list.vue 19 KB

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