list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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. columns () {
  208. const arr = [
  209. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  210. { title: '允许打印时间', dataIndex: 'allowPrintTime', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  211. { title: '收款单号', dataIndex: 'bookNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '收款日期', dataIndex: 'receiptDate', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '客户名称', dataIndex: 'payerName', align: 'left', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. // { title: '仓库', dataIndex: 'warehouseName', align: 'left', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  215. { title: '财务编码', dataIndex: 'dealerEntity.kdMidCustomerFnumber', align: 'left', width: '10%', customRender: function (text) { return text || '--' }, ellipsis: true },
  216. { title: '订单金额', dataIndex: 'orderAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  217. { title: '收款金额', dataIndex: 'receiptAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  218. { title: '使用授信', dataIndex: 'useCreditAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  219. { title: '余款抵扣', dataIndex: 'balanceAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  220. { title: '户名', dataIndex: 'bankAccount', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '汇入银行', dataIndex: 'bankName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '足额打款', dataIndex: 'fullPaymentFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '说明', dataIndex: 'explainInfo', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  224. { title: '收款打印状态', dataIndex: 'printStatusDictValue', width: '6%', align: 'center', scopedSlots: { customRender: 'printStatus' } },
  225. { title: '打印次数', dataIndex: 'printNum', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  227. ]
  228. if (this.isShowWarehouse) {
  229. arr.splice(5, 0, { title: '仓库', dataIndex: 'warehouseName', align: 'center', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true })
  230. }
  231. return arr
  232. }
  233. },
  234. methods: {
  235. changeTab (v) {
  236. this.currentTab = v
  237. this.pageInit()
  238. this.resetSearchForm()
  239. },
  240. // 表格选中项
  241. rowSelectionFun (obj) {
  242. this.rowSelectionInfo = obj || null
  243. },
  244. // 批量打印
  245. async handlePlPrint () {
  246. const _this = this
  247. const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
  248. const slen = rows.length
  249. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  250. _this.$message.warning('请在列表勾选后再进行批量操作!')
  251. return false
  252. }
  253. this.spinning = true
  254. const bookSns = []
  255. const bookDetailSn = []
  256. rows.map(item => {
  257. if (bookSns.indexOf(item.bookSn) < 0) {
  258. bookSns.push(item.bookSn)
  259. }
  260. bookDetailSn.push(item.bookDetailSn)
  261. })
  262. // 检查是否有已打印数据
  263. if (this.currentTab == 2) {
  264. const hasPrintData = await checkPrintStatus(bookDetailSn).then(res => res.data)
  265. if (!hasPrintData) {
  266. _this.$info({
  267. title: '操作提示',
  268. centered: true,
  269. content: '您所选择的收款单,存在已打印的单子,请重新选择。',
  270. onOk () {
  271. _this.resetSearchForm()
  272. }
  273. })
  274. return
  275. }
  276. }
  277. const retArr = []
  278. const auditInfo = await getBatchLastProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSnList': bookSns }).then(res => res.data)
  279. console.log(auditInfo)
  280. bookSns.map(item => {
  281. // 授信明细
  282. const rs = rows.filter(a => a.bookSn == item)
  283. let detailItemUseStr = ''
  284. rs.map(b => {
  285. if (b.detailItemUseList) {
  286. b.detailItemUseList.map((k, i) => {
  287. detailItemUseStr = detailItemUseStr + k.itemName + '(' + k.itemAmount + ')' + (i == b.detailItemUseList.length - 1 ? '。' : ';')
  288. })
  289. }
  290. })
  291. // 审核信息
  292. const auditStr = auditInfo ? this.getAuditInfo(auditInfo[item]) : ''
  293. retArr.push({ audit: auditStr, detail: detailItemUseStr, subList: rs })
  294. })
  295. console.log(retArr, '------------')
  296. this.handlePrint(retArr, 1, rows, bookSns)
  297. },
  298. // 获取审核信息
  299. getAuditInfo (auditList) {
  300. let auditStr = ''
  301. if (auditList && auditList.taskVOList) {
  302. const auditLists = auditList.taskVOList.filter(item => item.userType == '审批人')
  303. auditLists.map((a, i) => {
  304. auditStr = auditStr + a.userName + '(' + a.state + ')' + (i == auditLists.length - 1 ? '。' : ';')
  305. })
  306. }
  307. return auditStr
  308. },
  309. // 收款打印
  310. async handlePrint (row, type, list, bookSns) {
  311. const _this = this
  312. let auditInfo = null
  313. if (type == 0) {
  314. // 是否已打印
  315. if (this.currentTab == 2) {
  316. const hasPrintData = await checkPrintStatus([list.bookDetailSn]).then(res => res.data)
  317. if (!hasPrintData) {
  318. _this.$info({
  319. title: '操作提示',
  320. centered: true,
  321. content: '您所选择的收款单已打印,请重新选择。',
  322. onOk () {
  323. _this.resetSearchForm()
  324. }
  325. })
  326. return
  327. }
  328. }
  329. auditInfo = await getBatchLastProcessInstance({ 'businessType': 'FINANCE_BOOK', 'businessSnList': [list.bookSn] }).then(res => res.data)
  330. }
  331. console.log(auditInfo)
  332. this.spinning = true
  333. this.showTipModal = true
  334. let detailItemUseStr = ''
  335. this.$nextTick(() => {
  336. if (type == 0 && row.detailItemUseList) {
  337. row.detailItemUseList.map(k => {
  338. detailItemUseStr = detailItemUseStr + k.itemName + '(' + k.itemAmount + ');'
  339. })
  340. }
  341. // 审核信息
  342. const auditStr = auditInfo ? this.getAuditInfo(auditInfo[list.bookSn]) : ''
  343. this.$refs.printModel.getData(type ? row : [{ audit: auditStr, detail: detailItemUseStr, subList: [row] }], type ? list : [list])
  344. })
  345. },
  346. printOk (res) {
  347. if (res) {
  348. this.spinning = false
  349. this.$refs.table.refresh()
  350. this.$refs.table.clearSelected()
  351. }
  352. },
  353. // 时间 change
  354. dateChange (date) {
  355. this.queryParam.beginDate = date[0] ? date[0] : ''
  356. this.queryParam.endDate = date[1] ? date[1] : ''
  357. },
  358. custChange (val) {
  359. console.log(val)
  360. if (val.row) {
  361. this.queryParam.dealerSn = val.row.dealerSn
  362. this.queryParam.payerName = undefined
  363. } else {
  364. this.queryParam.dealerSn = undefined
  365. this.queryParam.payerName = val.key
  366. }
  367. },
  368. handlePrintStatus (row) {
  369. this.tipData = row
  370. this.showPrintModal = true
  371. },
  372. canselModal () {
  373. this.tipData = null
  374. this.showPrintModal = false
  375. },
  376. updatePrintStatus () {
  377. updateFinanceBookDetail({ id: this.tipData.id, printStatus: 'UNABLE_PRINT' }).then(res => {
  378. if (res.status == 200) {
  379. this.canselModal()
  380. this.$message.info(res.message)
  381. this.$refs.table.refresh()
  382. }
  383. })
  384. },
  385. // 关闭打印预览
  386. closeTipModal () {
  387. this.showTipModal = false
  388. this.spinning = false
  389. this.$refs.printModel.clearData()
  390. },
  391. // 打印记录
  392. viewPrint (row) {
  393. this.showRecordModal = true
  394. this.$refs.recordModal.setData(row, {
  395. billType: 'FINANCE_BOOK_DETAIL',
  396. billSn: row.bookDetailSn,
  397. billNo: row.bookNo
  398. })
  399. },
  400. // 重置
  401. resetSearchForm () {
  402. this.time = []
  403. this.$refs.rangeDate.resetDate(this.time)
  404. this.$refs.payerName.resetForm()
  405. this.queryParam = {
  406. beginDate: '',
  407. endDate: '',
  408. bookNo: '',
  409. payerName: '',
  410. dealerSn: undefined,
  411. subareaSn: undefined,
  412. billStatus: undefined,
  413. dealerProvinceSn: undefined,
  414. fullPaymentFlag: undefined,
  415. warehouseSn: undefined,
  416. printStatus: this.currentTab == 2 ? 'NO_PRINT' : undefined
  417. }
  418. this.$refs.table.refresh(true)
  419. this.$refs.table.clearSelected()
  420. },
  421. pageInit () {
  422. const _this = this
  423. this.$nextTick(() => { // 页面渲染完成后的回调
  424. _this.setTableH()
  425. })
  426. },
  427. setTableH () {
  428. const tableSearchH = this.$refs.tableSearch.offsetHeight
  429. this.tableHeight = window.innerHeight - tableSearchH - 250
  430. }
  431. },
  432. watch: {
  433. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  434. this.setTableH()
  435. }
  436. },
  437. mounted () {
  438. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  439. this.pageInit()
  440. this.resetSearchForm()
  441. }
  442. },
  443. activated () {
  444. // 如果是新页签打开,则重置当前页面
  445. if (this.$store.state.app.isNewTab) {
  446. this.pageInit()
  447. this.resetSearchForm()
  448. }
  449. // 仅刷新列表,不重置页面
  450. if (this.$store.state.app.updateList) {
  451. this.pageInit()
  452. this.$refs.table.refresh()
  453. }
  454. },
  455. beforeRouteEnter (to, from, next) {
  456. next(vm => {})
  457. }
  458. }
  459. </script>
  460. <style lang="less">
  461. .receiptPrint-wrap{
  462. .sTable{
  463. margin-top: 10px;
  464. }
  465. .ant-tabs-bar{
  466. margin:0;
  467. }
  468. }
  469. </style>