receipt_list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div style="width: 100%; height: 100%">
  3. <template-page
  4. v-if="showDetail == 1"
  5. ref="pageRef"
  6. :operation="operation()"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :getList="getList"
  9. :exportList="exportList"
  10. :tableAttributes="tableAttributes"
  11. :tableEvents="tableEvents"
  12. :columnParsing="columnParsing"
  13. >
  14. </template-page>
  15. <div class="app-container" v-else-if="showDetail == 2">
  16. <ReceiptPrint :listItem="queryItem" @backListFormDetail="backList" />
  17. </div>
  18. <div class="app-container" v-else>
  19. <ReceiptListDetail :detailId="detailId" />
  20. </div>
  21. <print-preview ref="preView" @initPrint="handleInitPrint" @refreshList="handleRefreshList" :addPrint="addPrint"/>
  22. </div>
  23. </template>
  24. <script>
  25. import { disAutoConnect, hiprint } from 'vue-plugin-hiprint'
  26. disAutoConnect()
  27. import printPreview from './components/design/preview.vue'
  28. import { getCompanyList } from '@/api/user'
  29. import { getCustomerList } from '@/api/finance/wallet'
  30. import { k3ReceiptList, k3ReceiptListExport } from '@/api/finance/receipt_list_v2'
  31. import { getK3ReceiptList, getK3ReceiptDetail, getK3ReceiptAbandon } from '@/api/finance/receipt_list'
  32. import ReceiptListDetail from './components/receipt_list-detail'
  33. import ReceiptPrint from '@/views/finance/components/receipt_print.vue'
  34. import importButton from '@/components/Common/import-button.vue'
  35. import { changeNumberMoneyToChinese, dateFormat } from '@/utils/util'
  36. import { numToFixed } from '@/filters'
  37. import TemplatePage from '@/components/template/template-page-1.vue'
  38. export default {
  39. components: {
  40. ReceiptPrint,
  41. printPreview,
  42. importButton,
  43. ReceiptListDetail,
  44. TemplatePage
  45. },
  46. data() {
  47. return {
  48. customerList: [],
  49. currentPage: 1, // 当前页码
  50. pageSize: 10, // 每页数量
  51. listTotal: 0, // 列表总数
  52. dataList: [], // 列表数据
  53. searchForm: {
  54. billType: '',
  55. billNo: '',
  56. wlCompanyType: '',
  57. customerName: '',
  58. settleType: '',
  59. startTime: '',
  60. endTime: '',
  61. websitNumber: ''
  62. }, //搜索表单
  63. listLoading: false, // 列表加载loading
  64. showDetail: 1,
  65. detailId: null,
  66. queryItem: {},
  67. tableSelection: [],
  68. company: '',
  69. panel: '',
  70. isCollapse: true,
  71. hiprintTemplate: '',
  72. orage: [
  73. {
  74. value: 'GZ',
  75. label: '广州'
  76. },
  77. {
  78. value: 'FS',
  79. label: '佛山'
  80. }
  81. ],
  82. // 表格属性
  83. tableAttributes: {
  84. // 启用勾选列
  85. selectColumn: true
  86. },
  87. // 表格事件
  88. tableEvents: {
  89. 'selection-change': this.selectionChange
  90. },
  91. recordSelected: []
  92. }
  93. },
  94. computed: {
  95. optionsEvensGroup() {
  96. return [
  97. [
  98. [
  99. {
  100. name: '打印发货单',
  101. click: () => {
  102. if (!this.tableSelection.length) {
  103. this.$message.info('请选择数据!')
  104. return
  105. }
  106. this.toPrint()
  107. },
  108. isRole: this.$checkBtnRole('print', this.$route.meta.roles)
  109. }
  110. ]
  111. ]
  112. ]
  113. },
  114. exParams() {
  115. return {
  116. ...this.searchForm
  117. }
  118. }
  119. },
  120. created() {
  121. this.getDataList()
  122. this.getCustomerDataList()
  123. this.getCompanyList()
  124. },
  125. mounted() {},
  126. methods: {
  127. // 列表请求函数
  128. getList: k3ReceiptList,
  129. // 列表导出函数
  130. exportList: k3ReceiptListExport,
  131. // 表格列解析渲染数据更改
  132. columnParsing(item, defaultData) {
  133. return defaultData
  134. },
  135. // 监听勾选变化
  136. selectionChange(data) {
  137. this.tableSelection = data
  138. },
  139. operation() {
  140. return (h, { row, index, column }) => {
  141. return (
  142. <div class="operation-btns">
  143. {this.$checkBtnRole('examine', this.$route.meta.roles) && row.status == 'C' ? (
  144. <el-button
  145. type="text"
  146. class="textColor"
  147. onClick={() => {
  148. this.NoExamineFn(row.id)
  149. }}
  150. >
  151. 弃审
  152. </el-button>
  153. ) : null}
  154. <el-button
  155. type="text"
  156. class="textColor"
  157. onClick={() => {
  158. this.seeFn(row.id)
  159. }}
  160. >
  161. 查看
  162. </el-button>
  163. {this.$checkBtnRole('print', this.$route.meta.roles) ? (
  164. <el-button
  165. type="text"
  166. class="textColor"
  167. onClick={() => {
  168. this.toPrint(row, 2)
  169. }}
  170. >
  171. 打印
  172. </el-button>
  173. ) : null}
  174. </div>
  175. )
  176. }
  177. },
  178. // ------------------------------------
  179. //获取经销商列表
  180. async getCustomerDataList() {
  181. let res = await getCustomerList({
  182. pageNum: 1,
  183. pageSize: -1
  184. })
  185. this.customerList = res.data.records
  186. },
  187. //合计
  188. getSummaries(param) {
  189. const { columns, data } = param
  190. const sums = []
  191. columns.forEach((column, index) => {
  192. if (index === 0) {
  193. sums[index] = '合计'
  194. }
  195. if (index === 8) {
  196. let arr = []
  197. data.forEach(v => {
  198. if (v.billType == 2 || v.billType == 3) {
  199. arr.push(-v.amount)
  200. } else {
  201. arr.push(v.amount)
  202. }
  203. })
  204. let a = arr.reduce((prev, curr) => {
  205. const value = Number(curr)
  206. if (!isNaN(value)) {
  207. return prev + curr
  208. } else {
  209. return prev
  210. }
  211. }, 0)
  212. sums[index] = numToFixed(a)
  213. sums[11] = numToFixed(a)
  214. }
  215. })
  216. return sums
  217. },
  218. //弃审
  219. async NoExamineFn(id) {
  220. await getK3ReceiptAbandon({ id })
  221. this.$message.success('弃审成功')
  222. this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage })
  223. },
  224. // 更改每页数量
  225. handleSizeChange(val) {
  226. this.pageSize = val
  227. this.currentPage = 1
  228. this.getDataList()
  229. },
  230. // 更改当前页
  231. handleCurrentChange(val) {
  232. this.currentPage = val
  233. this.getDataList()
  234. },
  235. //清空
  236. cancelFn() {
  237. this.$refs.searchForm.resetFields()
  238. },
  239. //搜索
  240. searchFn() {
  241. this.getDataList()
  242. },
  243. async getDataList() {
  244. let params = {
  245. billType: this.searchForm.billType,
  246. billNo: this.searchForm.billNo,
  247. wlCompanyType: this.searchForm.wlCompanyType,
  248. customerName: this.searchForm.customerName,
  249. settleType: this.searchForm.settleType,
  250. startTime: this.searchForm.startTime,
  251. endTime: this.searchForm.endTime,
  252. websitNumber: this.searchForm.websitNumber,
  253. pageNum: this.currentPage,
  254. pageSize: this.pageSize
  255. }
  256. const res = await getK3ReceiptList(params)
  257. // console.log(res);
  258. // res.data.records.forEach((item) => {
  259. // item.sums1 = [];
  260. // item.sums2 = ["amount"];
  261. // });
  262. this.dataList = res.data.records
  263. this.listTotal = res.data.total
  264. },
  265. seeFn(id) {
  266. this.detailId = id
  267. this.showDetail = 3
  268. },
  269. handleSelect(selection, row) {
  270. this.$refs.table.toggleRowSelection(row)
  271. this.dataList.forEach(item => {
  272. if (item.id === row.id) {
  273. this.$refs.table.toggleRowSelection(item)
  274. }
  275. })
  276. this.tableSelection = this.$refs.table.selection
  277. },
  278. handleSelectAll(selection) {
  279. this.tableSelection = this.$refs.table.selection
  280. },
  281. backList() {
  282. this.queryItem = {}
  283. this.isShowPrint = false
  284. },
  285. // 获取当前时间
  286. nowDate() {
  287. var date = new Date()
  288. var seperator1 = '-'
  289. var year = date.getFullYear()
  290. var month = date.getMonth() + 1
  291. var strDate = date.getDate()
  292. if (month >= 1 && month <= 9) {
  293. month = '0' + month
  294. }
  295. if (strDate >= 0 && strDate <= 9) {
  296. strDate = '0' + strDate
  297. }
  298. var currentdate = year + seperator1 + month + seperator1 + strDate
  299. console.log(currentdate)
  300. return currentdate
  301. },
  302. // 点击打印
  303. async toPrint(row, type) {
  304. // 初始化模板,否则生成的模板叠加
  305. hiprint.init()
  306. this.hiprintTemplate = new hiprint.PrintTemplate()
  307. // 兼容批量打印
  308. let params = !type ? this.tableSelection : [row.id]
  309. let len = params.length
  310. let loadingLen = len
  311. // 使用 i-- 提升for效率
  312. this.$startLoading()
  313. for (let i = len; i > 0; i--) {
  314. try {
  315. const { data } = await getK3ReceiptDetail({
  316. id: params[i - 1].id || params[i - 1]
  317. })
  318. // 模板基础配置
  319. this.panel = this.hiprintTemplate.addPrintPanel({
  320. height: 140,
  321. width: 241,
  322. fontFamily: '黑体',
  323. fontSize: 13,
  324. paperFooter: 340,
  325. paperHeader: 10,
  326. paperNumberDisabled: true
  327. })
  328. // 获取收款单模板和基础配置
  329. this.panel.addPrintHtml({
  330. options: {
  331. width: 633,
  332. top: 30,
  333. left: 20,
  334. fontFamily: '黑体',
  335. fontSize: 13,
  336. content: this.setTableDom(data)
  337. }
  338. })
  339. loadingLen--
  340. } catch (error) {
  341. this.$endLoading()
  342. return
  343. }
  344. }
  345. if (loadingLen === 0) {
  346. this.$endLoading()
  347. }
  348. // 预览打印内容
  349. this.$refs.preView.show(this.hiprintTemplate, this.panel)
  350. },
  351. getCompanyList() {
  352. getCompanyList().then(res => {
  353. this.company = res.data ? res.data[0].companyName : ''
  354. })
  355. },
  356. // 收款单打印模板
  357. setTableDom(data) {
  358. return `
  359. <div style="font-family:'黑体';">
  360. <h1 style="text-align:center">${this.company}收款单</h1>
  361. <div >
  362. <table border=".5" cellspacing="0" width="856" height="250"
  363. style="border-color: rgb(0,0,0);
  364. border-collapse: collapse;
  365. border-style: none;
  366. border: 1px solid rgb(0,0,0);
  367. font-weight: normal;
  368. direction: ltr;
  369. padding-bottom: 0pt;
  370. padding-left: 4pt;
  371. padding-right: 4pt;
  372. padding-top: 0pt;
  373. text-decoration: none;
  374. vertical-align: middle;
  375. box-sizing: border-box;
  376. word-wrap: break-word;
  377. word-break: break-all;">
  378. <tr>
  379. <td>单据编号</td>
  380. <td>${data.billNo}</td>
  381. <td>业务日期</td>
  382. <td>${data.theTime}</td>
  383. <td>打印日期</td>
  384. <td>${this.nowDate()}</td>
  385. </tr>
  386. <tr>
  387. <td>付款单位</td>
  388. <td colspan="5">${data.customerName}</td>
  389. </tr>
  390. <tr>
  391. <td>钱包</td>
  392. <td>${data.walletName}</td>
  393. <td>实收金额</td>
  394. <td style="text-align:right">${numToFixed(data.amount)}</td>
  395. <td colspan="2">${changeNumberMoneyToChinese(data.amount)}</td>
  396. </tr>
  397. <tr>
  398. <td>备注</td>
  399. <td colspan="5">${data.remark}</td>
  400. </tr>
  401. </table>
  402. </div>
  403. <div style="margin:100px 0 0 0">
  404. <div>打印</div>
  405. </div>
  406. </div>
  407. `
  408. },
  409. handleRefreshList(){
  410. this.recordSelected = []
  411. this.$refs.pageRef.refreshList()
  412. },
  413. handleInitPrint(){
  414. this.$nextTick(() => {
  415. this.initPrint()
  416. })
  417. }
  418. }
  419. }
  420. </script>
  421. <style lang="scss" scoped>
  422. .selectStyle {
  423. width: 100%;
  424. }
  425. .improt {
  426. display: flex;
  427. }
  428. </style>