list.vue 21 KB

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