list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. <a-input id="salesCollectionList-settleClientName" v-model.trim="queryParam.settleClientName" allowClear placeholder="请输入客户名称"/>
  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. <a-input id="salesCollectionList-receiverName" v-model.trim="queryParam.receiverName" allowClear placeholder="请输入收货客户名称"/>
  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" @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="$refs.table.refresh(true)" :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_financialCollection_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_financialCollection_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_financialCollection_receipt')"
  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="关联收款单" :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 getDate from '@/libs/getDate.js'
  205. import { STable, VSelect } from '@/components'
  206. import rangeDate from '@/views/common/rangeDate.vue'
  207. import subarea from '@/views/common/subarea.js'
  208. import Area from '@/views/common/area.js'
  209. import commonModal from '@/views/common/commonModal.vue'
  210. import detailModal from './detailModal.vue'
  211. import voucherModal from './voucherModal.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 },
  217. data () {
  218. return {
  219. spinning: false,
  220. showDetail: false,
  221. showSkModal: false,
  222. showVoucher: false,
  223. tableHeight: 0,
  224. queryParam: { // 查询条件
  225. beginDate: getDate.getThreeMonthDays().starttime + ' 00:00:00',
  226. endDate: getDate.getCurrMonthDays().endtime + ' 23:59:59',
  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. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  247. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  248. ], // 审核时间
  249. advanced: false,
  250. // 加载数据方法 必须为 Promise 对象
  251. loadData: parameter => {
  252. this.disabled = true
  253. this.spinning = true
  254. return settleReceiptList(Object.assign(parameter, this.queryParam)).then(res => {
  255. let data
  256. if (res.status == 200) {
  257. data = res.data
  258. const no = (data.pageNo - 1) * data.pageSize
  259. for (var i = 0; i < data.list.length; i++) {
  260. data.list[i].no = no + i + 1
  261. }
  262. this.total = data.count || 0
  263. this.disabled = false
  264. }
  265. this.spinning = false
  266. return data
  267. })
  268. },
  269. total: 0, // 合计
  270. rowSelectionInfo: null, // 批量选择的数据
  271. handlePlData: [], // 收款临时数据
  272. collectionType: 1 // 收款类型
  273. }
  274. },
  275. // 根据权限显示列表字段
  276. computed: {
  277. // 是否显示table选择框
  278. showSelect () {
  279. return this.$hasPermissions('B_financialCollection_receipt')
  280. },
  281. totalAmount () {
  282. let ret = 0
  283. this.handlePlData.map(item => {
  284. ret = ret + item.totalAmount
  285. })
  286. return ret.toFixed(2)
  287. },
  288. columns () {
  289. const arr = [
  290. { title: '创建时间', dataIndex: 'createDate', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  291. { title: '销售单号', scopedSlots: { customRender: 'bizNo' }, width: '9%', align: 'center' },
  292. { title: '备货单号', scopedSlots: { customRender: 'dispatchBillNo' }, width: '9%', align: 'center' },
  293. { title: '发货编号', dataIndex: 'sendNo', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  294. { title: '客户名称', dataIndex: 'settleClientName', align: 'left', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  295. { title: '收货客户名称', dataIndex: 'receiverName', align: 'left', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  296. { title: '产品款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  297. { title: '产品数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  298. // { title: '总售价', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  299. { title: '收款类型', dataIndex: 'keepTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  300. { title: '收款时间', dataIndex: 'settleTime', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  301. { title: '收款方式', dataIndex: 'settleStyleDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  302. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  303. { title: '财务状态', dataIndex: 'settleStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  304. { title: '单据状态', dataIndex: 'voidFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  305. { title: '操作', scopedSlots: { customRender: 'action' }, width: '4%', align: 'center' }
  306. ]
  307. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  308. arr.splice(8, 0, { title: '总售价', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  309. }
  310. return arr
  311. }
  312. },
  313. methods: {
  314. // 表格选中项
  315. rowSelectionFun (obj) {
  316. this.rowSelectionInfo = obj || null
  317. },
  318. // 审核时间 change
  319. dateAuditChange (date) {
  320. this.queryParam.beginDate = date[0] ? date[0] + ' 00:00:00' : ''
  321. this.queryParam.endDate = date[1] ? date[1] + ' 23:59:59' : ''
  322. },
  323. // 收款时间 change
  324. dateSettleChange (date) {
  325. this.queryParam.beginDateSettle = date[0] ? date[0] + ' 00:00:00' : ''
  326. this.queryParam.endDateSettle = date[1] ? date[1] + ' 23:59:59' : ''
  327. },
  328. // 重置
  329. resetSearchForm () {
  330. this.$refs.rangeAuditDate.resetDate(this.auditDate)
  331. if (this.advanced) { // 查询条件未展开时,该组件未渲染
  332. this.$refs.rangeSettleDate.resetDate()
  333. }
  334. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime + ' 00:00:00'
  335. this.queryParam.endDate = getDate.getCurrMonthDays().endtime + ' 23:59:59'
  336. this.queryParam.bizNo = ''
  337. this.queryParam.dispatchBillNo = ''
  338. this.queryParam.beginDateSettle = ''
  339. this.queryParam.endDateSettle = ''
  340. this.queryParam.settleClientName = ''
  341. this.queryParam.receiverName = ''
  342. this.queryParam.dealerLevel = undefined
  343. this.queryParam.settleStyle = undefined
  344. this.queryParam.keepType = undefined
  345. this.queryParam.subareaSn = undefined
  346. this.queryParam.billStatus = undefined
  347. this.queryParam.settleState = undefined
  348. this.queryParam.voidFlag = undefined
  349. this.queryParam.dealerProvinceSn = undefined
  350. this.queryParam.dealerCitySn = undefined
  351. this.queryParam.dealerCountySn = undefined
  352. this.$refs.table.refresh(true)
  353. },
  354. // 销售单详情
  355. handleDetail (row) {
  356. this.$router.push({ name: 'salesDetail', params: { sn: row.bizSn, type: 'salesCollection' } })
  357. },
  358. // 备货单号
  359. handleBhDetail (row) {
  360. this.$router.push({ name: 'pushOrderDetail', params: { sn: row.dispatchBillSn, type: 'salesCollection' } })
  361. },
  362. // 点击批量收款
  363. handlePlColle () {
  364. const _this = this
  365. const slen = _this.rowSelectionInfo.selectedRowKeys.length
  366. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  367. _this.$message.warning('请在列表勾选后再进行批量操作!')
  368. return
  369. }
  370. // 判断是否选择相同的客户
  371. const settleClientName = _this.rowSelectionInfo.selectedRows[0].settleClientName
  372. const haseq = _this.rowSelectionInfo.selectedRows.filter(item => item.settleClientName == settleClientName)
  373. if (haseq.length == slen) {
  374. this.handlePlData = _this.rowSelectionInfo.selectedRows
  375. this.showSkModal = true
  376. } else {
  377. this.$info({
  378. title: '操作提示',
  379. centered: true,
  380. content: '您所选择的备货单,不属于同一个客户,无法收款,请重新选择。只能针对一个客户的备货单进行批量收款。',
  381. onOk () {}
  382. })
  383. }
  384. },
  385. // 凭证
  386. handleVoucher (row) {
  387. this.showVoucher = true
  388. },
  389. // 点击收款
  390. handleColle (row) {
  391. this.handlePlData = [row]
  392. this.showSkModal = true
  393. },
  394. // 批量/单个收款
  395. handleSaveColle (row) {
  396. const _this = this
  397. const snList = []
  398. this.handlePlData.map(item => {
  399. snList.push(item.accountReceiptSn)
  400. })
  401. // 关联收款
  402. if (this.collectionType == 1) {
  403. this.showDetail = true
  404. this.$refs.detailModal.setData(this.handlePlData, snList)
  405. this.showSkModal = false
  406. _this.collectionType = 1
  407. } else {
  408. // 仅标记收款
  409. _this.spinning = true
  410. _this.showSkModal = false
  411. settleReceiptBatch({ snList: snList }).then(res => {
  412. if (res.status == 200) {
  413. _this.$message.success(res.message)
  414. _this.$refs.table.refresh()
  415. _this.spinning = false
  416. _this.collectionType = 1
  417. } else {
  418. _this.spinning = false
  419. }
  420. })
  421. }
  422. },
  423. pageInit () {
  424. const _this = this
  425. this.$nextTick(() => { // 页面渲染完成后的回调
  426. _this.setTableH()
  427. })
  428. },
  429. setTableH () {
  430. const tableSearchH = this.$refs.tableSearch.offsetHeight
  431. this.tableHeight = window.innerHeight - tableSearchH - 235
  432. }
  433. },
  434. watch: {
  435. advanced (newValue, oldValue) {
  436. const _this = this
  437. this.$nextTick(() => { // 页面渲染完成后的回调
  438. _this.setTableH()
  439. })
  440. },
  441. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  442. this.setTableH()
  443. }
  444. },
  445. mounted () {
  446. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  447. this.pageInit()
  448. this.resetSearchForm()
  449. }
  450. },
  451. activated () {
  452. // 如果是新页签打开,则重置当前页面
  453. if (this.$store.state.app.isNewTab) {
  454. this.pageInit()
  455. this.resetSearchForm()
  456. }
  457. // 仅刷新列表,不重置页面
  458. if (this.$store.state.app.updateList) {
  459. this.pageInit()
  460. this.$refs.table.refresh()
  461. }
  462. },
  463. beforeRouteEnter (to, from, next) {
  464. next(vm => {})
  465. }
  466. }
  467. </script>
  468. <style lang="less">
  469. .salesCollectionList-wrap{
  470. .active{
  471. color: #ed1c24;
  472. cursor: pointer;
  473. }
  474. .common{
  475. color: rgba(0, 0, 0);
  476. }
  477. }
  478. </style>