index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option"
  5. :table-loading="loading"
  6. :data="data"
  7. :page.sync="page"
  8. :permission="permissionList"
  9. :before-open="beforeOpen"
  10. v-model="form"
  11. id="out-table"
  12. :header-cell-class-name="headerClassName"
  13. ref="crud"
  14. @row-update="rowUpdate"
  15. @row-save="rowSave"
  16. @row-del="rowDel"
  17. @search-change="searchChange"
  18. @search-reset="searchReset"
  19. @selection-change="selectionChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @refresh-change="refreshChange"
  23. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 321)"
  24. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 321)"
  25. @on-load="onLoad" >
  26. <template slot="menuLeft">
  27. <el-button type="primary"
  28. size="small"
  29. icon="el-icon-plus"
  30. @click="addbtnfun()">新建财务凭证
  31. </el-button>
  32. <el-button type="danger"
  33. size="small"
  34. icon="el-icon-delete"
  35. plain
  36. @click="handleDelete">删 除
  37. </el-button>
  38. </template>
  39. <template slot="menu" slot-scope="{row}">
  40. <el-button type="text"
  41. size="small"
  42. @click="editFun(row)">编辑
  43. </el-button>
  44. <el-button type="text"
  45. size="small"
  46. @click="rowDel(row)">删除
  47. </el-button>
  48. </template>
  49. </avue-crud>
  50. </basic-container>
  51. <finvouchersitems ref="finvouchersitemsRef" v-if="!isShow" @goBack="goBack"></finvouchersitems>
  52. </div>
  53. </template>
  54. <script>
  55. import {finvouchersList, finvouchersDetail, finvouchersSubmit, finvouchersRemove} from "@/api/iosBasicData/finvouchers";
  56. import {mapGetters} from "vuex";
  57. import finvouchersitems from "@/views/iosBasicData/finvouchers/finvouchersitems.vue";
  58. import finstlbillsDetails from "@/views/iosBasicData/finstlbills/finstlbillsDetails.vue";
  59. export default {
  60. data() {
  61. return {
  62. isShow:true, // 详情弹窗
  63. form: {},
  64. query: {},
  65. loading: true,
  66. page: {
  67. pageSize: 10,
  68. currentPage: 1,
  69. total: 0
  70. },
  71. selectionList: [],
  72. option:{},
  73. optionBack: {
  74. height:'auto',
  75. calcHeight: 30,
  76. tip: false,
  77. searchShow: true,
  78. searchMenuSpan: 6,
  79. border: true,
  80. index: true,
  81. viewBtn: true,
  82. selection: true,
  83. dialogClickModal: false,
  84. menuWidth:'100',
  85. column: [
  86. {
  87. label: "账单编号",
  88. prop: "billNo",
  89. overHidden:true,
  90. },
  91. {
  92. label: "凭证来源",
  93. prop: "voucherSource",
  94. overHidden:true,
  95. },
  96. {
  97. label: "凭证类型",
  98. prop: "voucherType",
  99. overHidden:true,
  100. },
  101. {
  102. label: "凭证号",
  103. prop: "voucherNo",
  104. overHidden:true,
  105. },
  106. {
  107. label: "凭证日期",
  108. prop: "voucherDate",
  109. overHidden:true,
  110. },
  111. {
  112. label: "财务年",
  113. prop: "accountYear",
  114. overHidden:true,
  115. },
  116. {
  117. label: "财务月",
  118. prop: "accountMonth",
  119. overHidden:true,
  120. },
  121. {
  122. label: "财务日",
  123. prop: "accountDay",
  124. overHidden:true,
  125. },
  126. {
  127. label: "分录摘要",
  128. prop: "descr",
  129. overHidden:true,
  130. },
  131. {
  132. label: "借方金额(CNY)",
  133. prop: "amountDr",
  134. width:'140',
  135. overHidden:true,
  136. },
  137. {
  138. label: "贷方金额(CNY)",
  139. prop: "amountCr",
  140. width:'140',
  141. overHidden:true,
  142. },
  143. {
  144. label: "借方金额(USD)",
  145. prop: "amountDrUsd",
  146. width:'140',
  147. overHidden:true,
  148. },
  149. {
  150. label: "贷方金额(USD)",
  151. prop: "amountCrUsd",
  152. width:'140',
  153. overHidden:true,
  154. },
  155. {
  156. label: "合计本位币借方金额(CNY)",
  157. prop: "amountDrLoc",
  158. width:'170',
  159. overHidden:true,
  160. },
  161. {
  162. label: "合计本位币贷方金额(CNY)",
  163. prop: "amountCrLoc",
  164. width:'170',
  165. overHidden:true,
  166. },
  167. {
  168. label: "外币凭证",
  169. prop: "isForeign",
  170. search: true,
  171. type:'select',
  172. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  173. props: {
  174. label: "dictValue",
  175. value: "dictKey"
  176. },
  177. overHidden:true,
  178. },
  179. {
  180. label: "数量凭证",
  181. prop: "isQuantity",
  182. search: true,
  183. type:'select',
  184. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  185. props: {
  186. label: "dictValue",
  187. value: "dictKey"
  188. },
  189. overHidden:true,
  190. },
  191. {
  192. label: "复核人",
  193. prop: "checkUserName",
  194. overHidden:true,
  195. },
  196. {
  197. label: "复核时间",
  198. prop: "checkTime",
  199. overHidden:true,
  200. },
  201. {
  202. label: "记账人",
  203. prop: "postUserName",
  204. overHidden:true,
  205. },
  206. {
  207. label: "记账时间",
  208. prop: "postTime",
  209. overHidden:true,
  210. },
  211. {
  212. label: "凭证状态",
  213. prop: "voucherStatus",
  214. search: true,
  215. type:'select',
  216. dicUrl: "/api/blade-system/dict-biz/dictionary?code=voucher_status_los",
  217. props: {
  218. label: "dictValue",
  219. value: "dictKey"
  220. },
  221. overHidden:true,
  222. },
  223. {
  224. label: "备注",
  225. prop: "remarks",
  226. overHidden:true,
  227. },
  228. ]
  229. },
  230. data: []
  231. };
  232. },
  233. components:{finstlbillsDetails, finvouchersitems},
  234. computed: {
  235. ...mapGetters(["permission"]),
  236. permissionList() {
  237. return {
  238. addBtn: this.vaildData(this.permission.finvouchers_add, false),
  239. viewBtn: this.vaildData(this.permission.finvouchers_view, false),
  240. delBtn: this.vaildData(this.permission.finvouchers_delete, false),
  241. editBtn: this.vaildData(this.permission.finvouchers_edit, false)
  242. };
  243. },
  244. ids() {
  245. let ids = [];
  246. this.selectionList.forEach(ele => {
  247. ids.push(ele.id);
  248. });
  249. return ids.join(",");
  250. }
  251. },
  252. async created() {
  253. this.option = await this.getColumnData(this.getColumnName(321), this.optionBack);
  254. },
  255. methods: {
  256. // 新建凭证
  257. addbtnfun(){
  258. this.isShow = false
  259. },
  260. // 编辑
  261. editFun(row) {
  262. this.isShow = false
  263. this.$nextTick(()=>{
  264. this.$refs.finvouchersitemsRef.finvouchersDetailfun(row.id)
  265. })
  266. },
  267. // 详情的返回列表
  268. goBack() {
  269. // 初始化数据
  270. if (JSON.stringify(this.$route.query) != "{}") {
  271. this.$router.$avueRouter.closeTag();
  272. this.$router.push({
  273. path: "/iosBasicData/finvouchers/index"
  274. });
  275. }
  276. this.isShow = true;
  277. this.onLoad(this.page, this.search);
  278. },
  279. rowSave(row, done, loading) {
  280. finvouchersSubmit(row).then(() => {
  281. this.onLoad(this.page);
  282. this.$message({
  283. type: "success",
  284. message: "操作成功!"
  285. });
  286. done();
  287. }, error => {
  288. loading();
  289. window.console.log(error);
  290. });
  291. },
  292. rowUpdate(row, index, done, loading) {
  293. finvouchersSubmit(row).then(() => {
  294. this.onLoad(this.page);
  295. this.$message({
  296. type: "success",
  297. message: "操作成功!"
  298. });
  299. done();
  300. }, error => {
  301. loading();
  302. console.log(error);
  303. });
  304. },
  305. rowDel(row) {
  306. this.$confirm("确定将选择数据删除?", {
  307. confirmButtonText: "确定",
  308. cancelButtonText: "取消",
  309. type: "warning"
  310. })
  311. .then(() => {
  312. return finvouchersRemove(row.id);
  313. })
  314. .then(() => {
  315. this.onLoad(this.page);
  316. this.$message({
  317. type: "success",
  318. message: "操作成功!"
  319. });
  320. });
  321. },
  322. handleDelete() {
  323. if (this.selectionList.length === 0) {
  324. this.$message.warning("请选择至少一条数据");
  325. return;
  326. }
  327. this.$confirm("确定将选择数据删除?", {
  328. confirmButtonText: "确定",
  329. cancelButtonText: "取消",
  330. type: "warning"
  331. })
  332. .then(() => {
  333. return finvouchersRemove(this.ids);
  334. })
  335. .then(() => {
  336. this.onLoad(this.page);
  337. this.$message({
  338. type: "success",
  339. message: "操作成功!"
  340. });
  341. this.$refs.crud.toggleSelection();
  342. });
  343. },
  344. beforeOpen(done, type) {
  345. if (["edit", "view"].includes(type)) {
  346. finvouchersDetail(this.form.id).then(res => {
  347. this.form = res.data.data;
  348. });
  349. }
  350. done();
  351. },
  352. searchReset() {
  353. this.query = {};
  354. this.onLoad(this.page);
  355. },
  356. searchChange(params, done) {
  357. this.query = params;
  358. this.page.currentPage = 1;
  359. this.onLoad(this.page, params);
  360. done();
  361. },
  362. selectionChange(list) {
  363. this.selectionList = list;
  364. },
  365. selectionClear() {
  366. this.selectionList = [];
  367. this.$refs.crud.toggleSelection();
  368. },
  369. currentChange(currentPage){
  370. this.page.currentPage = currentPage;
  371. },
  372. sizeChange(pageSize){
  373. this.page.pageSize = pageSize;
  374. },
  375. refreshChange() {
  376. this.onLoad(this.page, this.query);
  377. },
  378. onLoad(page, params = {}) {
  379. this.loading = true;
  380. finvouchersList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  381. const data = res.data.data;
  382. this.page.total = data.total;
  383. this.data = data.records;
  384. this.loading = false;
  385. this.selectionClear();
  386. });
  387. },
  388. //自定义列保存
  389. async saveColumnTwo(ref, option, optionBack, code) {
  390. /**
  391. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  392. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  393. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  394. */
  395. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  396. if (inSave) {
  397. this.$message.success("保存成功");
  398. //关闭窗口
  399. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  400. }
  401. },
  402. //自定义列重置
  403. async resetColumnTwo(ref, option, optionBack, code) {
  404. this[option] = this[optionBack];
  405. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  406. if (inSave) {
  407. this.$message.success("重置成功");
  408. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  409. }
  410. },
  411. // 更改表格颜色
  412. headerClassName(tab){
  413. //颜色间隔
  414. let back = ""
  415. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  416. if (tab.columnIndex % 2 === 0) {
  417. back = "back-one"
  418. } else if (tab.columnIndex % 2 === 1) {
  419. back = "back-two"
  420. }
  421. }
  422. return back;
  423. },
  424. }
  425. };
  426. </script>
  427. <style scoped>
  428. ::v-deep#out-table .back-one {
  429. background: #ecf5ff !important;
  430. text-align: center;
  431. }
  432. ::v-deep#out-table .back-two {
  433. background: #ecf5ff !important;
  434. text-align: center;
  435. }
  436. </style>