index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <custom-loading ref="customLloading">
  5. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  6. :permission="permissionList" :before-open="beforeOpen" v-model="form" id="out-table"
  7. :header-cell-class-name="headerClassName" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
  8. @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  9. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  10. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 321)"
  11. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 321)" @on-load="onLoad">
  12. <template slot="menuLeft">
  13. <div style="margin-top: 0px; width: 260px">
  14. <el-tabs type="card" v-model="query.voucherStatus" @tab-click="handleClick">
  15. <el-tab-pane label="新建凭证" name="0"></el-tab-pane>
  16. <el-tab-pane label="已记账凭证" name="1"></el-tab-pane>
  17. </el-tabs>
  18. </div>
  19. </template>
  20. <template slot="menuRight">
  21. <el-button type="primary" size="small" icon="el-icon-plus" @click="addbtnfun()">新建财务凭证
  22. </el-button>
  23. <el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除
  24. </el-button>
  25. <el-button type="success" size="small" plain @click.stop="voucherAccountingfun">凭证记账
  26. </el-button>
  27. <el-button type="danger" size="small" style="margin-right: 40px" plain @click="revokeFinVouchersfun">撤销记账
  28. </el-button>
  29. </template>
  30. <template slot="menu" slot-scope="{row}">
  31. <el-button type="text" size="small" @click="editFun(row)" :disabled="row.voucherStatus == 1">编辑
  32. </el-button>
  33. <el-button type="text" size="small" @click="rowDel(row)" :disabled="row.voucherStatus == 1">删除
  34. </el-button>
  35. </template>
  36. <template slot="billNo" slot-scope="{row}">
  37. <span class="textHide" style="color: #1e9fff;cursor: pointer;" @click="editFun(row)">{{ row.billNo }}</span>
  38. </template>
  39. </avue-crud>
  40. </custom-loading>
  41. </basic-container>
  42. <finvouchersitems ref="finvouchersitemsRef" :key="datekey" v-if="!isShow" @goBack="goBack" @toAddEdit="toAddEdit">
  43. </finvouchersitems>
  44. </div>
  45. </template>
  46. <script>
  47. import {
  48. finvouchersList,
  49. finvouchersDetail,
  50. finvouchersSubmit,
  51. finvouchersRemove,
  52. confirmFinVouchers, revokeFinVouchers
  53. } from "@/api/iosBasicData/finvouchers";
  54. import { mapGetters } from "vuex";
  55. import finvouchersitems from "@/views/iosBasicData/finvouchers/finvouchersitems.vue";
  56. import finstlbillsDetails from "@/views/iosBasicData/finstlbills/finstlbillsDetails.vue";
  57. import { getWorkDicts } from "@/api/system/dictbiz";
  58. import CustomLoading from '@/views/iosBasicData/finvouchers/components/loading.vue'
  59. import { bbusinesstypeList } from "@/api/iosBasicData/bbusinesstype";
  60. export default {
  61. data() {
  62. return {
  63. datekey: Date.now(),
  64. isShow: true, // 详情弹窗
  65. form: {},
  66. query: {
  67. voucherStatus: "0",
  68. },
  69. loading: true,
  70. page: {
  71. pageSize: 10,
  72. currentPage: 1,
  73. total: 0
  74. },
  75. voucherTypeData: [],
  76. selectionList: [],
  77. option: {},
  78. optionBack: {
  79. height: 'auto',
  80. calcHeight: 30,
  81. tip: false,
  82. searchShow: true,
  83. searchMenuSpan: 6,
  84. searchSpan: 6,
  85. border: true,
  86. index: true,
  87. viewBtn: true,
  88. selection: true,
  89. dialogClickModal: false,
  90. menuWidth: '100',
  91. searchIcon: true,
  92. searchIndex: 4,
  93. column: [
  94. {
  95. label: "单据编号",
  96. prop: "billNo",
  97. search: true,
  98. searchOrder: 5,
  99. overHidden: true,
  100. width: 120,
  101. },
  102. {
  103. label: "类型",
  104. prop: "voucherType",
  105. overHidden: true,
  106. width: 80,
  107. type: "select",
  108. props: {
  109. label: "dictValue",
  110. value: "dictKey",
  111. },
  112. dicData: [],
  113. search: true,
  114. searchOrder: 1,
  115. sortable: true
  116. },
  117. {
  118. label: "凭证号",
  119. prop: "voucherNo",
  120. search: true,
  121. searchOrder: 2,
  122. overHidden: true,
  123. width: 100,
  124. sortable: true
  125. },
  126. {
  127. label: "凭证日期",
  128. prop: "voucherDate",
  129. overHidden: true,
  130. width: 100,
  131. },
  132. {
  133. label: "凭证开始日期",
  134. prop: "voucherDateStart",
  135. search: true,
  136. searchOrder: 3,
  137. overHidden: true,
  138. searchLabelWidth: "100",
  139. hide: true,
  140. type: "date",
  141. format: "yyyy-MM-dd",
  142. valueFormat: "yyyy-MM-dd HH:mm:ss",
  143. width: 100,
  144. },
  145. {
  146. label: "凭证结束日期",
  147. prop: "voucherDateEnd",
  148. search: true,
  149. searchOrder: 4,
  150. overHidden: true,
  151. searchLabelWidth: "100",
  152. hide: true,
  153. type: "date",
  154. format: "yyyy-MM-dd",
  155. valueFormat: "yyyy-MM-dd HH:mm:ss",
  156. width: 100,
  157. },
  158. /*
  159. {
  160. label: "年",
  161. prop: "accountYear",
  162. overHidden: true,
  163. width: 40,
  164. },
  165. {
  166. label: "月",
  167. prop: "accountMonth",
  168. overHidden: true,
  169. width: 40,
  170. },
  171. */
  172. {
  173. label: "摘要",
  174. prop: "descr",
  175. overHidden: true,
  176. width: 200,
  177. search: true,
  178. searchOrder: 6,
  179. },
  180. {
  181. label: "借方金额(CNY)",
  182. prop: "amountDr",
  183. overHidden: true,
  184. width: 120,
  185. },
  186. {
  187. label: "贷方金额(CNY)",
  188. prop: "amountCr",
  189. overHidden: true,
  190. width: 120,
  191. },
  192. {
  193. label: "CNY金额",
  194. prop: "amountDr",
  195. overHidden: true,
  196. width: 120,
  197. hide: true,
  198. search: true,
  199. searchOrder: 7,
  200. },
  201. {
  202. label: "借方金额(USD)",
  203. prop: "amountDrUsd",
  204. overHidden: true,
  205. width: 120,
  206. },
  207. {
  208. label: "贷方金额(USD)",
  209. prop: "amountCrUsd",
  210. overHidden: true,
  211. width: 120,
  212. },
  213. {
  214. label: "USD金额",
  215. prop: "amountDrUsd",
  216. overHidden: true,
  217. width: 120,
  218. hide: true,
  219. search: true,
  220. searchOrder: 8,
  221. },
  222. {
  223. label: "外币",
  224. prop: "isForeign",
  225. search: true,
  226. searchOrder: 9,
  227. type: 'select',
  228. dicData: [],
  229. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  230. props: {
  231. label: "dictValue",
  232. value: "dictKey"
  233. },
  234. overHidden: true,
  235. width: 60,
  236. },
  237. /*
  238. {
  239. label: "数量",
  240. prop: "isQuantity",
  241. search: true,
  242. type: 'select',
  243. dicData: [],
  244. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  245. props: {
  246. label: "dictValue",
  247. value: "dictKey"
  248. },
  249. overHidden: true,
  250. width: 60,
  251. },
  252. */
  253. {
  254. label: "凭证来源",
  255. prop: "voucherSource",
  256. search: true,
  257. searchOrder: 10,
  258. type: 'select',
  259. dicData: [],
  260. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=voucher_source_los",
  261. props: {
  262. label: "cnName",
  263. value: "code"
  264. },
  265. overHidden: true,
  266. width: 100,
  267. },
  268. {
  269. label: "来源单号",
  270. prop: "srcBlllNo",
  271. overHidden: true,
  272. width: 140,
  273. search: true,
  274. searchOrder: 12,
  275. },
  276. {
  277. label: "制单人",
  278. prop: "createUserName",
  279. overHidden: true,
  280. width: 80,
  281. },
  282. {
  283. label: "制单时间",
  284. prop: "createTime",
  285. overHidden: true,
  286. width: 100,
  287. },
  288. {
  289. label: "复核人",
  290. prop: "checkUserName",
  291. overHidden: true,
  292. width: 80,
  293. },
  294. {
  295. label: "复核时间",
  296. prop: "checkTime",
  297. overHidden: true,
  298. width: 100,
  299. },
  300. {
  301. label: "记账人",
  302. prop: "postUserName",
  303. overHidden: true,
  304. width: 80,
  305. },
  306. {
  307. label: "记账时间",
  308. prop: "postTime",
  309. overHidden: true,
  310. width: 100,
  311. },
  312. {
  313. label: "状态",
  314. prop: "voucherStatus",
  315. type: 'select',
  316. dicData: [],
  317. dicUrl: "/api/blade-system/dict-biz/dictionary?code=voucher_status_los",
  318. props: {
  319. label: "dictValue",
  320. value: "dictKey"
  321. },
  322. overHidden: true,
  323. width: 60,
  324. },
  325. {
  326. label: "备注",
  327. prop: "remarks",
  328. overHidden: true,
  329. width: 180,
  330. },
  331. ]
  332. },
  333. data: []
  334. };
  335. },
  336. components: { finstlbillsDetails, finvouchersitems, CustomLoading },
  337. computed: {
  338. ...mapGetters(["permission"]),
  339. permissionList() {
  340. return {
  341. addBtn: this.vaildData(this.permission.finvouchers_add, false),
  342. viewBtn: this.vaildData(this.permission.finvouchers_view, false),
  343. delBtn: this.vaildData(this.permission.finvouchers_delete, false),
  344. editBtn: this.vaildData(this.permission.finvouchers_edit, false)
  345. };
  346. },
  347. ids() {
  348. let ids = [];
  349. this.selectionList.forEach(ele => {
  350. ids.push(ele.id);
  351. });
  352. return ids.join(",");
  353. }
  354. },
  355. async created() {
  356. this.option = await this.getColumnData(this.getColumnName(321), this.optionBack);
  357. this.voucherStatusWorkDictsfun()
  358. },
  359. activated() {
  360. if (this.$route.query.id) {
  361. setTimeout(() => {
  362. if (!this.$store.getters.voucherStatus) {
  363. this.editFun(this.$route.query)
  364. }
  365. }, 200);
  366. }
  367. },
  368. methods: {
  369. toAddEdit() {
  370. this.datekey = Date.now()
  371. },
  372. // 获取字典数据
  373. setColumnDictData(name, data) {
  374. let col = this.findObject(this.option.column, name);
  375. if(col && typeof col === "object") col.dicData = Array.isArray(data) ? data : [];
  376. },
  377. voucherStatusWorkDictsfun() {
  378. getWorkDicts("voucher_status_los").then(res => {
  379. this.setColumnDictData("voucherStatus", res.data.data);
  380. })
  381. // 是否字典
  382. getWorkDicts("ifInvoice").then(res => {
  383. this.setColumnDictData("isForeign", res.data.data);
  384. this.setColumnDictData("isQuantity", res.data.data);
  385. })
  386. bbusinesstypeList(1,100,{enableVoucher:'1'}).then(res => {
  387. let data=[{id: 0, code: "MANUAL", cnName: "手工凭证"}].concat(res.data.data.records)
  388. this.setColumnDictData("voucherSource", data);
  389. })
  390. // getWorkDicts("voucher_source_los").then(res => {
  391. // this.findObject(this.option.column, "voucherSource").dicData = res.data.data;
  392. // })
  393. getWorkDicts("voucher_word_los").then((res) => {
  394. this.voucherTypeData = res.data.data;
  395. this.setColumnDictData("voucherType", res.data.data);
  396. });
  397. },
  398. // 凭证记账
  399. voucherAccountingfun() {
  400. if (this.selectionList.length === 0) {
  401. this.$message.warning("请选择至少一条数据");
  402. return;
  403. }
  404. if (this.selectionList.length === 1) {
  405. if (this.selectionList[0].voucherStatus == 1) {
  406. return this.$message.warning("请选择还未记账的数据");
  407. }
  408. }
  409. this.$confirm("确定将选择数据进行记账?", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning"
  413. }).then(() => {
  414. let arrids = this.selectionList.map(item => {
  415. if (item.voucherStatus == 0) {
  416. return item.id
  417. }
  418. })
  419. // this.loading = true;
  420. this.$refs.customLloading.startLoading()
  421. confirmFinVouchers({ ids: arrids.join(',') }).then(res => {
  422. this.$message({
  423. type: "success",
  424. message: "操作成功!"
  425. });
  426. // this.loading = false;
  427. this.onLoad(this.page, this.query);
  428. })
  429. .finally(() => {
  430. this.$refs.customLloading.endLoading()
  431. });
  432. })
  433. },
  434. // 撤销记账
  435. revokeFinVouchersfun() {
  436. if (this.selectionList.length === 0) {
  437. this.$message.warning("请选择至少一条数据");
  438. return;
  439. }
  440. if (this.selectionList.length === 1) {
  441. if (this.selectionList[0].voucherStatus == 0) {
  442. return this.$message.warning("请选择已记账的数据");
  443. }
  444. }
  445. this.$confirm("确定将选择数据撤销记账?", {
  446. confirmButtonText: "确定",
  447. cancelButtonText: "取消",
  448. type: "warning"
  449. }).then(() => {
  450. let arrids = this.selectionList.map(item => {
  451. if (item.voucherStatus == 1) {
  452. return item.id
  453. }
  454. })
  455. this.$refs.customLloading.startLoading()
  456. revokeFinVouchers({ ids: arrids.join(',') }).then(res => {
  457. this.$message({
  458. type: "success",
  459. message: "操作成功!"
  460. });
  461. this.onLoad(this.page, this.query);
  462. })
  463. .finally(() => {
  464. this.$refs.customLloading.endLoading()
  465. });
  466. })
  467. },
  468. // 新建凭证
  469. addbtnfun() {
  470. this.isShow = false
  471. this.$store.commit("IN_VOUCHER_DETAIL");
  472. },
  473. // 编辑
  474. editFun(row) {
  475. this.isShow = false
  476. this.$nextTick(() => {
  477. this.$refs.finvouchersitemsRef.finvouchersDetailfun(row.id)
  478. })
  479. this.$store.commit("IN_VOUCHER_DETAIL");
  480. },
  481. // 详情的返回列表
  482. goBack() {
  483. // 初始化数据
  484. if (JSON.stringify(this.$route.query) != "{}") {
  485. this.$router.$avueRouter.closeTag();
  486. this.$router.push({
  487. path: "/iosBasicData/finvouchers/index"
  488. });
  489. }
  490. this.isShow = true;
  491. this.onLoad(this.page, this.query);
  492. this.$store.commit("OUT_VOUCHER_DETAIL");
  493. },
  494. rowSave(row, done, loading) {
  495. finvouchersSubmit(row).then(() => {
  496. this.onLoad(this.page);
  497. this.$message({
  498. type: "success",
  499. message: "操作成功!"
  500. });
  501. done();
  502. }, error => {
  503. loading();
  504. window.console.log(error);
  505. });
  506. },
  507. rowUpdate(row, index, done, loading) {
  508. finvouchersSubmit(row).then(() => {
  509. this.onLoad(this.page);
  510. this.$message({
  511. type: "success",
  512. message: "操作成功!"
  513. });
  514. done();
  515. }, error => {
  516. loading();
  517. console.log(error);
  518. });
  519. },
  520. rowDel(row) {
  521. this.$confirm("确定将选择数据删除?", {
  522. confirmButtonText: "确定",
  523. cancelButtonText: "取消",
  524. type: "warning"
  525. })
  526. .then(() => {
  527. return finvouchersRemove(row.id);
  528. })
  529. .then(() => {
  530. this.onLoad(this.page);
  531. this.$message({
  532. type: "success",
  533. message: "操作成功!"
  534. });
  535. });
  536. },
  537. handleDelete() {
  538. if (this.selectionList.length === 0) {
  539. this.$message.warning("请选择至少一条数据");
  540. return;
  541. }
  542. this.$confirm("确定将选择数据删除?", {
  543. confirmButtonText: "确定",
  544. cancelButtonText: "取消",
  545. type: "warning"
  546. })
  547. .then(() => {
  548. return finvouchersRemove(this.ids);
  549. })
  550. .then(() => {
  551. this.onLoad(this.page);
  552. this.$message({
  553. type: "success",
  554. message: "操作成功!"
  555. });
  556. this.$refs.crud.toggleSelection();
  557. });
  558. },
  559. beforeOpen(done, type) {
  560. if (["edit", "view"].includes(type)) {
  561. finvouchersDetail(this.form.id).then(res => {
  562. this.form = res.data.data;
  563. });
  564. }
  565. done();
  566. },
  567. searchReset() {
  568. this.query = {
  569. voucherStatus: "0",
  570. };
  571. this.onLoad(this.page);
  572. },
  573. searchChange(params, done) {
  574. this.query = params;
  575. this.page.currentPage = 1;
  576. this.onLoad(this.page, this.query);
  577. done();
  578. },
  579. selectionChange(list) {
  580. this.selectionList = list;
  581. },
  582. selectionClear() {
  583. this.selectionList = [];
  584. this.$refs.crud.toggleSelection();
  585. },
  586. currentChange(currentPage) {
  587. this.page.currentPage = currentPage;
  588. },
  589. sizeChange(pageSize) {
  590. this.page.pageSize = pageSize;
  591. },
  592. refreshChange() {
  593. this.onLoad(this.page, this.query);
  594. },
  595. // tabs切换筛选
  596. handleClick(tab, event) {
  597. this.page = {
  598. pageSize: 10,
  599. currentPage: 1,
  600. total: 0
  601. };
  602. this.onLoad(this.page, this.query);
  603. },
  604. onLoad(page, params = {}) {
  605. this.loading = true;
  606. finvouchersList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  607. const data = res.data.data;
  608. this.page.total = data.total;
  609. this.data = data.records.map(item => {
  610. item.isForeign = item.isForeign + ''
  611. item.isQuantity = item.isQuantity + ''
  612. item.voucherStatus = item.voucherStatus + ''
  613. return item
  614. })
  615. this.loading = false;
  616. this.selectionClear();
  617. });
  618. },
  619. //自定义列保存
  620. async saveColumnTwo(ref, option, optionBack, code) {
  621. /**
  622. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  623. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  624. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  625. */
  626. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  627. if (inSave) {
  628. this.$message.success("保存成功");
  629. //关闭窗口
  630. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  631. }
  632. },
  633. //自定义列重置
  634. async resetColumnTwo(ref, option, optionBack, code) {
  635. this[option] = this[optionBack];
  636. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  637. if (inSave) {
  638. this.$message.success("重置成功");
  639. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  640. this.voucherStatusWorkDictsfun()
  641. }
  642. },
  643. // 更改表格颜色
  644. headerClassName(tab) {
  645. //颜色间隔
  646. let back = ""
  647. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  648. if (tab.columnIndex % 2 === 0) {
  649. back = "back-one"
  650. } else if (tab.columnIndex % 2 === 1) {
  651. back = "back-two"
  652. }
  653. }
  654. return back;
  655. },
  656. }
  657. };
  658. </script>
  659. <style scoped>
  660. ::v-deep#out-table .back-one {
  661. background: #ecf5ff !important;
  662. text-align: center;
  663. }
  664. ::v-deep#out-table .back-two {
  665. background: #ecf5ff !important;
  666. text-align: center;
  667. }
  668. .textHide {
  669. width: 100%;
  670. overflow: hidden;
  671. white-space: nowrap;
  672. text-overflow: ellipsis;
  673. }
  674. ::v-deep .el-col-md-8 {
  675. width: 24.33333%;
  676. }
  677. </style>