list.vue 18 KB

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