index.vue 24 KB

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