index.vue 21 KB

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