list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesCollectionList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeAuditDate" :value="auditDate" @change="dateAuditChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称">
  15. <dealerSubareaScopeList ref="settleClientName" id="salesCollectionList-settleClientName" @change="custChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="销售单号">
  20. <a-input id="salesCollectionList-bizNo" v-model.trim="queryParam.bizNo" 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="salesCollectionList-dispatchBillNo" v-model.trim="queryParam.dispatchBillNo" allowClear placeholder="请输入备货单号"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="收货客户名称">
  31. <dealerSubareaScopeList ref="receiverName" id="salesCollectionList-receiverName" @change="receiverChange" />
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="收款类型">
  36. <v-select
  37. v-model="queryParam.keepType"
  38. ref="keepType"
  39. id="salesCollectionList-keepType"
  40. code="KEEP_TYPE"
  41. placeholder="请选择收款类型"
  42. allowClear></v-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="收款时间">
  47. <rangeDate ref="rangeSettleDate" :value="settleDate" @change="dateSettleChange" />
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="收款方式">
  52. <v-select
  53. v-model="queryParam.settleStyle"
  54. ref="settleStyle"
  55. id="salesCollectionList-settleStyle"
  56. code="SETTLE_STYLE"
  57. placeholder="请选择收款方式"
  58. allowClear></v-select>
  59. </a-form-item>
  60. </a-col>
  61. <a-col :md="6" :sm="24">
  62. <a-form-item label="业务状态">
  63. <v-select
  64. v-model="queryParam.billStatus"
  65. ref="billStatus"
  66. id="salesCollectionList-billStatus"
  67. code="DISPATCH_BILL_STATUS"
  68. placeholder="请选择业务状态"
  69. allowClear></v-select>
  70. </a-form-item>
  71. </a-col>
  72. <a-col :md="6" :sm="24">
  73. <a-form-item label="财务状态">
  74. <v-select
  75. v-model="queryParam.settleState"
  76. ref="settleState"
  77. id="salesCollectionList-settleState"
  78. code="FINANCIAL_RECEIVE_STATUS"
  79. placeholder="请选择财务状态"
  80. allowClear></v-select>
  81. </a-form-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-item label="单据状态">
  85. <v-select
  86. v-model="queryParam.voidFlag"
  87. ref="voidFlag"
  88. id="salesCollectionList-voidFlag"
  89. code="VOID_FLAG"
  90. placeholder="请选择单据状态"
  91. allowClear></v-select>
  92. </a-form-item>
  93. </a-col>
  94. <a-col :md="6" :sm="24">
  95. <a-form-item label="所在区域">
  96. <subarea id="salesCollectionList-subarea" v-model="queryParam.subareaSn"></subarea>
  97. </a-form-item>
  98. </a-col>
  99. <a-col :md="6" :sm="24">
  100. <a-row>
  101. <a-form-item label="地区">
  102. <a-col span="24">
  103. <a-form-item prop="dealerProvinceSn" style="margin: 0;">
  104. <Area id="salesCollectionList-dealerProvinceSn" v-model="queryParam.dealerProvinceSn" placeholder="请选择省"></Area>
  105. </a-form-item>
  106. </a-col>
  107. </a-form-item>
  108. </a-row>
  109. </a-col>
  110. </template>
  111. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  112. <a-button type="primary" @click="searchTable" :disabled="disabled" id="salesCollectionList-refresh">查询</a-button>
  113. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesCollectionList-reset">重置</a-button>
  114. <a @click="advanced=!advanced" style="margin-left: 5px">
  115. {{ advanced ? '收起' : '展开' }}
  116. <a-icon :type="advanced ? 'up' : 'down'"/>
  117. </a>
  118. </a-col>
  119. </a-row>
  120. </a-form>
  121. </div>
  122. <!-- 操作按钮 -->
  123. <div class="table-operator" v-if="$hasPermissions('B_salesCollection_receipt')">
  124. <a-button type="primary" @click="handlePlColle()" class="button-error">批量收款</a-button>
  125. <span style="margin-left: 8px">
  126. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  127. </span>
  128. </div>
  129. <!-- 列表 -->
  130. <s-table
  131. class="sTable fixPagination"
  132. ref="table"
  133. :style="{ height: tableHeight+84.5+'px' }"
  134. size="small"
  135. :row-selection="showSelect?{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.settleState=='FINISH' } })}:null"
  136. @rowSelection="rowSelectionFun"
  137. :rowKey="(record) => record.id"
  138. :columns="columns"
  139. :data="loadData"
  140. :scroll="{ y: tableHeight }"
  141. :defaultLoadData="false"
  142. bordered>
  143. <!-- 单号 -->
  144. <template slot="bizNo" slot-scope="text, record">
  145. <span v-if="$hasPermissions('B_salesDetail')" class="link-bule" @click="handleDetail(record)">{{ record.bizNo }}</span>
  146. <span v-else>{{ record.bizNo }}</span>
  147. </template>
  148. <!-- 下推单号 -->
  149. <template slot="dispatchBillNo" slot-scope="text, record">
  150. <span v-if="$hasPermissions('B_dispatchDetail')" class="link-bule" @click="handleBhDetail(record)">{{ record.dispatchBillNo }}</span>
  151. <span v-else>{{ record.dispatchBillNo || '--' }}</span>
  152. </template>
  153. <!-- 操作 -->
  154. <template slot="action" slot-scope="text, record">
  155. <a-button
  156. size="small"
  157. type="link"
  158. v-if="record.settleState=='WAIT' && record.voidFlag!=1 && $hasPermissions('B_salesCollection_receipt')"
  159. class="button-warning"
  160. @click="handleColle(record)"
  161. id="financialCollectionList-audit-btn">收款</a-button>
  162. <a-button
  163. size="small"
  164. type="link"
  165. v-if="record.settleState=='FINISH' && $hasPermissions('B_salesCollection_record')"
  166. class="button-warning"
  167. @click="handleVoucher(record)"
  168. id="financialCollectionList-voucher-btn">凭证</a-button>
  169. <span v-if="record.settleState=='WAIT' && record.voidFlag==1">--</span>
  170. </template>
  171. </s-table>
  172. <!-- 销售收款弹框 -->
  173. <commonModal
  174. :openModal="showSkModal"
  175. modalTit="销售收款"
  176. @cancel="showSkModal=false"
  177. @ok="handleSaveColle"
  178. >
  179. <div style="text-align: center;line-height: 24px;">
  180. <div v-if="handlePlData.length">{{ handlePlData[0].settleClientName }},共 {{ handlePlData && handlePlData.length }} 个备货单,合计 {{ totalAmount }} 元</div>
  181. <div style="padding: 15px 0;font-weight: bold;">请选择收款类型</div>
  182. <div>
  183. <a-radio-group v-model="collectionType">
  184. <a-radio :value="1">
  185. 关联收款单
  186. </a-radio>
  187. <a-radio :value="0">
  188. 仅标记收款
  189. </a-radio>
  190. </a-radio-group>
  191. </div>
  192. </div>
  193. </commonModal>
  194. <!-- 关联收款单 -->
  195. <detailModal ref="detailModal" modalTit="关联收款单" @ok="relationSuccess" :openModal="showDetail" @cancel="showDetail=false"></detailModal>
  196. <!-- 销售收款凭证 -->
  197. <voucherModal ref="voucherModal" modalTit="销售收款凭证" :openModal="showVoucher" @cancel="showVoucher=false"></voucherModal>
  198. </a-spin>
  199. </a-card>
  200. </template>
  201. <script>
  202. import { commonMixin } from '@/utils/mixin'
  203. import moment from 'moment'
  204. import { STable, VSelect } from '@/components'
  205. import rangeDate from '@/views/common/rangeDate.vue'
  206. import subarea from '@/views/common/subarea.js'
  207. import Area from '@/views/common/area.js'
  208. import commonModal from '@/views/common/commonModal.vue'
  209. import detailModal from './detailModal.vue'
  210. import voucherModal from './voucherModal.vue'
  211. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  212. import { settleReceiptList, settleReceiptBatch } from '@/api/settleReceipt'
  213. export default {
  214. name: 'SalesCollectionList',
  215. mixins: [commonMixin],
  216. components: { STable, VSelect, subarea, rangeDate, commonModal, detailModal, Area, voucherModal, dealerSubareaScopeList },
  217. data () {
  218. return {
  219. spinning: false,
  220. showDetail: false,
  221. showSkModal: false,
  222. showVoucher: false,
  223. tableHeight: 0,
  224. queryParam: { // 查询条件
  225. beginDate: '',
  226. endDate: '',
  227. bizNo: '',
  228. dispatchBillNo: '',
  229. beginDateSettle: '',
  230. endDateSettle: '',
  231. settleClientName: '',
  232. receiverName: '',
  233. dealerLevel: undefined,
  234. settleStyle: undefined,
  235. keepType: undefined,
  236. subareaSn: undefined,
  237. billStatus: undefined,
  238. settleState: undefined,
  239. voidFlag: undefined,
  240. dealerProvinceSn: undefined,
  241. dealerCitySn: undefined,
  242. dealerCountySn: undefined
  243. },
  244. disabled: false, // 查询、重置按钮是否可操作
  245. auditDate: [], // 审核时间
  246. settleDate: [],
  247. advanced: false,
  248. // 加载数据方法 必须为 Promise 对象
  249. loadData: parameter => {
  250. this.disabled = true
  251. this.spinning = true
  252. return settleReceiptList(Object.assign(parameter, this.queryParam)).then(res => {
  253. let data
  254. if (res.status == 200) {
  255. data = res.data
  256. const no = (data.pageNo - 1) * data.pageSize
  257. for (var i = 0; i < data.list.length; i++) {
  258. data.list[i].no = no + i + 1
  259. }
  260. this.total = data.count || 0
  261. this.disabled = false
  262. }
  263. this.spinning = false
  264. return data
  265. })
  266. },
  267. total: 0, // 合计
  268. rowSelectionInfo: null, // 批量选择的数据
  269. handlePlData: [], // 收款临时数据
  270. collectionType: 1 // 收款类型
  271. }
  272. },
  273. // 根据权限显示列表字段
  274. computed: {
  275. // 是否显示table选择框
  276. showSelect () {
  277. return this.$hasPermissions('B_salesCollection_receipt')
  278. },
  279. totalAmount () {
  280. let ret = 0
  281. this.handlePlData.map(item => {
  282. ret = ret + item.totalAmount
  283. })
  284. return ret.toFixed(2)
  285. },
  286. columns () {
  287. const arr = [
  288. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  289. { title: '创建时间', dataIndex: 'createDate', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  290. { title: '销售单号', scopedSlots: { customRender: 'bizNo' }, width: '9%', align: 'center' },
  291. { title: '备货单号', scopedSlots: { customRender: 'dispatchBillNo' }, width: '9%', align: 'center' },
  292. { title: '发货编号', dataIndex: 'sendNo', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  293. { title: '客户名称', dataIndex: 'settleClientName', align: 'left', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  294. { title: '收货客户名称', dataIndex: 'receiverName', align: 'left', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  295. { title: '产品款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  296. { title: '产品数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  297. // { title: '总售价', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  298. { title: '收款类型', dataIndex: 'keepTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  299. { title: '收款时间', dataIndex: 'settleTime', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  300. { title: '收款方式', dataIndex: 'settleStyleDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  301. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  302. { title: '财务状态', dataIndex: 'settleStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  303. { title: '单据状态', dataIndex: 'voidFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  304. { title: '操作', scopedSlots: { customRender: 'action' }, width: '4%', align: 'center' }
  305. ]
  306. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  307. arr.splice(9, 0, { title: '总售价', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  308. }
  309. return arr
  310. }
  311. },
  312. methods: {
  313. custChange (val) {
  314. this.queryParam.settleClientName = val.name
  315. },
  316. receiverChange (val) {
  317. this.queryParam.receiverName = val.name
  318. },
  319. // 表格选中项
  320. rowSelectionFun (obj) {
  321. this.rowSelectionInfo = obj || null
  322. },
  323. // 审核时间 change
  324. dateAuditChange (date) {
  325. this.queryParam.beginDate = date[0] ? date[0] + ' 00:00:00' : ''
  326. this.queryParam.endDate = date[1] ? date[1] + ' 23:59:59' : ''
  327. },
  328. // 收款时间 change
  329. dateSettleChange (date) {
  330. this.queryParam.beginDateSettle = date[0] ? date[0] + ' 00:00:00' : ''
  331. this.queryParam.endDateSettle = date[1] ? date[1] + ' 23:59:59' : ''
  332. },
  333. searchTable () {
  334. this.$refs.table.refresh(true)
  335. this.$refs.table.clearSelected()
  336. },
  337. // 重置
  338. resetSearchForm () {
  339. this.auditDate = []
  340. this.$refs.rangeAuditDate.resetDate(this.auditDate)
  341. this.$refs.settleClientName.resetForm()
  342. if (this.advanced) { // 查询条件未展开时,该组件未渲染
  343. this.settleDate = []
  344. this.$refs.rangeSettleDate.resetDate()
  345. this.$refs.receiverName.resetForm()
  346. }
  347. this.queryParam.beginDate = ''
  348. this.queryParam.endDate = ''
  349. this.queryParam.bizNo = ''
  350. this.queryParam.dispatchBillNo = ''
  351. this.queryParam.beginDateSettle = ''
  352. this.queryParam.endDateSettle = ''
  353. this.queryParam.settleClientName = ''
  354. this.queryParam.receiverName = ''
  355. this.queryParam.dealerLevel = undefined
  356. this.queryParam.settleStyle = undefined
  357. this.queryParam.keepType = undefined
  358. this.queryParam.subareaSn = undefined
  359. this.queryParam.billStatus = undefined
  360. this.queryParam.settleState = undefined
  361. this.queryParam.voidFlag = undefined
  362. this.queryParam.dealerProvinceSn = undefined
  363. this.queryParam.dealerCitySn = undefined
  364. this.queryParam.dealerCountySn = undefined
  365. this.$refs.table.refresh(true)
  366. this.$refs.table.clearSelected()
  367. },
  368. // 销售单详情
  369. handleDetail (row) {
  370. this.$router.push({ name: 'salesDetail', params: { sn: row.bizSn, type: 'salesCollection' } })
  371. },
  372. // 备货单号
  373. handleBhDetail (row) {
  374. this.$router.push({ name: 'pushOrderDetail', params: { sn: row.dispatchBillSn, type: 'salesCollection' } })
  375. },
  376. // 点击批量收款
  377. handlePlColle () {
  378. const _this = this
  379. const slen = _this.rowSelectionInfo.selectedRowKeys.length
  380. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  381. _this.$message.warning('请在列表勾选后再进行批量操作!')
  382. return
  383. }
  384. // 判断是否选择相同的客户
  385. const settleClientName = _this.rowSelectionInfo.selectedRows[0].settleClientName
  386. const haseq = _this.rowSelectionInfo.selectedRows.filter(item => item.settleClientName == settleClientName)
  387. if (haseq.length == slen) {
  388. this.handlePlData = _this.rowSelectionInfo.selectedRows
  389. this.showSkModal = true
  390. } else {
  391. this.$info({
  392. title: '操作提示',
  393. centered: true,
  394. content: '您所选择的备货单,不属于同一个客户,无法收款,请重新选择。只能针对一个客户的备货单进行批量收款。',
  395. onOk () {}
  396. })
  397. }
  398. },
  399. // 凭证
  400. handleVoucher (row) {
  401. this.showVoucher = true
  402. this.$refs.voucherModal.getData(row)
  403. },
  404. // 点击收款
  405. handleColle (row) {
  406. this.handlePlData = [row]
  407. this.showSkModal = true
  408. },
  409. // 批量/单个收款
  410. handleSaveColle (row) {
  411. const _this = this
  412. const snList = []
  413. this.handlePlData.map(item => {
  414. snList.push(item.accountReceiptSn)
  415. })
  416. // 关联收款
  417. if (this.collectionType == 1) {
  418. this.showDetail = true
  419. this.$refs.detailModal.setData(this.handlePlData, snList)
  420. this.showSkModal = false
  421. _this.collectionType = 1
  422. } else {
  423. // 仅标记收款
  424. _this.spinning = true
  425. _this.showSkModal = false
  426. settleReceiptBatch({ snList: snList }).then(res => {
  427. if (res.status == 200) {
  428. _this.$message.success(res.message)
  429. _this.$refs.table.refresh()
  430. _this.spinning = false
  431. _this.collectionType = 1
  432. } else {
  433. _this.spinning = false
  434. }
  435. })
  436. }
  437. },
  438. // 关联收款成功
  439. relationSuccess () {
  440. this.$refs.table.refresh()
  441. this.showDetail = false
  442. this.$refs.table.clearSelected()
  443. },
  444. pageInit () {
  445. const _this = this
  446. this.$nextTick(() => { // 页面渲染完成后的回调
  447. _this.setTableH()
  448. })
  449. },
  450. setTableH () {
  451. const tableSearchH = this.$refs.tableSearch.offsetHeight
  452. this.tableHeight = window.innerHeight - tableSearchH - 235
  453. }
  454. },
  455. watch: {
  456. advanced (newValue, oldValue) {
  457. const _this = this
  458. this.$nextTick(() => { // 页面渲染完成后的回调
  459. _this.setTableH()
  460. })
  461. },
  462. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  463. this.setTableH()
  464. }
  465. },
  466. mounted () {
  467. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  468. this.pageInit()
  469. this.resetSearchForm()
  470. }
  471. },
  472. activated () {
  473. // 如果是新页签打开,则重置当前页面
  474. if (this.$store.state.app.isNewTab) {
  475. this.pageInit()
  476. this.resetSearchForm()
  477. }
  478. // 仅刷新列表,不重置页面
  479. if (this.$store.state.app.updateList) {
  480. this.pageInit()
  481. this.$refs.table.refresh()
  482. }
  483. },
  484. beforeRouteEnter (to, from, next) {
  485. next(vm => {})
  486. }
  487. }
  488. </script>
  489. <style lang="less">
  490. .salesCollectionList-wrap{
  491. .active{
  492. color: #ed1c24;
  493. cursor: pointer;
  494. }
  495. .common{
  496. color: rgba(0, 0, 0);
  497. }
  498. }
  499. </style>