list.vue 20 KB

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