list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="receiptPrint-wrap">
  3. <a-card size="small" class="searchBoxNormal" :bordered="false">
  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" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="收款单号">
  15. <a-input id="salesCollectionList-bookNo" v-model.trim="queryParam.bookNo" allowClear placeholder="请输入备货单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="客户名称">
  20. <dealerSearchList ref="payerName" id="alesCollectionList-payerName" @change="custChange" />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24" v-show="isShowWarehouse">
  24. <a-form-model-item label="仓库">
  25. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn" :isPermission="true"></chooseWarehouse>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24" v-if="currentTab == 1">
  29. <a-form-item label="收款打印状态">
  30. <v-select
  31. v-model="queryParam.printStatus"
  32. ref="printStatus"
  33. id="salesCollectionList-printStatus"
  34. code="PRINT_STATUS"
  35. placeholder="请选择打印状态"
  36. allowClear
  37. ></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="足额打款">
  42. <v-select
  43. v-model="queryParam.fullPaymentFlag"
  44. ref="fullPaymentFlag"
  45. id="salesCollectionList-fullPaymentFlag"
  46. code="FLAG"
  47. placeholder="请选择是否足额打款"
  48. allowClear></v-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  52. <a-form-item label="客服">
  53. <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  54. </a-form-item>
  55. </a-col>
  56. <a-col :md="6" :sm="24">
  57. <span class="table-page-search-submitButtons">
  58. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  59. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  60. <!-- <a @click="advanced=!advanced" style="margin-left: 8px">
  61. {{ advanced ? '收起' : '展开' }}
  62. <a-icon :type="advanced ? 'up' : 'down'"/>
  63. </a> -->
  64. </span>
  65. </a-col>
  66. </a-row>
  67. </a-form>
  68. </div>
  69. </a-card>
  70. <a-card class="receiptPrint-body" size="small" :bordered="false">
  71. <a-spin :spinning="spinning" tip="Loading...">
  72. <div>
  73. <a-tabs v-model="currentTab" @change="changeTab">
  74. <a-tab-pane :key="1" tab="全部">
  75. </a-tab-pane>
  76. <a-tab-pane :key="2" tab="待打印">
  77. </a-tab-pane>
  78. </a-tabs>
  79. </div>
  80. <!-- 操作按钮 -->
  81. <div class="table-operator" v-if="$hasPermissions('B_SkPrint')">
  82. <a-button type="primary" :loading="spinning" @click="handlePlPrint()">批量打印</a-button>
  83. <span style="margin:0 10px">
  84. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  85. </span>
  86. </div>
  87. <!-- 列表 -->
  88. <s-table
  89. class="sTable fixPagination"
  90. ref="table"
  91. :style="{ height: tableHeight+85+'px' }"
  92. :row-selection="$hasPermissions('B_SkPrint')?{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: (record.printStatus !== 'NO_PRINT'&&record.printStatus !== 'PRINT') } })}:null"
  93. @rowSelection="rowSelectionFun"
  94. size="small"
  95. :rowKey="(record) => record.id"
  96. :columns="columns"
  97. :data="loadData"
  98. :scroll="{ y:tableHeight }"
  99. :defaultLoadData="false"
  100. bordered>
  101. <!-- 打印状态 -->
  102. <template slot="printStatus" slot-scope="text, record">
  103. <span v-if="record.printStatus=='NO_PRINT'" class="link-bule" @click="handlePrintStatus(record)">{{ record.printStatusDictValue }}</span>
  104. <span v-else>{{ record.printStatusDictValue }}</span>
  105. </template>
  106. <!-- 操作 -->
  107. <template slot="action" slot-scope="text, record">
  108. <div>
  109. <a-button
  110. size="small"
  111. type="link"
  112. v-if="(record.printStatus == 'NO_PRINT'||record.printStatus == 'PRINT')&&$hasPermissions('B_SkPrint')"
  113. class="button-warning"
  114. @click="handlePrint(record,0,record)"
  115. >收款打印</a-button>
  116. <a-button
  117. size="small"
  118. type="link"
  119. class="button-success"
  120. v-if="record.printStatus == 'PRINT'&&$hasPermissions('B_SKPrintRecord')"
  121. @click="viewPrint(record)"
  122. >打印记录</a-button>
  123. </div>
  124. </template>
  125. </s-table>
  126. <!-- 收款打印 -->
  127. <commonModal modalTit="收款打印预览" width="700pt" :showFooter="false" :openModal="showTipModal" @cancel="closeTipModal">
  128. <printModel ref="printModel" @cancel="closeTipModal" @printOk="printOk"></printModel>
  129. </commonModal>
  130. <!-- 打印记录 -->
  131. <recordModal v-drag ref="recordModal" modalTit="打印记录" :openModal="showRecordModal" @cancel="showRecordModal=false"></recordModal>
  132. <!-- 操作提示 -->
  133. <commonModal modalTit="操作提示" okText="暂不打印" :openModal="showPrintModal" @cancel="canselModal" @ok="updatePrintStatus">
  134. <div style="display:flex;flex-direction: column;align-items: center;">
  135. <div style="margin-bottom: 15px;font-size: 14px;">如需将打印状态回退至<strong>【暂不打印】</strong>,请点击下方按钮</div>
  136. <div style="line-height: 24px;">
  137. <div>收款单号:{{ tipData&&tipData.bookNo }}</div>
  138. <div>客户名称:{{ tipData&&tipData.payerName }}</div>
  139. </div>
  140. </div>
  141. </commonModal>
  142. </a-spin>
  143. </a-card>
  144. </div>
  145. </template>
  146. <script>
  147. import { commonMixin } from '@/utils/mixin'
  148. import rangeDate from '@/views/common/rangeDate.vue'
  149. import { STable, VSelect } from '@/components'
  150. import dealerSearchList from '@/views/common/dealerSearchList.vue'
  151. import commonModal from '@/views/common/commonModal.vue'
  152. import recordModal from './recordModal.vue'
  153. import printModel from './printModel.vue'
  154. import chooseWarehouse from '@/views/common/chooseWarehouse'
  155. import customerService from '@/views/common/customerService'
  156. import { financeBookDetailList, updateFinanceBookDetail, getBatchLastProcessInstance, checkPrintStatus } from '@/api/financeBook'
  157. export default {
  158. name: 'ReceiptPrintList',
  159. mixins: [commonMixin],
  160. components: { STable, VSelect, dealerSearchList, rangeDate, commonModal, recordModal, printModel, chooseWarehouse, customerService },
  161. data () {
  162. return {
  163. spinning: false,
  164. advanced: true, // 高级搜索 展开/关闭
  165. disabled: false, // 查询、重置按钮是否可操作
  166. tableHeight: 0,
  167. time: [],
  168. currentTab: 2,
  169. // 查询参数
  170. queryParam: {
  171. beginDate: '',
  172. endDate: '',
  173. bookNo: '',
  174. payerName: '',
  175. dealerSn: undefined,
  176. subareaSn: undefined,
  177. billStatus: undefined,
  178. dealerProvinceSn: undefined,
  179. fullPaymentFlag: undefined,
  180. warehouseSn: undefined,
  181. printStatus: 'NO_PRINT',
  182. bizUserSn: undefined
  183. },
  184. totalData: {
  185. totalAmount: 0,
  186. totalQty: 0,
  187. totalRecord: 0
  188. },
  189. showTipModal: false,
  190. showRecordModal: false,
  191. showPrintModal: false,
  192. showViewModal: false,
  193. tipData: null,
  194. // 加载数据方法 必须为 Promise 对象
  195. loadData: parameter => {
  196. this.disabled = true
  197. this.spinning = true
  198. if (this.currentTab == 1) {
  199. this.queryParam.isAll = '1'
  200. this.queryParam.status = 'AUDIT_PASS'
  201. }
  202. return financeBookDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  203. let data
  204. if (res.status == 200) {
  205. data = res.data
  206. const no = (data.pageNo - 1) * data.pageSize
  207. for (var i = 0; i < data.list.length; i++) {
  208. data.list[i].no = no + i + 1
  209. }
  210. this.disabled = false
  211. }
  212. this.spinning = false
  213. return data
  214. })
  215. },
  216. rowSelectionInfo: null // 批量选择的数据
  217. }
  218. },
  219. computed: {
  220. columns () {
  221. const arr = [
  222. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  223. { title: '允许打印时间', dataIndex: 'allowPrintTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '收款单号', dataIndex: 'bookNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '收款日期', dataIndex: 'receiptDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '客户名称', dataIndex: 'payerName', align: 'left', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '财务编码', dataIndex: 'dealerEntity.kdMidCustomerFnumber', align: 'center', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '订单金额', dataIndex: 'orderAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  229. { title: '收款金额', dataIndex: 'receiptAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  230. { title: '使用授信', dataIndex: 'useCreditAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  231. { title: '余款抵扣', dataIndex: 'balanceAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  232. { title: '户名', dataIndex: 'bankAccount', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '汇入银行', dataIndex: 'bankName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  234. { title: '足额打款', dataIndex: 'fullPaymentFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '说明', dataIndex: 'explainInfo', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  236. { title: '收款打印状态', dataIndex: 'printStatusDictValue', width: '6%', align: 'center', scopedSlots: { customRender: 'printStatus' } },
  237. { title: '打印次数', dataIndex: 'printNum', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  238. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  239. ]
  240. if (this.isShowWarehouse) {
  241. arr.splice(5, 0, { title: '仓库', dataIndex: 'warehouseName', align: 'center', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true })
  242. }
  243. return arr
  244. }
  245. },
  246. watch: {
  247. advanced (newValue, oldValue) {
  248. const _this = this
  249. this.$nextTick(() => { // 页面渲染完成后的回调
  250. _this.setTableH()
  251. })
  252. },
  253. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  254. this.setTableH()
  255. }
  256. },
  257. methods: {
  258. changeTab (v) {
  259. this.currentTab = v
  260. this.pageInit()
  261. this.resetSearchForm()
  262. },
  263. // 表格选中项
  264. rowSelectionFun (obj) {
  265. this.rowSelectionInfo = obj || null
  266. },
  267. // 批量打印
  268. async handlePlPrint () {
  269. const _this = this
  270. const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
  271. const slen = rows.length
  272. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  273. _this.$message.warning('请在列表勾选后再进行批量操作!')
  274. return false
  275. }
  276. this.spinning = true
  277. const bookSns = []
  278. const bookDetailSn = []
  279. rows.map(item => {
  280. if (bookSns.indexOf(item.bookSn) < 0) {
  281. bookSns.push(item.bookSn)
  282. }
  283. bookDetailSn.push(item.bookDetailSn)
  284. })
  285. // 检查是否有已打印数据
  286. if (this.currentTab == 2) {
  287. const hasPrintData = await checkPrintStatus(bookDetailSn).then(res => res.data)
  288. if (!hasPrintData) {
  289. _this.$info({
  290. title: '操作提示',
  291. centered: true,
  292. content: '您所选择的收款单,存在已打印的单子,请重新选择。',
  293. onOk () {
  294. _this.resetSearchForm()
  295. }
  296. })
  297. return
  298. }
  299. }
  300. const retArr = []
  301. const auditInfo = await getBatchLastProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSnList': bookSns }).then(res => res.data)
  302. console.log(auditInfo)
  303. bookSns.map(item => {
  304. // 授信明细,还款明细
  305. const rs = rows.filter(a => a.bookSn == item)
  306. let detailItemUseStr = ''
  307. let detailPayUseStr = ''
  308. rs.map(b => {
  309. if (b.detailItemUseList) {
  310. detailItemUseStr = this.getUseDetailInfo(b.detailItemUseList)
  311. }
  312. if (b.detailItemPayList) {
  313. detailPayUseStr = this.getUseDetailInfo(b.detailItemPayList)
  314. }
  315. })
  316. // 审核信息
  317. const auditStr = auditInfo ? this.getAuditInfo(auditInfo[item]) : ''
  318. retArr.push({ audit: auditStr, detail: detailItemUseStr, payDetail: detailPayUseStr, subList: rs })
  319. })
  320. console.log(retArr, '------------')
  321. this.handlePrint(retArr, 1, rows, bookSns)
  322. },
  323. // 获取授信西悉尼
  324. getUseDetailInfo (list) {
  325. let ret = ''
  326. list.map((k, i) => {
  327. ret = ret + k.itemName + '(' + k.itemAmount + ')' + (i == list.length - 1 ? '。' : ';')
  328. })
  329. return ret
  330. },
  331. // 获取审核信息
  332. getAuditInfo (auditList) {
  333. let auditStr = ''
  334. if (auditList && auditList.taskVOList) {
  335. const auditLists = auditList.taskVOList.filter(item => item.userType == '审批人')
  336. auditLists.map((a, i) => {
  337. auditStr = auditStr + a.userName + '(' + a.state + ')' + (i == auditLists.length - 1 ? '。' : ';')
  338. })
  339. }
  340. return auditStr
  341. },
  342. // 收款打印
  343. async handlePrint (row, type, list, bookSns) {
  344. const _this = this
  345. let auditInfo = null
  346. if (type == 0) {
  347. // 是否已打印
  348. if (this.currentTab == 2) {
  349. const hasPrintData = await checkPrintStatus([list.bookDetailSn]).then(res => res.data)
  350. if (!hasPrintData) {
  351. _this.$info({
  352. title: '操作提示',
  353. centered: true,
  354. content: '您所选择的收款单已打印,请重新选择。',
  355. onOk () {
  356. _this.resetSearchForm()
  357. }
  358. })
  359. return
  360. }
  361. }
  362. auditInfo = await getBatchLastProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSnList': [list.bookSn] }).then(res => res.data)
  363. }
  364. console.log(auditInfo)
  365. this.spinning = true
  366. this.showTipModal = true
  367. let detailItemUseStr = ''
  368. let detailPayUseStr = ''
  369. this.$nextTick(() => {
  370. // type == 0 单个打印时
  371. if (type == 0 && row.detailItemUseList) {
  372. detailItemUseStr = this.getUseDetailInfo(row.detailItemUseList)
  373. }
  374. if (type == 0 && row.detailItemPayList) {
  375. detailPayUseStr = this.getUseDetailInfo(row.detailItemPayList)
  376. }
  377. // 审核信息
  378. const auditStr = auditInfo ? this.getAuditInfo(auditInfo[list.bookSn]) : ''
  379. this.$refs.printModel.getData(type ? row : [{ audit: auditStr, detail: detailItemUseStr, payDetail: detailPayUseStr, subList: [row] }], type ? list : [list])
  380. })
  381. },
  382. printOk (res) {
  383. if (res) {
  384. this.spinning = false
  385. this.$refs.table.refresh()
  386. this.$refs.table.clearSelected()
  387. }
  388. },
  389. // 时间 change
  390. dateChange (date) {
  391. this.queryParam.beginDate = date[0] ? date[0] : ''
  392. this.queryParam.endDate = date[1] ? date[1] : ''
  393. },
  394. custChange (val) {
  395. console.log(val)
  396. if (val.row) {
  397. this.queryParam.dealerSn = val.row.dealerSn
  398. this.queryParam.payerName = undefined
  399. } else {
  400. this.queryParam.dealerSn = undefined
  401. this.queryParam.payerName = val.key
  402. }
  403. },
  404. handlePrintStatus (row) {
  405. this.tipData = row
  406. this.showPrintModal = true
  407. },
  408. canselModal () {
  409. this.tipData = null
  410. this.showPrintModal = false
  411. },
  412. updatePrintStatus () {
  413. updateFinanceBookDetail({ id: this.tipData.id, printStatus: 'UNABLE_PRINT' }).then(res => {
  414. if (res.status == 200) {
  415. this.canselModal()
  416. this.$message.info(res.message)
  417. this.$refs.table.refresh()
  418. }
  419. })
  420. },
  421. // 关闭打印预览
  422. closeTipModal () {
  423. this.showTipModal = false
  424. this.spinning = false
  425. this.$refs.printModel.clearData()
  426. },
  427. // 打印记录
  428. viewPrint (row) {
  429. this.showRecordModal = true
  430. this.$refs.recordModal.setData(row, {
  431. billType: 'FINANCE_BOOK_DETAIL',
  432. billSn: row.bookDetailSn,
  433. billNo: row.bookNo
  434. })
  435. },
  436. // 重置
  437. resetSearchForm () {
  438. this.time = []
  439. this.$refs.rangeDate.resetDate(this.time)
  440. this.$refs.payerName.resetForm()
  441. this.queryParam = {
  442. beginDate: '',
  443. endDate: '',
  444. bookNo: '',
  445. payerName: '',
  446. dealerSn: undefined,
  447. subareaSn: undefined,
  448. billStatus: undefined,
  449. dealerProvinceSn: undefined,
  450. fullPaymentFlag: undefined,
  451. warehouseSn: undefined,
  452. bizUserSn: undefined,
  453. printStatus: this.currentTab == 2 ? 'NO_PRINT' : undefined
  454. }
  455. this.$refs.table.refresh(true)
  456. this.$refs.table.clearSelected()
  457. },
  458. pageInit () {
  459. const _this = this
  460. this.$nextTick(() => { // 页面渲染完成后的回调
  461. _this.setTableH()
  462. })
  463. },
  464. setTableH () {
  465. const tableSearchH = this.$refs.tableSearch.offsetHeight
  466. this.tableHeight = window.innerHeight - tableSearchH - 295
  467. }
  468. },
  469. watch: {
  470. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  471. this.setTableH()
  472. }
  473. },
  474. mounted () {
  475. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  476. this.pageInit()
  477. this.resetSearchForm()
  478. }
  479. },
  480. activated () {
  481. // 如果是新页签打开,则重置当前页面
  482. if (this.$store.state.app.isNewTab) {
  483. this.pageInit()
  484. this.resetSearchForm()
  485. }
  486. // 仅刷新列表,不重置页面
  487. if (this.$store.state.app.updateList) {
  488. this.pageInit()
  489. this.$refs.table.refresh()
  490. }
  491. },
  492. beforeRouteEnter (to, from, next) {
  493. next(vm => {})
  494. }
  495. }
  496. </script>
  497. <style lang="less">
  498. .receiptPrint-wrap{
  499. .ant-tabs-bar{
  500. margin-bottom: 10px;
  501. }
  502. .receiptPrint-body{
  503. .ant-card-body{
  504. padding-top:0;
  505. }
  506. }
  507. }
  508. </style>