list.vue 21 KB

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