index.vue 17 KB

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