list.vue 19 KB

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