receivable_list.vue 14 KB

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