list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  15. <custList ref="custList" @change="custChange" v-model="queryParam.buyerSn"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="销售单号">
  20. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="采购单号">
  26. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="收款方式">
  31. <a-select placeholder="请选择收款方式" allowClear v-model="queryParam.settleStyleSn">
  32. <a-select-option v-for="item in settleStyleList" :key="item.settleStyleSn" :value="item.settleStyleSn">
  33. {{ item.name }}
  34. </a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="业务状态">
  40. <v-select
  41. v-model="queryParam.billStatus"
  42. ref="billStatus"
  43. id="salesManagementList-billStatus"
  44. code="SALES_BILL_STATUS"
  45. placeholder="请选择业务状态"
  46. allowClear></v-select>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="财务状态">
  51. <v-select
  52. v-model="queryParam.financialStatus"
  53. ref="financialStatus"
  54. id="salesManagementList-financialStatus"
  55. code="FINANCIAL_RECEIVE_STATUS"
  56. placeholder="请选择财务状态"
  57. allowClear></v-select>
  58. </a-form-item>
  59. </a-col>
  60. </template>
  61. <a-col :md="6" :sm="24">
  62. <span class="table-page-search-submitButtons">
  63. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  64. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  65. <a @click="advanced=!advanced" style="margin-left: 8px">
  66. {{ advanced ? '收起' : '展开' }}
  67. <a-icon :type="advanced ? 'up' : 'down'"/>
  68. </a>
  69. </span>
  70. </a-col>
  71. </a-row>
  72. </a-form>
  73. </div>
  74. <!-- 操作按钮 -->
  75. <div class="table-operator">
  76. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd">新增(零售)</a-button>
  77. </div>
  78. <!-- alert -->
  79. <a-alert type="info" style="margin-bottom:10px">
  80. <div slot="message">
  81. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? totalData.totalAmount : '--' }}</strong>元;
  82. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  83. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  84. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  85. </div>
  86. </a-alert>
  87. <!-- 列表 -->
  88. <s-table
  89. class="sTable fixPagination"
  90. ref="table"
  91. :style="{ height: tableHeight+87+'px' }"
  92. size="small"
  93. :rowKey="(record) => record.id"
  94. :columns="columns"
  95. :data="loadData"
  96. :scroll="{ x: 1400, y:tableHeight }"
  97. bordered>
  98. <!-- 销售单号 -->
  99. <template slot="salesBillNo" slot-scope="text, record">
  100. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  101. <span v-else>{{ record.salesBillNo }}</span>
  102. </template>
  103. <!-- 急件 -->
  104. <template slot="oosFlag" slot-scope="text, record">
  105. <a-tag :color="record.oosFlag==1?'red':'#ccc'" >{{ record.oosFlagDictValue }}</a-tag>
  106. </template>
  107. <!-- 操作 -->
  108. <template slot="action" slot-scope="text, record">
  109. <a-button
  110. size="small"
  111. type="link"
  112. class="button-warning"
  113. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  114. @click="handleEexamine(record)"
  115. >审核</a-button>
  116. <a-button
  117. size="small"
  118. type="link"
  119. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  120. class="button-primary"
  121. @click="handleSend(record)"
  122. >出库</a-button>
  123. <a-button
  124. size="small"
  125. type="link"
  126. class="button-info"
  127. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  128. @click="handleEdit(record)"
  129. >
  130. 编辑
  131. </a-button>
  132. <a-button
  133. size="small"
  134. type="link"
  135. class="button-error"
  136. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  137. @click="handleDel(record)"
  138. >
  139. 删除
  140. </a-button>
  141. <a-button
  142. size="small"
  143. type="link"
  144. class="button-info"
  145. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  146. @click="handleEdit(record)"
  147. >
  148. 改单
  149. </a-button>
  150. <a-button
  151. size="small"
  152. type="link"
  153. class="button-error"
  154. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  155. @click="handleDel(record, 'cancel')"
  156. >
  157. 取消
  158. </a-button>
  159. <span v-if="!(record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')) && !(record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')) && !(((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')) && !(((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')) && !((record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')) && !((record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel'))">--</span>
  160. </template>
  161. </s-table>
  162. </a-spin>
  163. <!-- 选择客户弹框 -->
  164. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  165. <!-- 审核 -->
  166. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  167. </a-card>
  168. </template>
  169. <script>
  170. import { STable, VSelect } from '@/components'
  171. import chooseCustomModal from './chooseCustomModal.vue'
  172. import auditModal from '@/views/common/auditModal.vue'
  173. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount } from '@/api/sales'
  174. import { settleStyleQueryAll } from '@/api/settleStyle'
  175. import rangeDate from '@/views/common/rangeDate.vue'
  176. import custList from '@/views/common/custList.vue'
  177. export default {
  178. name: 'TableList',
  179. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList },
  180. data () {
  181. return {
  182. spinning: false,
  183. tableHeight: 0,
  184. advanced: true, // 高级搜索 展开/关闭
  185. disabled: false, // 查询、重置按钮是否可操作
  186. openModal: false, // 选择客户弹框是否显示
  187. settleStyleList: [], // 收款方式
  188. // 查询参数
  189. queryParam: {
  190. beginDate: '',
  191. endDate: '',
  192. buyerSn: undefined, // 客户名称
  193. salesBillNo: '', // 销售单号
  194. purchaseBillNo: '', // 采购单号
  195. payType: undefined, // 支付方式
  196. settleStyleSn: undefined, // 收款方式
  197. billStatus: undefined, // 业务状态
  198. financialStatus: undefined // 财务状态
  199. },
  200. totalData: {
  201. totalAmount: 0,
  202. totalCategory: 0,
  203. totalQty: 0,
  204. totalRecord: 0
  205. },
  206. // 表头
  207. columns: [
  208. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  209. { title: '创建时间', dataIndex: 'createDate', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  210. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  211. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: 120, align: 'center' },
  212. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '总款数', dataIndex: 'totalCategory', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '总数量', dataIndex: 'totalQty', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '总售价', dataIndex: 'totalAmount', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: '收款方式', dataIndex: 'settleStyleEntity.name', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '审核时间', dataIndex: 'auditDate', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '急件', dataIndex: 'oosFlag', scopedSlots: { customRender: 'oosFlag' }, width: 60, align: 'center' },
  220. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '操作', scopedSlots: { customRender: 'action' }, width: 140, align: 'center', fixed: 'right' }
  223. ],
  224. // 加载数据方法 必须为 Promise 对象
  225. loadData: parameter => {
  226. this.disabled = true
  227. this.spinning = true
  228. // 查询总计
  229. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  230. this.totalData = Object.assign(this.totalData, res.data || {})
  231. })
  232. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  233. const data = res.data
  234. const no = (data.pageNo - 1) * data.pageSize
  235. for (var i = 0; i < data.list.length; i++) {
  236. data.list[i].no = no + i + 1
  237. }
  238. this.disabled = false
  239. this.spinning = false
  240. return data
  241. })
  242. },
  243. visibleAudit: false,
  244. auditInfo: null,
  245. spinningAudit: false
  246. }
  247. },
  248. methods: {
  249. // 时间 change
  250. dateChange (date) {
  251. this.queryParam.beginDate = date[0]
  252. this.queryParam.endDate = date[1]
  253. },
  254. // 新增
  255. handleAdd () {
  256. this.openModal = true
  257. },
  258. // 选择客户成功
  259. chooseCustomOk (data) {
  260. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  261. },
  262. // 审核
  263. handleEexamine (row) {
  264. this.auditInfo = row
  265. this.visibleAudit = true
  266. },
  267. auditOrder (billStatus) {
  268. this.spinningAudit = true
  269. salesWriteAudit({
  270. id: this.auditInfo.id,
  271. billStatus: billStatus
  272. }).then(res => {
  273. if (res.status == 200) {
  274. this.visibleAudit = false
  275. this.$message.success(res.message)
  276. this.$refs.table.refresh()
  277. this.spinningAudit = false
  278. } else {
  279. this.visibleAudit = false
  280. this.spinningAudit = false
  281. }
  282. })
  283. },
  284. // 出库
  285. handleSend (row) {
  286. const _this = this
  287. this.$confirm({
  288. title: '提示',
  289. content: '确认要出库吗?',
  290. centered: true,
  291. closable: true,
  292. onOk () {
  293. _this.spinning = true
  294. salesWriteStockOut({
  295. salesBillSn: row.salesBillSn
  296. }).then(res => {
  297. if (res.status == 200) {
  298. _this.$message.success(res.message)
  299. _this.$refs.table.refresh()
  300. _this.spinning = false
  301. } else {
  302. _this.spinning = false
  303. }
  304. })
  305. }
  306. })
  307. },
  308. // 详情
  309. handleDetail (row) {
  310. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  311. },
  312. // 编辑
  313. handleEdit (row) {
  314. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  315. },
  316. // 删除
  317. handleDel (row, type) {
  318. const _this = this
  319. let content = '确认要删除吗?'
  320. if (type == 'cancel') {
  321. content = '确认要取消吗?'
  322. }
  323. this.$confirm({
  324. title: '提示',
  325. content: content,
  326. centered: true,
  327. closable: true,
  328. onOk () {
  329. _this.spinning = true
  330. salesDel({ id: row.id }).then(res => {
  331. if (res.status == 200) {
  332. _this.$message.success(res.message)
  333. _this.$refs.table.refresh()
  334. _this.spinning = false
  335. } else {
  336. _this.spinning = false
  337. }
  338. })
  339. }
  340. })
  341. },
  342. // 客户 change
  343. custChange (obj) {
  344. this.queryParam.buyerSn = obj.key || undefined
  345. },
  346. // 重置
  347. resetSearchForm () {
  348. this.$refs.rangeDate.resetDate()
  349. this.queryParam.beginDate = ''
  350. this.queryParam.endDate = ''
  351. this.queryParam.buyerSn = undefined
  352. this.queryParam.salesBillNo = ''
  353. this.queryParam.purchaseBillNo = ''
  354. this.queryParam.payType = undefined
  355. this.queryParam.settleStyleSn = undefined
  356. this.queryParam.billStatus = undefined
  357. this.queryParam.financialStatus = undefined
  358. this.$refs.custList.resetForm()
  359. this.$refs.table.refresh(true)
  360. },
  361. // 获取收款方式
  362. getSettleStyle () {
  363. settleStyleQueryAll().then(res => {
  364. if (res.status == 200) {
  365. this.settleStyleList = res.data
  366. }
  367. })
  368. },
  369. setTableH () {
  370. const tableSearchH = this.$refs.tableSearch.offsetHeight
  371. this.tableHeight = window.innerHeight - tableSearchH - 285
  372. }
  373. },
  374. mounted () {
  375. const _this = this
  376. this.$nextTick(() => { // 页面渲染完成后的回调
  377. _this.setTableH()
  378. })
  379. },
  380. watch: {
  381. advanced (newValue, oldValue) {
  382. const _this = this
  383. setTimeout(() => {
  384. _this.setTableH()
  385. }, 400)
  386. }
  387. },
  388. beforeRouteEnter (to, from, next) {
  389. next(vm => {
  390. vm.getSettleStyle()
  391. })
  392. }
  393. }
  394. </script>
  395. <style lang="less">
  396. .ssalesManagementList-wrap{
  397. .sTable{
  398. margin-top: 15px;
  399. }
  400. }
  401. </style>