index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud :option="option"
  5. :table-loading="loading"
  6. :data="data"
  7. :page.sync="page"
  8. :search.sync="query"
  9. :permission="permissionList"
  10. :before-open="beforeOpen"
  11. v-model="form"
  12. ref="crud"
  13. id="out-table"
  14. :header-cell-class-name="headerClassName"
  15. @row-update="rowUpdate"
  16. @row-save="rowSave"
  17. @row-del="rowDel"
  18. @search-change="searchChange"
  19. @search-reset="searchReset"
  20. @selection-change="selectionChange"
  21. @current-change="currentChange"
  22. @size-change="sizeChange"
  23. @refresh-change="refreshChange"
  24. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 329)"
  25. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 329)"
  26. @on-load="onLoad" >
  27. <template slot="menuLeft">
  28. <el-button type="primary"
  29. size="small"
  30. plain @click="initializationfun" >初始入账
  31. </el-button>
  32. <el-button type="success"
  33. size="small"
  34. plain >导出
  35. </el-button>
  36. <el-button type="danger"
  37. size="small"
  38. icon="el-icon-delete"
  39. plain
  40. v-if="permission.fingenleg_delete"
  41. @click="handleDelete">删 除
  42. </el-button>
  43. </template>
  44. <template slot-scope="{disabled,size}" slot="startCodeSearch">
  45. <search-query :datalist="startCodeData"
  46. :selectValue="query.startCode"
  47. :filterable="true"
  48. :clearable="true"
  49. :remote="true"
  50. :buttonIf="false"
  51. :forParameter="{key:'id',label:'code',value:'code'}"
  52. @corpFocus="startCodeDatafun"
  53. @remoteMethod="startCodeDatafun"
  54. @corpChange="corpChange($event,'startCode')">
  55. </search-query>
  56. </template>
  57. <template slot-scope="{disabled,size}" slot="endCodeSearch">
  58. <search-query :datalist="endCodeData"
  59. :selectValue="query.endCode"
  60. :filterable="true"
  61. :clearable="true"
  62. :remote="true"
  63. :buttonIf="false"
  64. :forParameter="{key:'id',label:'code',value:'code'}"
  65. @corpFocus="endCodeDatafun"
  66. @remoteMethod="endCodeDatafun"
  67. @corpChange="corpChange($event,'endCode')">
  68. </search-query>
  69. </template>
  70. <template slot-scope="{disabled,size}" slot="isYearMothSearch">
  71. <el-checkbox v-model="query.isYearMoth" :true-label="1" :false-label="0" @change="isYearMothfun" ></el-checkbox>
  72. </template>
  73. <template slot-scope="{disabled,size}" slot="isBalanceSearch">
  74. <el-checkbox v-model="query.isBalance" :true-label="1" :false-label="0" ></el-checkbox>
  75. </template>
  76. <template slot-scope="{disabled,size}" slot="isForeignDetermineSearch">
  77. <el-checkbox v-model="isForeignDetermine" @change="isForeignDeterminefun" ></el-checkbox>
  78. </template>
  79. </avue-crud>
  80. </basic-container>
  81. </div>
  82. </template>
  83. <script>
  84. import {
  85. fingenlegList,
  86. fingenlegDetail,
  87. fingenlegSubmit,
  88. fingenlegRemove,
  89. fingenlegInitialization
  90. } from "@/api/iosBasicData/fingenleg";
  91. import {accountsList} from "@/api/iosBasicData/accounts";
  92. import {mapGetters} from "vuex";
  93. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  94. import {CurrentMonth, dateFormat, defaultDate4} from "@/util/date";
  95. export default {
  96. components: {SearchQuery},
  97. data() {
  98. return {
  99. form: {},
  100. query: {
  101. isYearMoth:0,
  102. isBalance:0,
  103. accyear:defaultDate4(), // 默认当年
  104. startDate:CurrentMonth(new Date(),'yyyy-MM'), // 开始日期
  105. endDate:dateFormat(new Date(),'yyyy-MM'), // 结束日期
  106. },
  107. isForeignDetermine:false, // 是否外币
  108. startCodeData:[], // 开始科目数据
  109. endCodeData:[], // 结束科目数据
  110. loading: true,
  111. page: {
  112. pageSize: 10,
  113. currentPage: 1,
  114. total: 0
  115. },
  116. selectionList: [],
  117. option:{},
  118. optionBack: {
  119. height:'auto',
  120. calcHeight: 30,
  121. tip: false,
  122. searchShow: true,
  123. searchMenuSpan: 6,
  124. border: true,
  125. index: false,
  126. viewBtn: true,
  127. selection: true,
  128. dialogClickModal: false,
  129. menu:false,
  130. rowKey:'id',
  131. rowParentKey:'pid',
  132. defaultExpandAll:true,
  133. column: [
  134. {
  135. label: "年",
  136. prop: "accyear",
  137. width:'80',
  138. index:1,
  139. overHidden:true,
  140. },
  141. {
  142. label: "月",
  143. prop: "accmonth",
  144. width:'40',
  145. index:2,
  146. overHidden:true,
  147. },
  148. {
  149. label: "科目代码",
  150. prop: "accCode",
  151. index:3,
  152. overHidden:true,
  153. },
  154. {
  155. label: "科目名称",
  156. prop: "fullName",
  157. index:4,
  158. overHidden:true,
  159. },
  160. {
  161. label: "科目方向",
  162. prop: "accDc",
  163. index:5,
  164. type: 'select',
  165. dicData:[
  166. {
  167. label:'借方',
  168. value:'D'
  169. },{
  170. label:'贷方',
  171. value:'C'
  172. },
  173. ],
  174. overHidden:true,
  175. },
  176. {
  177. label: "摘要",
  178. prop: "descr",
  179. index:6,
  180. overHidden:true,
  181. },
  182. {
  183. label: "开始科目",
  184. prop: "startCode",
  185. overHidden:true,
  186. search:true,
  187. hide:true,
  188. searchslot:true,
  189. },
  190. {
  191. label: "结束科目",
  192. prop: "endCode",
  193. overHidden:true,
  194. search:true,
  195. hide:true,
  196. searchslot:true,
  197. },
  198. {
  199. label: "开始日期",
  200. prop: "startDate",
  201. search:true,
  202. overHidden:true,
  203. hide:true,
  204. type: "month",
  205. format: "yyyy-MM",
  206. valueFormat: "yyyy-MM",
  207. },
  208. {
  209. label: "结束日期",
  210. prop: "endDate",
  211. search:true,
  212. overHidden:true,
  213. hide:true,
  214. type: "month",
  215. format: "yyyy-MM",
  216. valueFormat: "yyyy-MM",
  217. },
  218. {
  219. label: "币种",
  220. prop: "curCode",
  221. hide:true,
  222. search:true,
  223. dicData:[
  224. {
  225. label:'CNY',
  226. value:'CNY'
  227. },{
  228. label:'USD',
  229. value:'USD'
  230. },
  231. ],
  232. overHidden:true,
  233. },
  234. {
  235. label: "无发生额显示本月本年累计",
  236. prop: "isYearMoth",
  237. hide:true,
  238. search:true,
  239. searchslot:true,
  240. searchLabelWidth:'160',
  241. searchSpan:4,
  242. },
  243. {
  244. label: "无余额无发生显示",
  245. prop: "isBalance",
  246. hide:true,
  247. search:true,
  248. searchslot:true,
  249. searchLabelWidth:'120',
  250. searchSpan:4,
  251. },
  252. {
  253. label: "显示外币",
  254. prop: "isForeignDetermine",
  255. hide:true,
  256. search:true,
  257. searchslot:true,
  258. searchSpan:3,
  259. },
  260. {
  261. label: "本期借方金额",
  262. prop: "amountDr",
  263. index:7,
  264. width:'100',
  265. overHidden:true,
  266. },
  267. {
  268. label: "本期贷方金额",
  269. prop: "amountCr",
  270. index:8,
  271. width:'100',
  272. overHidden:true,
  273. },
  274. {
  275. label: "本期余额",
  276. prop: "amountBlc",
  277. index:9,
  278. overHidden:true,
  279. },
  280. {
  281. label: "方向",
  282. prop: "dc",
  283. index:10,
  284. type: 'select',
  285. dicData:[
  286. {
  287. label:'借方',
  288. value:'D'
  289. },{
  290. label:'贷方',
  291. value:'C'
  292. },
  293. ],
  294. overHidden:true,
  295. },
  296. ]
  297. },
  298. data: []
  299. };
  300. },
  301. computed: {
  302. ...mapGetters(["permission"]),
  303. permissionList() {
  304. return {
  305. addBtn: this.vaildData(this.permission.fingenleg_add, false),
  306. viewBtn: this.vaildData(this.permission.fingenleg_view, false),
  307. delBtn: this.vaildData(this.permission.fingenleg_delete, false),
  308. editBtn: this.vaildData(this.permission.fingenleg_edit, false)
  309. };
  310. },
  311. ids() {
  312. let ids = [];
  313. this.selectionList.forEach(ele => {
  314. ids.push(ele.id);
  315. });
  316. return ids.join(",");
  317. }
  318. },
  319. async created() {
  320. this.option = await this.getColumnData(this.getColumnName(329), this.optionBack);
  321. },
  322. methods: {
  323. // 下拉监听
  324. corpChange(value,name){
  325. this.$set(this.query,name,value)
  326. },
  327. // 获取科目类型数据
  328. startCodeDatafun(code){
  329. accountsList(1,10,{code,isDetail:1}).then(res=>{
  330. this.startCodeData = res.data.data.records
  331. })
  332. },
  333. endCodeDatafun(code){
  334. accountsList(1,10,{code,isDetail:1}).then(res=>{
  335. this.endCodeData = res.data.data.records
  336. })
  337. },
  338. // 无发生额显示本月本年累计 点击
  339. isYearMothfun(){
  340. let obj = JSON.parse(JSON.stringify(this.query))
  341. if (this.query.isYearMoth) {
  342. this.findObject(this.option.column, "amountDr").label = '本年借方金额'
  343. this.findObject(this.option.column, "amountDr").prop = 'amountYearDr'
  344. this.findObject(this.option.column, "amountCr").label = '本年贷方金额'
  345. this.findObject(this.option.column, "amountCr").prop = 'amountYearCr'
  346. if (this.isForeignDetermine) {
  347. this.findObject(this.option.column, "amountDrUsd").label = '本年借方外币金额'
  348. this.findObject(this.option.column, "amountDrUsd").prop = 'amountYearDrUsd'
  349. this.findObject(this.option.column, "amountCrUsd").label = '本年贷方外币金额'
  350. this.findObject(this.option.column, "amountCrUsd").prop = 'amountYearCrUsd'
  351. }
  352. }else {
  353. this.findObject(this.option.column, "amountYearDr").label = '本期借方金额'
  354. this.findObject(this.option.column, "amountYearDr").prop = 'amountDr'
  355. this.findObject(this.option.column, "amountYearCr").label = '本期贷方金额'
  356. this.findObject(this.option.column, "amountYearCr").prop = 'amountCr'
  357. if (this.isForeignDetermine) {
  358. this.findObject(this.option.column, "amountYearDrUsd").label = '本期借方外币金额'
  359. this.findObject(this.option.column, "amountYearDrUsd").prop = 'amountDrUsd'
  360. this.findObject(this.option.column, "amountYearCrUsd").label = '本期贷方外币金额'
  361. this.findObject(this.option.column, "amountYearCrUsd").prop = 'amountCrUsd'
  362. }
  363. }
  364. this.query = JSON.parse(JSON.stringify(obj))
  365. },
  366. // 是否外币点击
  367. isForeignDeterminefun(){
  368. let obj = JSON.parse(JSON.stringify(this.query))
  369. if (this.isForeignDetermine) {
  370. this.option.column.push(
  371. {
  372. label: '币种',
  373. prop: 'curCode',
  374. index:11,
  375. overHidden: true,
  376. },
  377. {
  378. label: '本期借方外币金额',
  379. prop: 'amountDrUsd',
  380. width:'120',
  381. index:12,
  382. overHidden: true,
  383. },{
  384. label: '本期贷方外币金额',
  385. prop: 'amountCrUsd',
  386. width:'120',
  387. index:13,
  388. overHidden: true,
  389. },{
  390. label: '本期外币余额',
  391. prop: 'amountUsdBlc',
  392. width:'100',
  393. index:14,
  394. overHidden: true,
  395. })
  396. if (this.query.isYearMoth) {
  397. this.findObject(this.option.column, "amountDrUsd").label = '本年借方外币金额'
  398. this.findObject(this.option.column, "amountDrUsd").prop = 'amountYearDrUsd'
  399. this.findObject(this.option.column, "amountCrUsd").label = '本年贷方外币金额'
  400. this.findObject(this.option.column, "amountCrUsd").prop = 'amountYearCrUsd'
  401. }
  402. this.query = JSON.parse(JSON.stringify(obj))
  403. }else {
  404. this.option = JSON.parse(JSON.stringify(this.optionBack))
  405. this.query = JSON.parse(JSON.stringify(obj))
  406. if (this.query.isYearMoth) {
  407. this.findObject(this.option.column, "amountDr").label = '本年借方金额'
  408. this.findObject(this.option.column, "amountDr").prop = 'amountYearDr'
  409. this.findObject(this.option.column, "amountCr").label = '本年贷方金额'
  410. this.findObject(this.option.column, "amountCr").prop = 'amountYearCr'
  411. }
  412. }
  413. },
  414. // 初始入账
  415. initializationfun(){
  416. fingenlegInitialization().then(res=>{
  417. this.page.currentPage = 1;
  418. this.onLoad(this.page, this.query);
  419. })
  420. },
  421. rowSave(row, done, loading) {
  422. fingenlegSubmit(row).then(() => {
  423. this.onLoad(this.page);
  424. this.$message({
  425. type: "success",
  426. message: "操作成功!"
  427. });
  428. done();
  429. }, error => {
  430. loading();
  431. window.console.log(error);
  432. });
  433. },
  434. rowUpdate(row, index, done, loading) {
  435. fingenlegSubmit(row).then(() => {
  436. this.onLoad(this.page);
  437. this.$message({
  438. type: "success",
  439. message: "操作成功!"
  440. });
  441. done();
  442. }, error => {
  443. loading();
  444. console.log(error);
  445. });
  446. },
  447. rowDel(row) {
  448. this.$confirm("确定将选择数据删除?", {
  449. confirmButtonText: "确定",
  450. cancelButtonText: "取消",
  451. type: "warning"
  452. })
  453. .then(() => {
  454. return fingenlegRemove(row.id);
  455. })
  456. .then(() => {
  457. this.onLoad(this.page);
  458. this.$message({
  459. type: "success",
  460. message: "操作成功!"
  461. });
  462. });
  463. },
  464. handleDelete() {
  465. if (this.selectionList.length === 0) {
  466. this.$message.warning("请选择至少一条数据");
  467. return;
  468. }
  469. this.$confirm("确定将选择数据删除?", {
  470. confirmButtonText: "确定",
  471. cancelButtonText: "取消",
  472. type: "warning"
  473. })
  474. .then(() => {
  475. return fingenlegRemove(this.ids);
  476. })
  477. .then(() => {
  478. this.onLoad(this.page);
  479. this.$message({
  480. type: "success",
  481. message: "操作成功!"
  482. });
  483. this.$refs.crud.toggleSelection();
  484. });
  485. },
  486. beforeOpen(done, type) {
  487. if (["edit", "view"].includes(type)) {
  488. fingenlegDetail(this.form.id).then(res => {
  489. this.form = res.data.data;
  490. });
  491. }
  492. done();
  493. },
  494. searchReset() {
  495. this.query = {
  496. isYearMoth:0,
  497. isBalance:0,
  498. accyear:defaultDate4(), // 默认当年
  499. startDate:CurrentMonth(new Date(),'yyyy-MM'), // 开始日期
  500. endDate:dateFormat(new Date(),'yyyy-MM'), // 结束日期
  501. };
  502. this.onLoad(this.page);
  503. },
  504. searchChange(params, done) {
  505. this.query = params;
  506. this.page.currentPage = 1;
  507. this.onLoad(this.page, params);
  508. done();
  509. },
  510. selectionChange(list) {
  511. this.selectionList = list;
  512. },
  513. selectionClear() {
  514. this.selectionList = [];
  515. this.$refs.crud.toggleSelection();
  516. },
  517. currentChange(currentPage){
  518. this.page.currentPage = currentPage;
  519. },
  520. sizeChange(pageSize){
  521. this.page.pageSize = pageSize;
  522. },
  523. refreshChange() {
  524. this.onLoad(this.page, this.query);
  525. },
  526. onLoad(page, params = {}) {
  527. if (this.query.startDate.split('-')[0] != this.query.endDate.split('-')[0]) {
  528. return this.$message.warning('开始日期和结束日期请选择同一年')
  529. }
  530. this.loading = true;
  531. fingenlegList(page.currentPage, page.pageSize, {
  532. ...Object.assign(params, this.query),
  533. startDate:Number(this.query.startDate.split('-')[1]),
  534. endDate:Number(this.query.endDate.split('-')[1]),
  535. }).then(res => {
  536. const data = res.data.data;
  537. this.page.total = data.total;
  538. this.data = data.records.map(item=>{
  539. item.children = item.finGenlegs.map((ite,inde)=>{
  540. ite.id = Number(inde) + 1
  541. return ite
  542. })
  543. return item
  544. })
  545. this.loading = false;
  546. this.selectionClear();
  547. });
  548. },
  549. //自定义列保存
  550. async saveColumnTwo(ref, option, optionBack, code) {
  551. /**
  552. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  553. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  554. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  555. */
  556. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  557. if (inSave) {
  558. this.$message.success("保存成功");
  559. //关闭窗口
  560. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  561. }
  562. },
  563. //自定义列重置
  564. async resetColumnTwo(ref, option, optionBack, code) {
  565. this[option] = this[optionBack];
  566. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  567. if (inSave) {
  568. this.$message.success("重置成功");
  569. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  570. }
  571. },
  572. // 更改表格颜色
  573. headerClassName(tab){
  574. //颜色间隔
  575. let back = ""
  576. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  577. if (tab.columnIndex % 2 === 0) {
  578. back = "back-one"
  579. } else if (tab.columnIndex % 2 === 1) {
  580. back = "back-two"
  581. }
  582. }
  583. return back;
  584. },
  585. }
  586. };
  587. </script>
  588. <style scoped>
  589. ::v-deep#out-table .back-one {
  590. background: #ecf5ff !important;
  591. text-align: center;
  592. }
  593. ::v-deep#out-table .back-two {
  594. background: #ecf5ff !important;
  595. text-align: center;
  596. }
  597. </style>