index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-form :option="optionForm" v-model="query" class="form-mb">
  5. <tempalte slot="button" slot-scope="{ row }">
  6. <span style="display: flex;justify-content: end;">
  7. <el-button icon="el-icon-arrow-down" size="small" @click="searchShow = true, showHight()" v-if="!searchShow">展
  8. 开</el-button>
  9. <el-button icon="el-icon-arrow-up" size="small" @click="searchShow = false, showHight()" v-if="searchShow">收
  10. 缩</el-button>
  11. <!-- <el-button type="primary" size="small" plain @click="inItial">初始入账
  12. </el-button> -->
  13. <el-button type="success" size="small" plain @click="outExport">导出
  14. </el-button>
  15. </span>
  16. </tempalte>
  17. </avue-form>
  18. <div v-show="searchShow">
  19. <avue-form :option="optionForm2" v-model="query" class="form-mb">
  20. <tempalte slot="levelStart" slot-scope="{ row }">
  21. <span style="display: flex;">
  22. <avue-select v-model="query.levelStart" placeholder="请选择科目级次" :dic="dic"></avue-select>
  23. <span style="margin: 0 4px;">至</span>
  24. <avue-select v-model="query.levelEnd" placeholder="请选择科目级次" :dic="dic"></avue-select>
  25. </span>
  26. </tempalte>
  27. <tempalte slot="type" slot-scope="{ row }">
  28. <el-row>
  29. <el-col :span="6"> <avue-select v-model="query.type" placeholder="请选择核算类型"
  30. :dic="typeDic"></avue-select></el-col>
  31. <el-col :span="18"> <avue-select v-model="query.corpList" placeholder="请选择核算项目" :dic="corpDic"
  32. :props="corpProps" :filterable="true" :multiple="true" :tags="true"></avue-select></el-col>
  33. </el-row>
  34. </tempalte>
  35. </avue-form>
  36. <span style="display: flex;justify-content: end;">
  37. <el-button type="primary" icon="el-icon-search" size="small" @click="serach">搜 索</el-button>
  38. <el-button icon="el-icon-delete" size="small" @click="reset">清 空</el-button>
  39. </span>
  40. </div>
  41. </basic-container>
  42. <basic-container v-show="treeData.length > 0">
  43. <el-row>
  44. <el-col :span="4">
  45. <avue-tree ref="tree" :class="searchShow ? 'treeStyle' : 'bigTreeStyle'" :option="treeOption" :data="treeData"
  46. v-model="treeForm" @node-click="nodeClick">
  47. </avue-tree>
  48. </el-col>
  49. <el-col :span="20" style="padding-left: 20px;">
  50. <avue-crud :option="option" :data="dataList" ref="crud" id="out-table"
  51. :header-cell-class-name="headerClassName">
  52. <template slot="voucherNo" slot-scope="{ row }">
  53. <span style="color: #1e9fff;cursor: pointer;" @click="toJump(row)">{{ row.voucherNo }}
  54. </span>
  55. </template>
  56. </avue-crud>
  57. </el-col>
  58. </el-row>
  59. </basic-container>
  60. </div>
  61. </template>
  62. <script>
  63. import {
  64. getList,
  65. getAllList,
  66. getTreelist,
  67. initialization
  68. } from "@/api/iosBasicData/accountsDetails";
  69. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  70. import { dateFormat } from "@/util/date";
  71. import { getToken } from "@/util/auth";
  72. export default {
  73. components: { SearchQuery },
  74. data() {
  75. return {
  76. treeForm: {},
  77. treeData: [],
  78. treeOption: {
  79. menu: false,
  80. addBtn: false,
  81. props: {
  82. label: 'accName',
  83. value: 'id'
  84. }
  85. },
  86. query: {
  87. startYear: null,
  88. endYear: null,
  89. monthDate: [dateFormat(new Date(), 'yyyy-MM'), dateFormat(new Date(), 'yyyy-MM')],
  90. checkbox: [],
  91. accIds: null,
  92. accList: [],
  93. levelStart: null,
  94. levelEnd: null,
  95. type: null,
  96. corpList: [],
  97. corpIds: null,
  98. auxiliaryAccounting: 0,
  99. foreignCurrency: 0,
  100. lastLevelItem: 0,
  101. blcNotZero: 0,
  102. noAmountIncurred: 0,
  103. doNotDisplayYear: 0,
  104. oppositeAcc: 0,
  105. total: 0
  106. },
  107. outExportQuery: {},
  108. searchShow: true,
  109. optionForm: {
  110. submitBtn: false,
  111. emptyBtn: false,
  112. column: [
  113. {
  114. label: '期间',
  115. prop: 'monthDate',
  116. type: 'monthrange',
  117. format: 'yyyy-MM',
  118. valueFormat: 'yyyy-MM',
  119. span: 6,
  120. },
  121. {
  122. label: '',
  123. prop: 'button',
  124. span: 18,
  125. }
  126. ]
  127. },
  128. optionForm2: {
  129. submitBtn: false,
  130. emptyBtn: false,
  131. column: [
  132. {
  133. label: '科目',
  134. prop: 'accList',
  135. type: 'select',
  136. filterable: true,
  137. multiple: true,
  138. tags: true,
  139. dicUrl: "/api/blade-los/accounts/selectList?isDetail=1",
  140. props: {
  141. label: 'cnName',
  142. desc: 'code',
  143. value: 'id',
  144. res: 'data'
  145. },
  146. span: 6,
  147. },
  148. {
  149. label: '科目级次',
  150. prop: 'levelStart',
  151. span: 6,
  152. },
  153. {
  154. label: '分录摘要',
  155. prop: 'descr',
  156. span: 6,
  157. row: true,
  158. },
  159. {
  160. label: '显示辅助核算',
  161. prop: 'auxiliaryAccounting',
  162. type: 'switch',
  163. dicData: [{
  164. label: '',
  165. value: 0
  166. }, {
  167. label: '',
  168. value: 1
  169. }],
  170. span: 6,
  171. },
  172. {
  173. label: '辅助核算',
  174. prop: 'type',
  175. display: false,
  176. span: 12,
  177. },
  178. {
  179. label: '多选',
  180. prop: 'checkbox',
  181. type: 'checkbox',
  182. span: 24,
  183. dicData: [
  184. {
  185. label: '只显示最明细级',
  186. value: 'lastLevelItem'
  187. }, {
  188. label: '是否显示外币',
  189. value: 'foreignCurrency'
  190. }, {
  191. label: '显示对方科目辅助核算',
  192. value: 'oppositeAcc'
  193. }, {
  194. label: '余额为0不显示',
  195. value: 'blcNotZero'
  196. }, {
  197. label: '无发生额且余额为0不显示',
  198. value: 'noAmountIncurred'
  199. }, {
  200. label: '发生额为0不显示本期合计、本年累计',
  201. value: 'doNotDisplayYear'
  202. }, {
  203. label: '显示合计',
  204. value: 'total'
  205. }
  206. ],
  207. },
  208. ]
  209. },
  210. dic: [{
  211. label: '1',
  212. value: 1
  213. }, {
  214. label: '2',
  215. value: 2
  216. }, {
  217. label: '3',
  218. value: 3
  219. }],
  220. typeDic: [{
  221. label: '客户',
  222. value: 1
  223. }, {
  224. label: '部门',
  225. value: 2
  226. }, {
  227. label: '职工',
  228. value: 3
  229. }],
  230. corpProps: {
  231. label: 'name',
  232. value: 'id'
  233. },
  234. corpDic: [],
  235. option: {
  236. height: 'auto',
  237. calcHeight: 30,
  238. border: true,
  239. index: true,
  240. menu: false,
  241. addBtn: false,
  242. header: false,
  243. summaryText: "合计",
  244. showSummary: false,
  245. sumColumnList: [{
  246. name: "amountDr",
  247. type: "sum",
  248. decimals: 2
  249. }, {
  250. name: "amountCr",
  251. type: "sum",
  252. decimals: 2
  253. }, {
  254. name: "amountDrUsd",
  255. type: "sum",
  256. decimals: 2
  257. }, {
  258. name: "amountCrUsd",
  259. type: "sum",
  260. decimals: 2
  261. }, {
  262. name: "amountUsdBlc",
  263. type: "sum",
  264. decimals: 2
  265. }],
  266. column: [
  267. {
  268. label: "凭证号",
  269. prop: "voucherNo",
  270. overHidden: true,
  271. },
  272. {
  273. label: "凭证日期",
  274. prop: "voucherDate",
  275. overHidden: true,
  276. },
  277. {
  278. label: "摘要",
  279. prop: "descr",
  280. overHidden: true,
  281. },
  282. {
  283. label: "币种",
  284. prop: "curCode",
  285. hide: true,
  286. type: 'select',
  287. dicData: [
  288. {
  289. label: 'CNY',
  290. value: 'CNY'
  291. }, {
  292. label: 'USD',
  293. value: 'USD'
  294. },
  295. ],
  296. overHidden: true,
  297. },
  298. {
  299. label: "借方金额",
  300. prop: "amountDr",
  301. width: '100',
  302. overHidden: true,
  303. },
  304. {
  305. label: "贷方金额",
  306. prop: "amountCr",
  307. width: '100',
  308. overHidden: true,
  309. },
  310. {
  311. label: "本期余额",
  312. prop: "amountBlc",
  313. overHidden: true,
  314. },
  315. {
  316. label: "本期外币借方金额",
  317. prop: "amountDrUsd",
  318. overHidden: true,
  319. hide: false,
  320. width: 120,
  321. },
  322. {
  323. label: "本期外币贷方金额",
  324. prop: "amountCrUsd",
  325. overHidden: true,
  326. hide: false,
  327. width: 120,
  328. },
  329. {
  330. label: "本期外币期初余额",
  331. prop: "amountUsdBlc",
  332. overHidden: true,
  333. hide: false,
  334. width: 120,
  335. },
  336. {
  337. label: "方向",
  338. prop: "dc",
  339. type: 'select',
  340. dicData: [
  341. {
  342. label: '借方',
  343. value: 'D'
  344. }, {
  345. label: '贷方',
  346. value: 'C'
  347. },
  348. ],
  349. overHidden: true,
  350. },
  351. ]
  352. },
  353. dataList: []
  354. };
  355. },
  356. watch: {
  357. "query.monthDate": {
  358. handler(newVla, oldVal) {
  359. if (newVla && newVla.length > 0) {
  360. this.query.startYear = newVla[0]
  361. this.query.endYear = newVla[1]
  362. } else {
  363. this.query.startYear = null
  364. this.query.endYear = null
  365. }
  366. },
  367. deep: false, // 深度监听
  368. immediate: false // 第一次改变就执行
  369. },
  370. "query.checkbox": {
  371. handler(newVla, oldVal) {
  372. this.resetData()
  373. if (newVla.filter(e => e == 'foreignCurrency') && newVla.filter(e => e == 'foreignCurrency').length) {
  374. this.findObject(this.option.column, "amountDrUsd").hide = false;
  375. this.findObject(this.option.column, "amountCrUsd").hide = false;
  376. this.findObject(this.option.column, "amountUsdBlc").hide = false;
  377. } else {
  378. this.findObject(this.option.column, "amountDrUsd").hide = true;
  379. this.findObject(this.option.column, "amountCrUsd").hide = true;
  380. this.findObject(this.option.column, "amountUsdBlc").hide = true;
  381. }
  382. if (newVla.filter(e => e == 'total') && newVla.filter(e => e == 'total').length) {
  383. this.option.showSummary = true
  384. } else {
  385. this.option.showSummary = false
  386. }
  387. this.$refs.crud.refreshTable();
  388. },
  389. deep: false, // 深度监听
  390. immediate: false // 第一次改变就执行
  391. },
  392. "query.accList": {
  393. handler(newVla, oldVal) {
  394. this.resetData()
  395. if (newVla && newVla.length) {
  396. this.query.accIds = newVla.join(',')
  397. } else {
  398. this.query.accIds = null
  399. }
  400. },
  401. deep: false, // 深度监听
  402. immediate: false // 第一次改变就执行
  403. },
  404. "query.auxiliaryAccounting": {
  405. handler(newVla, oldVal) {
  406. if (newVla == 1) {
  407. this.findObject(this.optionForm2.column, "type").display = true;
  408. } else {
  409. this.findObject(this.optionForm2.column, "type").display = false;
  410. this.query.type = null
  411. this.query.corpList = []
  412. this.corpDic = []
  413. }
  414. },
  415. deep: false, // 深度监听
  416. immediate: false // 第一次改变就执行
  417. },
  418. "query.type": {
  419. handler(newVla, oldVal) {
  420. if (newVla) {
  421. this.query.corpList = []
  422. this.corpDic = []
  423. getAllList({ type: newVla }).then(res => {
  424. this.corpDic = res.data.data
  425. })
  426. } else {
  427. this.query.corpList = []
  428. this.corpDic = []
  429. }
  430. },
  431. deep: false, // 深度监听
  432. immediate: false // 第一次改变就执行
  433. },
  434. "query.corpList": {
  435. handler(newVla, oldVal) {
  436. if (newVla && newVla.length) {
  437. this.query.corpIds = newVla.join(',')
  438. } else {
  439. this.query.corpIds = null
  440. }
  441. },
  442. deep: false, // 深度监听
  443. immediate: false // 第一次改变就执行
  444. },
  445. // "searchShow": {
  446. // handler(newVla, oldVal) {
  447. // if (newVla) {
  448. // this.option.height = this.option.height - 149;
  449. // } else {
  450. // this.option.height = this.option.height + 149;
  451. // }
  452. // this.$refs.crud.getTableHeight();
  453. // },
  454. // deep: false, // 深度监听
  455. // immediate: false // 第一次改变就执行
  456. // },
  457. },
  458. created() {
  459. this.option.height = window.innerHeight - 360;
  460. },
  461. activated() {
  462. if (this.$route.query.accId) {
  463. setTimeout(() => {
  464. if (!this.$store.getters.subLedgerStatus) {
  465. this.$store.commit("IN_SUBLED_DETAIL");
  466. this.query.accList = this.$route.query.accId ? this.$route.query.accId.split(',') : []
  467. this.serach()
  468. }
  469. }, 200);
  470. }
  471. },
  472. methods: {
  473. toJump(row) {
  474. if (this.$store.getters.voucherStatus) {
  475. this.$alert("财务凭证页面已存在,请关闭财务凭证再进行操作", "温馨提示", {
  476. confirmButtonText: "确定",
  477. type: 'warning',
  478. callback: action => {
  479. }
  480. });
  481. } else {
  482. this.$router.push({
  483. path: `/iosBasicData/finvouchers/index`,
  484. query: {
  485. id: row.voucherId
  486. },
  487. });
  488. }
  489. },
  490. showHight() {
  491. // this.$refs.crud.getTableHeight();
  492. },
  493. nodeClick(data) {
  494. this.getList(data)
  495. },
  496. //初始入账
  497. inItial() {
  498. const loading = this.$loading({
  499. lock: true,
  500. text: '加载中',
  501. spinner: 'el-icon-loading',
  502. background: 'rgba(255,255,255,0.7)'
  503. });
  504. this.$confirm('是否继续初始入账?', '提示', {
  505. confirmButtonText: '确定',
  506. cancelButtonText: '取消',
  507. type: 'warning'
  508. }).then(() => {
  509. initialization().then(res => {
  510. this.$message({
  511. type: 'success',
  512. message: '初始入账成功!'
  513. });
  514. this.getTreelist()
  515. })
  516. }).finally(() => {
  517. loading.close();
  518. });
  519. },
  520. //重置特殊值
  521. resetData() {
  522. this.query.foreignCurrency = this.query.checkbox.find(e => e == 'foreignCurrency') ? 1 : 0
  523. this.query.lastLevelItem = this.query.checkbox.find(e => e == 'lastLevelItem') ? 1 : 0
  524. this.query.blcNotZero = this.query.checkbox.find(e => e == 'blcNotZero') ? 1 : 0
  525. this.query.noAmountIncurred = this.query.checkbox.find(e => e == 'noAmountIncurred') ? 1 : 0
  526. this.query.doNotDisplayYear = this.query.checkbox.find(e => e == 'doNotDisplayYearc') ? 1 : 0
  527. this.query.oppositeAcc = this.query.checkbox.find(e => e == 'oppositeAcc') ? 1 : 0
  528. this.query.total = this.query.checkbox.find(e => e == 'total') ? 1 : 0
  529. },
  530. //导出
  531. outExport() {
  532. this.$confirm('是否导出当前所有数据?', '提示', {
  533. confirmButtonText: '确定',
  534. cancelButtonText: '取消',
  535. type: 'warning'
  536. }).then(() => {
  537. const routeData = this.$router.resolve({
  538. path: '/api/blade-los/accounts/accountsDetailsListExport', //跳转目标窗口的地址
  539. query: {
  540. 'Blade-Auth': getToken(),
  541. ...this.outExportQuery //括号内是要传递给新窗口的参数
  542. }
  543. })
  544. window.open(routeData.href.slice(1, routeData.href.length));
  545. })
  546. },
  547. serach() {
  548. if (!this.query.startYear && !this.query.endYear) {
  549. return this.$message.error("请选择期间!");
  550. }
  551. this.searchShow = false
  552. this.getTreelist()
  553. },
  554. reset() {
  555. this.query = this.$options.data().query
  556. this.dataList = []
  557. },
  558. getTreelist() {
  559. const loading = this.$loading({
  560. lock: true,
  561. text: '加载中',
  562. spinner: 'el-icon-loading',
  563. background: 'rgba(255,255,255,0.7)'
  564. });
  565. getTreelist(this.query).then(res => {
  566. this.treeData = res.data.data
  567. if (res.data.data && res.data.data.length > 0) {
  568. this.$nextTick(() => {
  569. this.$refs.tree.setCurrentKey(res.data.data[0].id)
  570. this.getList(res.data.data[0])
  571. })
  572. }
  573. }).finally(() => {
  574. loading.close();
  575. });
  576. },
  577. getList(data) {
  578. let obj = {}
  579. obj = {
  580. ...this.query,
  581. accIds: data.id,
  582. accType: data.type,
  583. corpId: data.corpId,
  584. deptId: data.deptId,
  585. emplId: data.emplId
  586. }
  587. this.outExportQuery = obj
  588. const loading = this.$loading({
  589. lock: true,
  590. text: '加载中',
  591. spinner: 'el-icon-loading',
  592. background: 'rgba(255,255,255,0.7)'
  593. });
  594. // console.log("当前回显选中:" + this.$refs.tree.getCurrentKey())
  595. getList(obj).then(res => {
  596. this.dataList = res.data.data
  597. }).finally(() => {
  598. this.$refs.crud.refreshTable();
  599. loading.close();
  600. });
  601. },
  602. //自定义列保存
  603. async saveColumnTwo(ref, option, optionBack, code) {
  604. /**
  605. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  606. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  607. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  608. */
  609. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  610. if (inSave) {
  611. this.$message.success("保存成功");
  612. //关闭窗口
  613. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  614. }
  615. },
  616. //自定义列重置
  617. async resetColumnTwo(ref, option, optionBack, code) {
  618. this[option] = this[optionBack];
  619. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  620. if (inSave) {
  621. this.$message.success("重置成功");
  622. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  623. }
  624. },
  625. // 更改表格颜色
  626. headerClassName(tab) {
  627. //颜色间隔
  628. let back = ""
  629. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  630. if (tab.columnIndex % 2 === 0) {
  631. back = "back-one"
  632. } else if (tab.columnIndex % 2 === 1) {
  633. back = "back-two"
  634. }
  635. }
  636. return back;
  637. },
  638. }
  639. };
  640. </script>
  641. <style scoped>
  642. ::v-deep#out-table .back-one {
  643. background: #ecf5ff !important;
  644. text-align: center;
  645. }
  646. ::v-deep#out-table .back-two {
  647. background: #ecf5ff !important;
  648. text-align: center;
  649. }
  650. .treeStyle {
  651. height: 56vh;
  652. margin-bottom: 60px;
  653. /* overflow-y: scroll; */
  654. }
  655. .bigTreeStyle {
  656. height: 72vh;
  657. margin-bottom: 60px;
  658. }
  659. </style>