index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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', 323)"
  24. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 323)"
  25. @on-load="onLoad"
  26. @tree-load="treeLoad" >
  27. <template slot="menuLeft">
  28. <el-button type="primary"
  29. size="small"
  30. icon="el-icon-plus"
  31. @click="addAccountsfun">新 增
  32. </el-button>
  33. <el-button type="danger"
  34. size="small"
  35. icon="el-icon-delete"
  36. plain
  37. @click="handleDelete">删 除
  38. </el-button>
  39. <div style="margin-top: 10px">
  40. <el-tabs type="card" v-model="query.property" @tab-click="handleClick">
  41. <el-tab-pane :label="item.dictValue" :name="item.dictKey"
  42. v-for="item in propertyData" :key="item.dictKey">
  43. <span slot="label">{{item.dictValue}}</span>
  44. </el-tab-pane>
  45. </el-tabs>
  46. </div>
  47. </template>
  48. <template slot="menu" slot-scope="{ row, index }">
  49. <el-button size="small" icon="el-icon-edit" type="text" @click="editfun(row,index)">编辑</el-button>
  50. <!--<el-button v-if="row.isItem == 1" size="small" type="text" @click="editOpeningfun(row,index)">核算期初</el-button>-->
  51. <el-button size="small" type="text" @click="addChildfun(row,index)">添加子项</el-button>
  52. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)">删 除</el-button>
  53. </template>
  54. <template slot="code" slot-scope="{ row }">
  55. <span style="color: #1e9fff" @click="editDetailsfun(row.id)">{{row.code}}</span>
  56. </template>
  57. <template slot="isItem" slot-scope="{ row }">
  58. <span class="pointerClick" v-if="row.isItem == 1" @click="editOpeningfun(row)" >是</span>
  59. <span v-else >否</span>
  60. </template>
  61. <template slot="quantityOpenDr" slot-scope="{ row }">
  62. <el-input style="width: 100%;" v-model="row.quantityOpenDr"
  63. v-if="row.edit" type="number" min="0"
  64. size="mini" autocomplete="off" clearable
  65. placeholder="请输入期初借方数量" >
  66. </el-input>
  67. <span v-else >{{row.quantityOpenDr}}</span>
  68. </template>
  69. </avue-crud>
  70. </basic-container>
  71. <!--辅助核算-->
  72. <el-dialog
  73. title="账户管理"
  74. append-to-body
  75. :visible.sync="accountsVisible"
  76. class="el-dialogDeep"
  77. width="60%"
  78. :before-close="handleClose">
  79. <accounts-dialog ref="accountsDialog" :form="form"></accounts-dialog>
  80. <span slot="footer" class="dialog-footer">
  81. <el-button @click="accountsVisible = false">取 消</el-button>
  82. <el-button type="primary" @click="bigSavefun">确 定</el-button>
  83. </span>
  84. </el-dialog>
  85. <!--从表数据-->
  86. <el-dialog
  87. title="辅助核算期初"
  88. append-to-body
  89. :visible.sync="sopenblcVisible"
  90. class="el-dialogDeep"
  91. width="70%"
  92. :before-close="handleClose">
  93. <accitemsopenblc :form="form" ></accitemsopenblc>
  94. <span slot="footer" class="dialog-footer">
  95. <el-button @click="sopenblcVisible = false">取 消</el-button>
  96. <el-button type="primary" @click="openingCalculatefun">保 存</el-button>
  97. </span>
  98. </el-dialog>
  99. <!--<accountsDetails v-if="!isShow" @goBack="goBack"></accountsDetails>-->
  100. </div>
  101. </template>
  102. <script>
  103. import {accountsList, accountsDetail, accountsSubmit, accountsRemove} from "@/api/iosBasicData/accounts";
  104. import {mapGetters} from "vuex";
  105. import accountsDialog from "@/views/iosBasicData/accounts/assembly/accountsDialog.vue";
  106. import accountsDetails from "@/views/iosBasicData/accounts/accountsDetails.vue";
  107. import {getWorkDicts} from "@/api/system/dictbiz";
  108. import accitemsopenblc from "@/views/iosBasicData/accounts/assembly/accitemsopenblc.vue";
  109. export default {
  110. data() {
  111. return {
  112. accountsVisible:false, // 添加编辑弹窗
  113. sopenblcVisible:false, // 从表数据
  114. isShow:true,
  115. form: {},
  116. query: {
  117. property:'0',
  118. },
  119. loading: true,
  120. page: {
  121. pageSize: 10,
  122. currentPage: 1,
  123. total: 0
  124. },
  125. selectionList: [],
  126. option:{},
  127. optionBack: {
  128. height:'auto',
  129. calcHeight: 30,
  130. tip: false,
  131. searchShow: true,
  132. searchMenuSpan: 6,
  133. border: true,
  134. index: true,
  135. viewBtn: true,
  136. selection: true,
  137. dialogClickModal: false,
  138. menuWidth:"200",
  139. lazy: true,
  140. tree: true,
  141. rowKey:'code',
  142. rowParentKey:'children',
  143. simplePage: true,
  144. searchIcon:true,
  145. searchIndex:2,
  146. column: [
  147. {
  148. label: "科目代码",
  149. prop: "code",
  150. search: true,
  151. width: "80",
  152. overHidden: true,
  153. },
  154. {
  155. label: "中文名称",
  156. prop: "cnName",
  157. search: true,
  158. width: "80",
  159. overHidden: true,
  160. },
  161. {
  162. label: "方向",
  163. prop: "dc",
  164. overHidden: true,
  165. type:'select',
  166. search: true,
  167. width: "50",
  168. dicData:[
  169. {
  170. label:'借方',
  171. value:'D',
  172. },
  173. {
  174. label:'贷方',
  175. value:'C',
  176. }
  177. ]
  178. },
  179. {
  180. label: "外币",
  181. prop: "isForeign",
  182. overHidden: true,
  183. search: true,
  184. type:'select',
  185. width: "35",
  186. dicData:[
  187. {
  188. label:'否',
  189. value:0,
  190. },
  191. {
  192. label:'是',
  193. value:1,
  194. }
  195. ]
  196. },
  197. {
  198. label: "币种",
  199. prop: "curCode",
  200. overHidden: true,
  201. search: true,
  202. width: "50",
  203. },
  204. {
  205. label: "数量",
  206. prop: "isQuantity",
  207. overHidden: true,
  208. search: true,
  209. type:'select',
  210. width: "35",
  211. dicData:[
  212. {
  213. label:'否',
  214. value:0,
  215. },
  216. {
  217. label:'是',
  218. value:1,
  219. }
  220. ]
  221. },
  222. {
  223. label: "客户",
  224. prop: "isCorp",
  225. overHidden: true,
  226. search: true,
  227. type:'select',
  228. width: "35",
  229. dicData:[
  230. {
  231. label:'否',
  232. value:0,
  233. },
  234. {
  235. label:'是',
  236. value:1,
  237. }
  238. ]
  239. },
  240. {
  241. label: "部门",
  242. prop: "isDept",
  243. overHidden: true,
  244. search: true,
  245. type:'select',
  246. width: "35",
  247. dicData:[
  248. {
  249. label:'否',
  250. value:0,
  251. },
  252. {
  253. label:'是',
  254. value:1,
  255. }
  256. ]
  257. },
  258. {
  259. label: "职员",
  260. prop: "isEmpl",
  261. overHidden: true,
  262. search: true,
  263. type:'select',
  264. width: "35",
  265. dicData:[
  266. {
  267. label:'否',
  268. value:0,
  269. },
  270. {
  271. label:'是',
  272. value:1,
  273. }
  274. ]
  275. },
  276. {
  277. label: "项目",
  278. prop: "isItem",
  279. overHidden: true,
  280. search: true,
  281. type:'select',
  282. width: "35",
  283. dicData:[
  284. {
  285. label:'否',
  286. value:0,
  287. },
  288. {
  289. label:'是',
  290. value:1,
  291. }
  292. ]
  293. },
  294. {
  295. label: "上级科目",
  296. prop: "parentCode",
  297. overHidden: true,
  298. },
  299. // {
  300. // label: "children",
  301. // prop: "children",
  302. // hasChildren:true,
  303. // },
  304. {
  305. label: "期初数量借方",
  306. prop: "quantityOpenDr",
  307. overHidden: true,
  308. },
  309. {
  310. label: "期初本币借方金额",
  311. prop: "amountOpenDr",
  312. overHidden: true,
  313. },
  314. {
  315. label: "期初外币借方金额",
  316. prop: "amountOpenDrUsd",
  317. overHidden: true,
  318. },
  319. {
  320. label: "期初数量贷方",
  321. prop: "quantityOpenCr",
  322. overHidden: true,
  323. },
  324. {
  325. label: "期初本币贷方金额",
  326. prop: "amountOpenCr",
  327. overHidden: true,
  328. },
  329. {
  330. label: "期初外币贷方金额",
  331. prop: "amountOpenCrUsd",
  332. overHidden: true,
  333. },
  334. {
  335. label: "期初数量余额",
  336. prop: "quantityOpenUsdBlc",
  337. overHidden: true,
  338. },
  339. {
  340. label: "期初本币余额",
  341. prop: "amountOpenBlc",
  342. overHidden: true,
  343. },
  344. {
  345. label: "期初外币余额",
  346. prop: "amountOpenUsdBlc",
  347. overHidden: true,
  348. },
  349. {
  350. label: "本期数量借方",
  351. prop: "quantityDr",
  352. overHidden: true,
  353. },
  354. {
  355. label: "本期本币借方金额",
  356. prop: "amountDr",
  357. overHidden: true,
  358. },
  359. {
  360. label: "本期外币借方金额",
  361. prop: "amountDrUsd",
  362. overHidden: true,
  363. },
  364. {
  365. label: "本期数量贷方",
  366. prop: "quantityCr",
  367. overHidden: true,
  368. },
  369. {
  370. label: "本期本币贷方金额",
  371. prop: "amountCr",
  372. overHidden: true,
  373. },
  374. {
  375. label: "本期外币贷方金额",
  376. prop: "amountCrUsd",
  377. overHidden: true,
  378. },
  379. {
  380. label: "本期数量余额",
  381. prop: "quantityUsdBlc",
  382. overHidden: true,
  383. },
  384. {
  385. label: "本期本币余额",
  386. prop: "amountBlc",
  387. overHidden: true,
  388. },
  389. {
  390. label: "本期外币余额",
  391. prop: "amountUsdBlc",
  392. overHidden: true,
  393. },
  394. {
  395. label: "备注",
  396. prop: "remarks",
  397. overHidden: true,
  398. },
  399. ]
  400. },
  401. data: [],
  402. propertyData:[], // 科目类别
  403. };
  404. },
  405. components:{accitemsopenblc, accountsDialog,accountsDetails},
  406. computed: {
  407. ...mapGetters(["permission"]),
  408. permissionList() {
  409. return {
  410. addBtn: this.vaildData(this.permission.accounts_add, false),
  411. viewBtn: this.vaildData(this.permission.accounts_view, false),
  412. delBtn: this.vaildData(this.permission.accounts_delete, false),
  413. editBtn: this.vaildData(this.permission.accounts_edit, false)
  414. };
  415. },
  416. ids() {
  417. let ids = [];
  418. this.selectionList.forEach(ele => {
  419. ids.push(ele.id);
  420. });
  421. return ids.join(",");
  422. }
  423. },
  424. async created() {
  425. this.option = await this.getColumnData(this.getColumnName(323), this.optionBack);
  426. this.propertyWorkDictsfun()
  427. },
  428. methods: {
  429. // 辅助核算期初确认
  430. openingCalculatefun(){
  431. this.accountsSubmitfun()
  432. this.sopenblcVisible = false
  433. },
  434. // 核算项目数据
  435. propertyWorkDictsfun(cnName){
  436. getWorkDicts('itemClassify_los').then((res) => {
  437. this.propertyData = res.data.data
  438. });
  439. },
  440. // 添加
  441. addAccountsfun(){
  442. this.form = {}
  443. this.accountsVisible = true
  444. // this.isShow = false
  445. },
  446. // 编辑
  447. editDetailsfun(id){
  448. // 详情接口
  449. accountsDetail(id).then(res => {
  450. this.form = res.data.data;
  451. this.$set(this.form,'property',this.form.property + '')
  452. });
  453. this.accountsVisible = true
  454. },
  455. // 大保存
  456. bigSavefun(){
  457. let sum = '请填写'
  458. if (!this.form.code) {
  459. sum += '科目编码 '
  460. }
  461. if (!this.form.cnName) {
  462. sum += '科目名称 '
  463. }
  464. if (!this.form.dc) {
  465. sum += '方向 '
  466. }
  467. if (sum != '请填写') {
  468. this.$alert(sum, '提示', {
  469. confirmButtonText: '确定',
  470. });
  471. return
  472. }
  473. this.accountsSubmitfun()
  474. },
  475. // 保存
  476. accountsSubmitfun(){
  477. accountsSubmit(this.form).then(res=>{
  478. this.$message.success("操作成功!")
  479. this.accountsVisible = false
  480. this.onLoad(this.page, this.query)
  481. })
  482. },
  483. // 弹窗点击差号
  484. handleClose(done) {
  485. this.$confirm('确认关闭?')
  486. .then(_ => {
  487. done();
  488. })
  489. .catch(_ => {});
  490. },
  491. // 添加
  492. rowSave(row, done, loading) {
  493. accountsSubmit(row).then(() => {
  494. this.onLoad(this.page);
  495. this.$message({
  496. type: "success",
  497. message: "操作成功!"
  498. });
  499. done();
  500. }, error => {
  501. loading();
  502. window.console.log(error);
  503. });
  504. },
  505. // 编辑操作
  506. rowUpdate(row, index, done, loading) {
  507. accountsSubmit(row).then(() => {
  508. this.onLoad(this.page);
  509. this.$message({
  510. type: "success",
  511. message: "操作成功!"
  512. });
  513. done();
  514. }, error => {
  515. loading();
  516. });
  517. },
  518. // 删除
  519. rowDel(row) {
  520. this.$confirm("确定将选择数据删除?", {
  521. confirmButtonText: "确定",
  522. cancelButtonText: "取消",
  523. type: "warning"
  524. })
  525. .then(() => {
  526. return accountsRemove(row.id);
  527. })
  528. .then(() => {
  529. this.onLoad(this.page);
  530. this.$message({
  531. type: "success",
  532. message: "操作成功!"
  533. });
  534. });
  535. },
  536. // 编辑
  537. editfun(row){
  538. accountsDetail(row.id).then(res => {
  539. this.form = res.data.data;
  540. this.$set(this.form,'property',this.form.property + '')
  541. });
  542. this.accountsVisible = true
  543. this.$nextTick(()=>{
  544. this.$refs.accountsDialog.propertyWorkDictsfun()
  545. })
  546. },
  547. // 添加子项
  548. addChildfun(row){
  549. this.form = {
  550. parentId:row.id,
  551. parentCode:row.code,
  552. parentCnName:row.cnName,
  553. }
  554. this.accountsVisible = true
  555. },
  556. // 核算期初
  557. editOpeningfun(row){
  558. accountsDetail(row.id).then(res => {
  559. this.form = res.data.data;
  560. });
  561. this.sopenblcVisible = true
  562. },
  563. // 匹配删除
  564. handleDelete() {
  565. if (this.selectionList.length === 0) {
  566. this.$message.warning("请选择至少一条数据");
  567. return;
  568. }
  569. this.$confirm("确定将选择数据删除?", {
  570. confirmButtonText: "确定",
  571. cancelButtonText: "取消",
  572. type: "warning"
  573. })
  574. .then(() => {
  575. return accountsRemove(this.ids);
  576. })
  577. .then(() => {
  578. this.onLoad(this.page);
  579. this.$message({
  580. type: "success",
  581. message: "操作成功!"
  582. });
  583. this.$refs.crud.toggleSelection();
  584. });
  585. },
  586. // 打开弹窗调用详情接口
  587. beforeOpen(done, type) {
  588. if (["edit", "view"].includes(type)) {
  589. accountsDetail(this.form.id).then(res => {
  590. this.form = res.data.data;
  591. });
  592. }
  593. done();
  594. },
  595. searchReset() {
  596. this.query = {};
  597. this.onLoad(this.page);
  598. },
  599. searchChange(params, done) {
  600. this.query = params;
  601. this.page.currentPage = 1;
  602. this.onLoad(this.page, params);
  603. done();
  604. },
  605. selectionChange(list) {
  606. this.selectionList = list;
  607. },
  608. selectionClear() {
  609. this.selectionList = [];
  610. this.$refs.crud.toggleSelection();
  611. },
  612. currentChange(currentPage){
  613. this.page.currentPage = currentPage;
  614. },
  615. sizeChange(pageSize){
  616. this.page.pageSize = pageSize;
  617. },
  618. refreshChange() {
  619. this.onLoad(this.page, this.query);
  620. },
  621. onLoad(page, params = {}) {
  622. this.loading = true;
  623. accountsList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  624. const data = res.data.data;
  625. this.page.total = data.total;
  626. this.data = data.records;
  627. this.loading = false;
  628. this.selectionClear();
  629. });
  630. },
  631. // 懒加载查询子节点数据
  632. treeLoad(row, treeNode, resolve){
  633. console.log(row,688)
  634. console.log(row,treeNode,resolve,673)
  635. },
  636. // 详情的返回列表
  637. goBack() {
  638. // 初始化数据
  639. if (JSON.stringify(this.$route.query) != "{}") {
  640. this.$router.$avueRouter.closeTag();
  641. this.$router.push({
  642. path: "/iosBasicData/accounts/index"
  643. });
  644. }
  645. this.isShow = true;
  646. this.onLoad(this.page, this.search);
  647. },
  648. //自定义列保存
  649. async saveColumnTwo(ref, option, optionBack, code) {
  650. /**
  651. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  652. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  653. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  654. */
  655. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  656. if (inSave) {
  657. this.$message.success("保存成功");
  658. //关闭窗口
  659. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  660. }
  661. },
  662. //自定义列重置
  663. async resetColumnTwo(ref, option, optionBack, code) {
  664. this[option] = this[optionBack];
  665. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  666. if (inSave) {
  667. this.$message.success("重置成功");
  668. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  669. }
  670. },
  671. // 更改表格颜色
  672. headerClassName(tab){
  673. //颜色间隔
  674. let back = ""
  675. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  676. if (tab.columnIndex % 2 === 0) {
  677. back = "back-one"
  678. } else if (tab.columnIndex % 2 === 1) {
  679. back = "back-two"
  680. }
  681. }
  682. return back;
  683. },
  684. }
  685. };
  686. </script>
  687. <style scoped>
  688. ::v-deep#out-table .back-one {
  689. background: #ecf5ff !important;
  690. text-align: center;
  691. }
  692. ::v-deep#out-table .back-two {
  693. background: #ecf5ff !important;
  694. text-align: center;
  695. }
  696. .pointerClick {
  697. cursor:pointer;
  698. color: #1e9fff;
  699. }
  700. </style>