receivable_list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :operation="operation()"
  7. :operationColumnWidth="200"
  8. :optionsEvensGroup="optionsEvensGroup"
  9. :columnParsing="columnParsing"
  10. :tableAttributes="tableAttributes"
  11. :tableEvents="tableEvents"
  12. :replaceOrNotMap="false"
  13. >
  14. <Popu v-if="showPage !== 1">
  15. <ReceivableListAdd v-if="showPage == 2" @close="handleClose" />
  16. <ReceivableListApproval :approvalId="approvalId" v-if="showPage == 3" @close="handleClose" />
  17. <ReceivableListDetail :approvalId="approvalId" :czType="czType" v-if="showPage == 4" @close="handleClose" />
  18. </Popu>
  19. <print-preview ref="preView" @initPrint="handleInitPrint" @refreshList="handleRefreshList" />
  20. </template-page>
  21. </template>
  22. <script>
  23. import TemplatePage from '@/components/template/template-page-1.vue'
  24. import import_mixin from '@/components/template/import_mixin.js'
  25. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  26. import Popu from '@/components/template/popu.vue'
  27. import { getCustomerList } from '@/api/finance/wallet'
  28. import {
  29. getFinanceOtherReceList,
  30. getFinanceOtherReceListV2,
  31. exportFinanceOtherReceListV2,
  32. getFinanceOtherReceDelete,
  33. getFinanceOtherReceDetail,
  34. getFinanceOtherReceApply,
  35. getFinanceOtherReceAbandon,
  36. financeOtherReceClose
  37. } from '@/api/finance/receivable_list'
  38. import ReceivableListAdd from './components/receivable_list-add'
  39. import ReceivableListApproval from './components/receivable_list-approval'
  40. import ReceivableListDetail from './components/receivable_list-detail'
  41. import { disAutoConnect, hiprint } from 'vue-plugin-hiprint'
  42. disAutoConnect()
  43. import printPreview from './components/design/preview.vue'
  44. import { getCompanyList } from '@/api/user'
  45. import { numToFixed } from '@/filters'
  46. import { changeNumberMoneyToChinese } from '@/utils/util'
  47. export default {
  48. components: { TemplatePage, Popu, ReceivableListAdd, ReceivableListApproval, ReceivableListDetail, printPreview },
  49. mixins: [import_mixin, add_callback_mixin],
  50. data() {
  51. return {
  52. visible: false,
  53. // 事件组合
  54. optionsEvensGroup: [
  55. [
  56. [
  57. {
  58. name: '打印发货单',
  59. click: () => {
  60. if (!this.recordSelected.length) {
  61. this.$message.info('请选择数据!')
  62. return
  63. }
  64. this.toPrint()
  65. },
  66. isRole: this.$checkBtnRole('print', this.$route.meta.roles)
  67. }
  68. ]
  69. ],
  70. [
  71. [
  72. {
  73. name: '新增',
  74. click: this.addOn(() => {
  75. this.addFn()
  76. }),
  77. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  78. }
  79. ]
  80. ],
  81. [
  82. [
  83. {
  84. name: '批量删除',
  85. click: async () => {
  86. if (this.recordSelected.length === 0) {
  87. this.$message.error('请选择需要删除的数据')
  88. return
  89. }
  90. let ids = this.recordSelected.map(v => {
  91. return v.itemId
  92. })
  93. let params = { ids: ids.toString() }
  94. await getFinanceOtherReceDelete(params)
  95. this.$refs.pageRef.refreshList()
  96. this.$message.success('批量删除成功')
  97. },
  98. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  99. }
  100. ]
  101. ]
  102. ],
  103. // 表格属性
  104. tableAttributes: {
  105. // 启用勾选列
  106. selectColumn: true
  107. }, // 关闭新增弹窗
  108. // 表格事件
  109. tableEvents: {
  110. 'selection-change': this.selectionChange
  111. },
  112. recordSelected: [],
  113. customerList: [],
  114. currentPage: 1, // 当前页码
  115. pageSize: 10, // 每页数量
  116. listTotal: 0, // 列表总数
  117. dataList: [], // 列表数据
  118. searchForm: {
  119. source: '',
  120. code: '',
  121. userName: '',
  122. startTime: '',
  123. endTime: '',
  124. examineBy: ''
  125. }, //搜索表单
  126. listLoading: false, // 列表加载loading
  127. examine: '',
  128. showPage: 1,
  129. approvalId: null,
  130. czType: '',
  131. isCollapse: true,
  132. deleList: [],
  133. hiprintTemplate: '',
  134. company: '',
  135. tableSelection: []
  136. }
  137. },
  138. methods: {
  139. // 列表请求函数
  140. getList(...p) {
  141. this.recordSelected = []
  142. return getFinanceOtherReceListV2(...p)
  143. },
  144. // 列表导出函数
  145. exportList: exportFinanceOtherReceListV2,
  146. // 表格列解析渲染数据更改
  147. columnParsing(item, defaultData) {
  148. return defaultData
  149. },
  150. // 监听勾选变化
  151. selectionChange(data) {
  152. this.recordSelected = data
  153. },
  154. operation() {
  155. return (h, { row, index, column }) => {
  156. return (
  157. <div class="operation-btns">
  158. {this.$checkBtnRole('print', this.$route.meta.roles) ? (
  159. <el-button type="text" size="mini" class="textColor" onClick={() => this.toPrint(row, 2)}>
  160. 打印
  161. </el-button>
  162. ) : null}
  163. {(row.examineStatus == 'WAIT' || row.examineStatus == 'FAIL') &&
  164. this.$checkBtnRole('examine', this.$route.meta.roles) ? (
  165. <el-button type="text" size="mini" onClick={() => this.approvalFn(row.id)}>
  166. 审批
  167. </el-button>
  168. ) : null}
  169. {row.examineStatus == 'SAVE' ? (
  170. <el-button type="text" size="mini" onClick={() => this.bringFn(row.id)}>
  171. 提审
  172. </el-button>
  173. ) : null}
  174. {row.examineStatus == 'OK' || row.examineStatus == 'FAIL' ? (
  175. <el-button type="text" size="mini" onClick={() => this.unApprovalFn(row.id)}>
  176. 弃审
  177. </el-button>
  178. ) : null}
  179. {row.examineStatus == 'SAVE' ? (
  180. <el-button type="text" size="mini" onClick={() => this.detailFn(row.id, 'edit')}>
  181. 编辑
  182. </el-button>
  183. ) : null}
  184. {row.examineStatus !== 'CLOSE' ? (
  185. <el-popconfirm title="关闭吗?" onConfirm={() => {
  186. financeOtherReceClose({
  187. id: row.id
  188. }).then(_res=>{
  189. this.$message.success('关闭成功')
  190. this.$refs.pageRef.refreshList()
  191. })
  192. }}>
  193. <el-button slot="reference" type="text" size="mini">
  194. 关闭
  195. </el-button>
  196. </el-popconfirm>
  197. ) : null}
  198. {
  199. <el-button type="text" size="mini" onClick={() => this.detailFn(row.id, 'detail')}>
  200. 详情
  201. </el-button>
  202. }
  203. </div>
  204. )
  205. }
  206. },
  207. handleClose() {
  208. this.addOff(() => {
  209. this.showPage = 1
  210. })()
  211. this.$refs.pageRef.refreshList()
  212. },
  213. //获取经销商列表
  214. async getCustomerDataList() {
  215. let res = await getCustomerList({
  216. pageNum: 1,
  217. pageSize: -1
  218. })
  219. this.customerList = res.data.records
  220. },
  221. //提审
  222. async bringFn(id) {
  223. await getFinanceOtherReceApply({ id })
  224. this.$message.success('提审成功')
  225. this.$refs.pageRef.refreshList()
  226. // this.getDataList({
  227. // pageNum: this.currentPage,
  228. // pageSize: this.pageSize,
  229. // examineStatus: this.examine
  230. // })
  231. },
  232. //弃审
  233. async unApprovalFn(id) {
  234. await getFinanceOtherReceAbandon({ id })
  235. this.$message.success('弃审成功')
  236. this.$refs.pageRef.refreshList()
  237. // this.getDataList({
  238. // pageNum: this.currentPage,
  239. // pageSize: this.pageSize,
  240. // examineStatus: this.examine
  241. // })
  242. },
  243. handleSelectAll(selection) {
  244. this.tableSelection = this.$refs.table.selection
  245. },
  246. //radio切换'
  247. changeRadioGroupFn(v) {
  248. this.getDataList({
  249. pageSize: this.pageSize,
  250. pageNum: this.currentPage,
  251. examineStatus: v
  252. })
  253. },
  254. // 更改每页数量
  255. handleSizeChange(val) {
  256. this.pageSize = val
  257. this.currentPage = 1
  258. this.getDataList({
  259. pageNum: 1,
  260. pageSize: this.pageSize,
  261. examineStatus: this.examine
  262. })
  263. },
  264. // 更改当前页
  265. handleCurrentChange(val) {
  266. this.currentPage = val
  267. this.getDataList({
  268. pageNum: val,
  269. pageSize: 10,
  270. examineStatus: this.examine
  271. })
  272. },
  273. //清除
  274. async clearFn() {
  275. await this.$refs.searchForm.resetFields()
  276. this.examine = ''
  277. },
  278. //搜索
  279. searchFn() {
  280. this.getDataList({
  281. ...this.searchForm,
  282. // examineStatus: this.examine,
  283. pageSize: this.pageSize,
  284. pageNum: this.currentPage
  285. })
  286. },
  287. //删除
  288. async deleFn() {
  289. let res = this.deleList.toString()
  290. console.log(res)
  291. await getFinanceOtherReceDelete({ ids: res })
  292. this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage })
  293. this.$message.success('删除成功')
  294. this.deleList = []
  295. },
  296. selectionChangeFn(value) {
  297. // console.log(value);
  298. const res = value.map(v => v.itemId)
  299. // console.log(res);
  300. this.deleList = res
  301. },
  302. //新建后更新列表
  303. updateList() {
  304. this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage })
  305. },
  306. //获取来列表数据
  307. async getDataList(data) {
  308. let res = await getFinanceOtherReceList(data)
  309. // console.log(res);
  310. res.data.records.forEach(item => {
  311. item.sums2 = ['itemAmount']
  312. item.sums1 = ['itemAmount']
  313. })
  314. this.dataList = res.data.records
  315. this.listTotal = res.data.total
  316. },
  317. //详情
  318. detailFn(id, type) {
  319. this.czType = type
  320. this.approvalId = id
  321. this.showPage = 4
  322. },
  323. //审批
  324. approvalFn(id) {
  325. this.approvalId = id
  326. this.showPage = 3
  327. },
  328. //新建
  329. addFn() {
  330. this.showPage = 2
  331. },
  332. // 点击打印
  333. async toPrint(row, type) {
  334. // 初始化模板,否则生成的模板叠加
  335. hiprint.init()
  336. this.hiprintTemplate = new hiprint.PrintTemplate()
  337. // 兼容批量打印
  338. let params = !type ? this.recordSelected : [row.id]
  339. let len = params.length
  340. let loadingLen = len
  341. // 使用 i-- 提升for效率
  342. this.$startLoading()
  343. for (let i = len; i > 0; i--) {
  344. try {
  345. const { data } = await getFinanceOtherReceDetail({
  346. id: params[i - 1].id || params[i - 1]
  347. })
  348. // 模板基础配置
  349. this.panel = this.hiprintTemplate.addPrintPanel({
  350. height: 140,
  351. width: 241,
  352. fontFamily: '黑体',
  353. fontSize: 13,
  354. paperFooter: 340,
  355. paperHeader: 10,
  356. paperNumberDisabled: true
  357. })
  358. // 获取收款单模板和基础配置
  359. this.panel.addPrintHtml({
  360. options: {
  361. width: 633,
  362. top: 30,
  363. left: 20,
  364. fontFamily: '黑体',
  365. fontSize: 13,
  366. content: this.setTableDom(data)
  367. }
  368. })
  369. loadingLen--
  370. } catch (error) {
  371. console.log(999)
  372. this.$endLoading()
  373. return
  374. }
  375. }
  376. if (loadingLen === 0) {
  377. this.$endLoading()
  378. }
  379. console.log(333)
  380. // 预览打印内容
  381. this.$refs.preView.show(this.hiprintTemplate, this.panel)
  382. },
  383. getCompanyList() {
  384. getCompanyList().then(res => {
  385. this.company = res.data ? res.data[0].companyName : ''
  386. })
  387. },
  388. // 收款单打印模板
  389. setTableDom(data) {
  390. console.log(this.company, this.nowDate())
  391. return `
  392. <div style="font-family:'黑体';">
  393. <h1 style="text-align:center">${this.company}其他应收单</h1>
  394. <div >
  395. <table border=".5" cellspacing="0" width="856" height="250"
  396. style="border-color: rgb(0,0,0);
  397. border-collapse: collapse;
  398. border-style: none;
  399. border: 1px solid rgb(0,0,0);
  400. font-weight: normal;
  401. direction: ltr;
  402. padding-bottom: 0pt;
  403. padding-left: 4pt;
  404. padding-right: 4pt;
  405. padding-top: 0pt;
  406. text-decoration: none;
  407. vertical-align: middle;
  408. box-sizing: border-box;
  409. word-wrap: break-word;
  410. word-break: break-all;">
  411. <tr>
  412. <td>单据编号</td>
  413. <td>${data.code}</td>
  414. <td>业务日期</td>
  415. <td>${data.createTime}</td>
  416. <td>打印日期</td>
  417. <td>${this.nowDate()}</td>
  418. </tr>
  419. <tr>
  420. <td>付款单位</td>
  421. <td colspan="5">${data.items[0].customerName}</td>
  422. </tr>
  423. <tr>
  424. <td>钱包</td>
  425. <td>${data.items[0].customerWalletName}</td>
  426. <td>实收金额</td>
  427. <td style="text-align:right">${numToFixed(data.totalAmount)}</td>
  428. <td colspan="2">${changeNumberMoneyToChinese(data.totalAmount)}</td>
  429. </tr>
  430. <tr>
  431. <td>备注</td>
  432. <td colspan="5">${data.remark}</td>
  433. </tr>
  434. </table>
  435. </div>
  436. <div style="margin:100px 0 0 0">
  437. <div></div>
  438. </div>
  439. </div>
  440. `
  441. },
  442. // 获取当前时间
  443. nowDate() {
  444. var date = new Date()
  445. var seperator1 = '-'
  446. var year = date.getFullYear()
  447. var month = date.getMonth() + 1
  448. var strDate = date.getDate()
  449. if (month >= 1 && month <= 9) {
  450. month = '0' + month
  451. }
  452. if (strDate >= 0 && strDate <= 9) {
  453. strDate = '0' + strDate
  454. }
  455. var currentdate = year + seperator1 + month + seperator1 + strDate
  456. console.log(currentdate)
  457. return currentdate
  458. },
  459. handleRefreshList() {
  460. this.recordSelected = []
  461. this.$refs.pageRef.refreshList()
  462. },
  463. handleInitPrint() {
  464. this.$nextTick(() => {
  465. this.initPrint()
  466. })
  467. }
  468. }
  469. }
  470. </script>
  471. <style lang="scss" scoped>
  472. .selectStyle {
  473. width: 100%;
  474. }
  475. .dateStyle {
  476. width: 100%;
  477. }
  478. .delClass {
  479. margin-left: 10px;
  480. }
  481. </style>