list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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, checkPrintStatus } from '@/api/financeBook'
  157. import { getProcessInstance } from '@/api/expenseManagement'
  158. export default {
  159. name: 'ReceiptPrintList',
  160. mixins: [commonMixin],
  161. components: { STable, VSelect, dealerSearchList, rangeDate, commonModal, recordModal, printModel, chooseWarehouse, customerService },
  162. data () {
  163. return {
  164. spinning: false,
  165. advanced: true, // 高级搜索 展开/关闭
  166. disabled: false, // 查询、重置按钮是否可操作
  167. tableHeight: 0,
  168. time: [],
  169. currentTab: 2,
  170. // 查询参数
  171. queryParam: {
  172. beginDate: '',
  173. endDate: '',
  174. bookNo: '',
  175. payerName: '',
  176. dealerSn: undefined,
  177. subareaSn: undefined,
  178. billStatus: undefined,
  179. dealerProvinceSn: undefined,
  180. fullPaymentFlag: undefined,
  181. warehouseSn: undefined,
  182. printStatus: 'NO_PRINT',
  183. bizUserSn: undefined
  184. },
  185. totalData: {
  186. totalAmount: 0,
  187. totalQty: 0,
  188. totalRecord: 0
  189. },
  190. showTipModal: false,
  191. showRecordModal: false,
  192. showPrintModal: false,
  193. showViewModal: false,
  194. tipData: null,
  195. // 加载数据方法 必须为 Promise 对象
  196. loadData: parameter => {
  197. this.disabled = true
  198. this.spinning = true
  199. if (this.currentTab == 1) {
  200. this.queryParam.isAll = '1'
  201. this.queryParam.status = 'AUDIT_PASS'
  202. }
  203. return financeBookDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  204. let data
  205. if (res.status == 200) {
  206. data = res.data
  207. const no = (data.pageNo - 1) * data.pageSize
  208. for (var i = 0; i < data.list.length; i++) {
  209. data.list[i].no = no + i + 1
  210. }
  211. this.disabled = false
  212. }
  213. this.spinning = false
  214. return data
  215. })
  216. },
  217. rowSelectionInfo: null // 批量选择的数据
  218. }
  219. },
  220. computed: {
  221. columns () {
  222. const arr = [
  223. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  224. { title: '允许打印时间', dataIndex: 'allowPrintTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '收款单号', dataIndex: 'bookNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '收款日期', dataIndex: 'receiptDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  227. { title: '客户名称', dataIndex: 'payerName', align: 'left', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '财务编码', dataIndex: 'dealerEntity.kdMidCustomerFnumber', align: 'center', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  229. { title: '订单金额', dataIndex: 'orderAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  230. { title: '收款金额', dataIndex: 'receiptAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  231. { title: '使用授信', dataIndex: 'useCreditAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  232. { title: '授信还款', dataIndex: 'payCreditAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  233. { title: '余款抵扣', dataIndex: 'balanceAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  234. { title: '跨月打款', dataIndex: 'nextMonthAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  235. { title: '特殊申请发货', dataIndex: 'specialSendAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  236. { title: '户名', dataIndex: 'bankAccount', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  237. { title: '汇入银行', dataIndex: 'bankName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '足额打款', dataIndex: 'fullPaymentFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '说明', dataIndex: 'explainInfo', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  240. { title: '收款打印状态', dataIndex: 'printStatusDictValue', width: '6%', align: 'center', scopedSlots: { customRender: 'printStatus' } },
  241. { title: '打印次数', dataIndex: 'printNum', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  243. ]
  244. if (this.isShowWarehouse) {
  245. arr.splice(5, 0, { title: '仓库', dataIndex: 'warehouseName', align: 'center', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true })
  246. }
  247. return arr
  248. }
  249. },
  250. watch: {
  251. advanced (newValue, oldValue) {
  252. const _this = this
  253. this.$nextTick(() => { // 页面渲染完成后的回调
  254. _this.setTableH()
  255. })
  256. },
  257. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  258. this.setTableH()
  259. }
  260. },
  261. methods: {
  262. changeTab (v) {
  263. this.currentTab = v
  264. this.pageInit()
  265. this.resetSearchForm()
  266. },
  267. // 表格选中项
  268. rowSelectionFun (obj) {
  269. this.rowSelectionInfo = obj || null
  270. },
  271. // 批量打印
  272. async handlePlPrint () {
  273. const _this = this
  274. const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
  275. const slen = rows.length
  276. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  277. _this.$message.warning('请在列表勾选后再进行批量操作!')
  278. return false
  279. }
  280. this.spinning = true
  281. const bookSns = []
  282. const bookDetailSn = []
  283. rows.map(item => {
  284. if (bookSns.indexOf(item.bookSn) < 0) {
  285. bookSns.push(item.bookSn)
  286. }
  287. bookDetailSn.push(item.bookDetailSn)
  288. })
  289. // 检查是否有已打印数据
  290. if (this.currentTab == 2) {
  291. const hasPrintData = await checkPrintStatus(bookDetailSn).then(res => res.data)
  292. if (!hasPrintData) {
  293. _this.$info({
  294. title: '操作提示',
  295. centered: true,
  296. content: '您所选择的收款单,存在已打印的单子,请重新选择。',
  297. onOk () {
  298. _this.resetSearchForm()
  299. }
  300. })
  301. return
  302. }
  303. }
  304. const retArr = []
  305. for (let i = 0; i < bookSns.length; i++) {
  306. const item = bookSns[i]
  307. // 授信明细,还款明细
  308. const rs = rows.filter(a => a.bookSn == item)
  309. let detailItemUseStr = ''
  310. let detailPayUseStr = ''
  311. rs.map(b => {
  312. if (b.detailItemUseList) {
  313. detailItemUseStr += this.getUseDetailInfo(b.detailItemUseList)
  314. }
  315. if (b.detailItemPayList) {
  316. detailPayUseStr += this.getUseDetailInfo(b.detailItemPayList)
  317. }
  318. })
  319. const auditInfo = await getProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSn': item }).then(res => res.data[0].opinionList || [])
  320. // 审核信息
  321. const auditStr = auditInfo ? this.getAuditInfo(auditInfo) : ''
  322. retArr.push({ audit: auditStr, detail: detailItemUseStr, payDetail: detailPayUseStr, subList: rs })
  323. }
  324. this.handlePrint(retArr, 1, rows, bookSns)
  325. },
  326. // 获取授信西悉尼
  327. getUseDetailInfo (list) {
  328. let ret = ''
  329. list.map((k, i) => {
  330. ret = ret + k.itemName + '(' + k.itemAmount + ')' + (i == list.length - 1 ? ';' : ',')
  331. })
  332. return ret
  333. },
  334. // 获取审核信息
  335. getAuditInfo (auditList) {
  336. let auditStr = ''
  337. if (auditList && auditList.length) {
  338. const auditLists = auditList.filter(item => item.processTaskType == '审批人')
  339. auditLists.map((a, i) => {
  340. auditStr = auditStr + a.approvalName + '(' + a.approvalStateDictValue + ')' + (i == auditLists.length - 1 ? ';' : ',')
  341. })
  342. }
  343. return auditStr
  344. },
  345. // 收款打印
  346. async handlePrint (row, type, list, bookSns) {
  347. const _this = this
  348. let auditInfo = null
  349. if (type == 0) {
  350. // 是否已打印
  351. if (this.currentTab == 2) {
  352. const hasPrintData = await checkPrintStatus(list.bookDetailSn).then(res => res.data)
  353. if (!hasPrintData) {
  354. _this.$info({
  355. title: '操作提示',
  356. centered: true,
  357. content: '您所选择的收款单已打印,请重新选择。',
  358. onOk () {
  359. _this.resetSearchForm()
  360. }
  361. })
  362. return
  363. }
  364. }
  365. auditInfo = await getProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSn': list.bookSn }).then(res => (res.data[0] && res.data[0].opinionList) ? res.data[0].opinionList : [])
  366. }
  367. console.log(auditInfo)
  368. this.spinning = true
  369. this.showTipModal = true
  370. let detailItemUseStr = ''
  371. let detailPayUseStr = ''
  372. this.$nextTick(() => {
  373. // type == 0 单个打印时
  374. if (type == 0 && row.detailItemUseList) {
  375. detailItemUseStr = this.getUseDetailInfo(row.detailItemUseList)
  376. }
  377. if (type == 0 && row.detailItemPayList) {
  378. detailPayUseStr = this.getUseDetailInfo(row.detailItemPayList)
  379. }
  380. // 审核信息
  381. const auditStr = auditInfo ? this.getAuditInfo(auditInfo[list.bookSn]) : ''
  382. this.$refs.printModel.getData(type ? row : [{ audit: auditStr, detail: detailItemUseStr, payDetail: detailPayUseStr, subList: [row] }], type ? list : [list])
  383. })
  384. },
  385. printOk (res) {
  386. if (res) {
  387. this.spinning = false
  388. this.$refs.table.refresh()
  389. this.$refs.table.clearSelected()
  390. }
  391. },
  392. // 时间 change
  393. dateChange (date) {
  394. this.queryParam.beginDate = date[0] ? date[0] : ''
  395. this.queryParam.endDate = date[1] ? date[1] : ''
  396. },
  397. custChange (val) {
  398. console.log(val)
  399. if (val.row) {
  400. this.queryParam.dealerSn = val.row.dealerSn
  401. this.queryParam.payerName = undefined
  402. } else {
  403. this.queryParam.dealerSn = undefined
  404. this.queryParam.payerName = val.key
  405. }
  406. },
  407. handlePrintStatus (row) {
  408. this.tipData = row
  409. this.showPrintModal = true
  410. },
  411. canselModal () {
  412. this.tipData = null
  413. this.showPrintModal = false
  414. },
  415. updatePrintStatus () {
  416. updateFinanceBookDetail({ id: this.tipData.id, printStatus: 'UNABLE_PRINT' }, 1).then(res => {
  417. if (res.status == 200) {
  418. this.canselModal()
  419. this.$message.info(res.message)
  420. this.$refs.table.refresh()
  421. }
  422. })
  423. },
  424. // 关闭打印预览
  425. closeTipModal () {
  426. this.showTipModal = false
  427. this.spinning = false
  428. this.$refs.printModel.clearData()
  429. },
  430. // 打印记录
  431. viewPrint (row) {
  432. this.showRecordModal = true
  433. this.$refs.recordModal.setData(row, {
  434. billType: 'FINANCE_BOOK_DETAIL',
  435. billSn: row.bookDetailSn,
  436. billNo: row.bookNo
  437. })
  438. },
  439. // 重置
  440. resetSearchForm () {
  441. this.time = []
  442. this.$refs.rangeDate.resetDate(this.time)
  443. this.$refs.payerName.resetForm()
  444. this.queryParam = {
  445. beginDate: '',
  446. endDate: '',
  447. bookNo: '',
  448. payerName: '',
  449. dealerSn: undefined,
  450. subareaSn: undefined,
  451. billStatus: undefined,
  452. dealerProvinceSn: undefined,
  453. fullPaymentFlag: undefined,
  454. warehouseSn: undefined,
  455. bizUserSn: undefined,
  456. printStatus: this.currentTab == 2 ? 'NO_PRINT' : undefined
  457. }
  458. this.$refs.table.refresh(true)
  459. this.$refs.table.clearSelected()
  460. },
  461. pageInit () {
  462. const _this = this
  463. this.$nextTick(() => { // 页面渲染完成后的回调
  464. _this.setTableH()
  465. })
  466. },
  467. setTableH () {
  468. const tableSearchH = this.$refs.tableSearch.offsetHeight
  469. this.tableHeight = window.innerHeight - tableSearchH - 295
  470. }
  471. },
  472. watch: {
  473. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  474. this.setTableH()
  475. }
  476. },
  477. mounted () {
  478. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  479. this.pageInit()
  480. this.resetSearchForm()
  481. }
  482. },
  483. activated () {
  484. // 如果是新页签打开,则重置当前页面
  485. if (this.$store.state.app.isNewTab) {
  486. this.pageInit()
  487. this.resetSearchForm()
  488. }
  489. // 仅刷新列表,不重置页面
  490. if (this.$store.state.app.updateList) {
  491. this.pageInit()
  492. this.$refs.table.refresh()
  493. }
  494. },
  495. beforeRouteEnter (to, from, next) {
  496. next(vm => {})
  497. }
  498. }
  499. </script>
  500. <style lang="less">
  501. .receiptPrint-wrap{
  502. .ant-tabs-bar{
  503. margin-bottom: 10px;
  504. }
  505. .receiptPrint-body{
  506. .ant-card-body{
  507. padding-top:0;
  508. }
  509. }
  510. }
  511. </style>