index.vue 17 KB

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