index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="5">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree :option="treeOption" :data="feesTypeData" @node-click="nodeClick">
  8. <template slot="addBtn">
  9. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  10. <i
  11. class="el-icon-setting"
  12. style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"
  13. @click="corpTypeVisible = true"
  14. ></i>
  15. </el-tooltip>
  16. </template>
  17. </avue-tree>
  18. </basic-container>
  19. </el-scrollbar>
  20. </el-col>
  21. <el-col :span="19">
  22. <basic-container>
  23. <avue-crud
  24. :option="option"
  25. :table-loading="loading"
  26. :data="data"
  27. :page.sync="page"
  28. :search="search"
  29. :permission="permissionList"
  30. :before-open="beforeOpen"
  31. v-model="form"
  32. ref="crud"
  33. id="out-table"
  34. :header-cell-class-name="headerClassName"
  35. @row-update="rowUpdate"
  36. @row-save="rowSave"
  37. @row-del="rowDel"
  38. @search-change="searchChange"
  39. @search-reset="searchReset"
  40. @selection-change="selectionChange"
  41. @current-change="currentChange"
  42. @size-change="sizeChange"
  43. @refresh-change="refreshChange"
  44. @on-load="onLoad"
  45. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 328)"
  46. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 328)"
  47. >
  48. <template slot="menuLeft">
  49. <el-button type="primary" size="small" @click="initializationfun">初始化 </el-button>
  50. <!--<el-button type="danger"-->
  51. <!-- size="small"-->
  52. <!-- icon="el-icon-delete"-->
  53. <!-- plain-->
  54. <!-- @click="handleDelete">删 除-->
  55. <!--</el-button>-->
  56. </template>
  57. <!--<template slot-scope="{ row }" slot="currencyCodeForm" >-->
  58. <!-- <search-query :datalist="currencyData"-->
  59. <!-- :selectValue="form.currencyCode"-->
  60. <!-- :clearable="true"-->
  61. <!-- :buttonIf="false"-->
  62. <!-- placeholder="请选择币种"-->
  63. <!-- :forParameter="{key:'id',label:'code',value:'code'}"-->
  64. <!-- @remoteMethod="bcurrencyGetExratefun"-->
  65. <!-- @corpChange="corpChange($event,'currencyCode')"-->
  66. <!-- @corpFocus="bcurrencyGetExratefun" >-->
  67. <!-- </search-query>-->
  68. <!--</template>-->
  69. <template slot="subjectCodeForm" slot-scope="{ row }">
  70. <search-query
  71. :datalist="subjectData"
  72. :selectValue="form.subjectCode"
  73. :filterable="true"
  74. :clearable="true"
  75. :remote="true"
  76. :buttonIf="false"
  77. :desc="true"
  78. :forParameter="{ key: 'id', label: 'code', value: 'code', desc: 'fullName' }"
  79. @corpFocus="accountsListfun"
  80. @remoteMethod="accountsListfun"
  81. @corpChange="corpChange($event, 'subjectCode')"
  82. >
  83. </search-query>
  84. </template>
  85. </avue-crud>
  86. </basic-container>
  87. </el-col>
  88. </el-row>
  89. <!--类别弹窗-->
  90. <el-dialog title="类别" :visible.sync="corpTypeVisible" append-to-body width="70%" :before-close="corpTypeClose">
  91. <div>
  92. <bbusinesstype></bbusinesstype>
  93. </div>
  94. <span slot="footer" class="dialog-footer">
  95. <el-button @click="corpTypeVisible = false">取 消</el-button>
  96. <el-button type="primary" @click="corpTypeVisible = false">确 定</el-button>
  97. </span>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import bvouchertype from "@/views/iosBasicData/bvouchertype/index.vue";
  103. import { bvouchertypelist } from "@/api/bvouchertype/index";
  104. import { mapGetters } from "vuex";
  105. import {
  106. vouchertemplatelist,
  107. vouchertemplateDetail,
  108. vouchertemplateSubmit,
  109. vouchertemplateRemove,
  110. initialization
  111. } from "@/api/vouchertemplate/index";
  112. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  113. import { bcurrencyGetExrate } from "@/api/iosBasicData/rateManagement";
  114. import { getCurrentDate } from "@/util/date";
  115. import { accountsList } from "@/api/iosBasicData/accounts";
  116. import { bbusinesstypeList } from "@/api/iosBasicData/bbusinesstype";
  117. import bbusinesstype from "@/views/iosBasicData/bbusinesstype/index.vue";
  118. export default {
  119. name: "凭证模板(F)",
  120. components: { SearchQuery, bvouchertype, bbusinesstype },
  121. data() {
  122. return {
  123. treeOption: {
  124. nodeKey: "id",
  125. // lazy: true,
  126. addBtn: false,
  127. menu: false,
  128. size: "small",
  129. props: {
  130. labelText: "标题",
  131. label: "cnName",
  132. value: "value",
  133. children: "children"
  134. }
  135. },
  136. feesTypeData: [],
  137. corpTypeVisible: false,
  138. form: {
  139. // currencyCode:'RMB', // 币种代码
  140. },
  141. currencyData: [], // 币种数据
  142. subjectData: [], // 科目数据
  143. query: {},
  144. loading: true,
  145. page: {
  146. pageSize: 20,
  147. currentPage: 1,
  148. total: 0,
  149. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  150. },
  151. search: {},
  152. data: [],
  153. option: {},
  154. optionBack: {
  155. height: "auto",
  156. calcHeight: 30,
  157. tip: false,
  158. searchShow: true,
  159. searchMenuSpan: 6,
  160. border: true,
  161. index: true,
  162. viewBtn: true,
  163. selection: true,
  164. dialogClickModal: false,
  165. menuWidth: "100",
  166. column: [
  167. {
  168. label: "币别代码",
  169. prop: "currencyCode",
  170. // formslot:true,
  171. overHidden: true,
  172. display: false,
  173. disabled: true
  174. },
  175. {
  176. label: "币别名称",
  177. prop: "currencyName",
  178. overHidden: true,
  179. display: false,
  180. disabled: true
  181. },
  182. {
  183. label: "凭证类型",
  184. prop: "voucherType",
  185. overHidden: true,
  186. display: false,
  187. disabled: true
  188. },
  189. {
  190. label: "凭证名称",
  191. prop: "voucherName",
  192. overHidden: true
  193. },
  194. {
  195. label: "类型",
  196. prop: "dcType",
  197. overHidden: true,
  198. display: false,
  199. disabled: true
  200. },
  201. {
  202. label: "科目代码",
  203. prop: "subjectCode",
  204. formslot: true,
  205. overHidden: true
  206. },
  207. {
  208. label: "科目名称",
  209. prop: "subjectName",
  210. overHidden: true,
  211. disabled: true
  212. },
  213. {
  214. label: "金额方向",
  215. prop: "amountDirection",
  216. type: "select",
  217. dicData: [
  218. {
  219. label: "借",
  220. value: "D"
  221. },
  222. {
  223. label: "贷",
  224. value: "C"
  225. }
  226. ],
  227. overHidden: true
  228. },
  229. {
  230. label: "静态值",
  231. prop: "staticValue",
  232. overHidden: true
  233. },
  234. {
  235. label: "状态",
  236. prop: "status",
  237. type: "select",
  238. overHidden: true,
  239. dicData: [
  240. {
  241. label: "启用",
  242. value: 0
  243. },
  244. {
  245. label: "停用",
  246. value: 1
  247. }
  248. ],
  249. value: 0
  250. },
  251. {
  252. label: "附加公式",
  253. prop: "additionalFormulas",
  254. type: "textarea",
  255. minRows: 2,
  256. span: 12,
  257. overHidden: true
  258. },
  259. {
  260. label: "业务类型",
  261. prop: "businessType",
  262. overHidden: true,
  263. display: false
  264. },
  265. {
  266. label: "创建人",
  267. prop: "createUserName",
  268. overHidden: true,
  269. display: false
  270. },
  271. {
  272. label: "创建部门",
  273. prop: "createDeptName",
  274. overHidden: true,
  275. display: false
  276. },
  277. {
  278. label: "创建时间",
  279. prop: "createTime",
  280. overHidden: true,
  281. display: false
  282. },
  283. {
  284. label: "修改人",
  285. prop: "updateUserName",
  286. overHidden: true,
  287. display: false
  288. },
  289. {
  290. label: "修改时间",
  291. prop: "updateTime",
  292. overHidden: true,
  293. display: false
  294. },
  295. {
  296. label: "备注",
  297. prop: "remarks",
  298. overHidden: true,
  299. type: "textarea",
  300. minRows: 2,
  301. span: 12
  302. }
  303. ]
  304. }
  305. };
  306. },
  307. computed: {
  308. ...mapGetters(["permission"]),
  309. permissionList() {
  310. return {
  311. addBtn: this.vaildData(this.permission.bvouchertype_add, false),
  312. viewBtn: this.vaildData(this.permission.bvouchertype_view, false),
  313. delBtn: this.vaildData(this.permission.bvouchertype_delete, false)
  314. // editBtn: this.vaildData(this.permission.bvouchertype_edit, false)
  315. };
  316. },
  317. ids() {
  318. let ids = [];
  319. this.selectionList.forEach(ele => {
  320. ids.push(ele.id);
  321. });
  322. return ids.join(",");
  323. }
  324. },
  325. async created() {
  326. this.option = await this.getColumnData(this.getColumnName(328), this.optionBack);
  327. this.bbusinesstypeListfun();
  328. this.accountsListfun(); // 科目
  329. },
  330. methods: {
  331. // 所属币别
  332. corpChange(value, name) {
  333. if (name == "currencyCode") {
  334. for (let item of this.currencyData) {
  335. if (item.code == value) {
  336. this.$set(this.form, "currencyCode", item.code);
  337. this.$set(this.form, "currencyName", item.cnName);
  338. }
  339. }
  340. }
  341. if (name == "subjectCode") {
  342. for (let item of this.subjectData) {
  343. if (item.code == value) {
  344. this.$set(this.form, "subjectCode", item.code);
  345. this.$set(this.form, "subjectName", item.fullName);
  346. }
  347. }
  348. }
  349. },
  350. // 获取币别数据
  351. bcurrencyGetExratefun() {
  352. bcurrencyGetExrate({
  353. date: getCurrentDate(), // 当前日期
  354. dc: "C"
  355. }).then(res => {
  356. this.currencyData = res.data.data;
  357. });
  358. },
  359. // 获取科目类型数据
  360. accountsListfun(code) {
  361. accountsList(1, 10, { code, isDetail: 1 }).then(res => {
  362. this.subjectData = res.data.data.records;
  363. });
  364. },
  365. rowSave(row, done, loading) {
  366. console.log(row, "添加");
  367. vouchertemplateSubmit(row).then(
  368. () => {
  369. this.onLoad(this.page);
  370. this.$message({
  371. type: "success",
  372. message: "操作成功!"
  373. });
  374. done();
  375. },
  376. error => {
  377. loading();
  378. window.console.log(error);
  379. }
  380. );
  381. },
  382. rowUpdate(row, index, done, loading) {
  383. console.log(row, "编辑");
  384. vouchertemplateSubmit(row).then(
  385. () => {
  386. this.onLoad(this.page, this.search);
  387. this.$message({
  388. type: "success",
  389. message: "操作成功!"
  390. });
  391. done();
  392. },
  393. error => {
  394. loading();
  395. console.log(error);
  396. }
  397. );
  398. },
  399. rowDel(row) {
  400. this.$confirm("确定将选择数据删除?", {
  401. confirmButtonText: "确定",
  402. cancelButtonText: "取消",
  403. type: "warning"
  404. })
  405. .then(() => {
  406. return vouchertemplateRemove(row.id);
  407. })
  408. .then(() => {
  409. this.onLoad(this.page);
  410. this.$message({
  411. type: "success",
  412. message: "操作成功!"
  413. });
  414. });
  415. },
  416. handleDelete() {
  417. if (this.selectionList.length === 0) {
  418. this.$message.warning("请选择至少一条数据");
  419. return;
  420. }
  421. this.$confirm("确定将选择数据删除?", {
  422. confirmButtonText: "确定",
  423. cancelButtonText: "取消",
  424. type: "warning"
  425. })
  426. .then(() => {
  427. return vouchertemplateRemove(this.ids);
  428. })
  429. .then(() => {
  430. this.onLoad(this.page);
  431. this.$message({
  432. type: "success",
  433. message: "操作成功!"
  434. });
  435. this.$refs.crud.toggleSelection();
  436. });
  437. },
  438. beforeOpen(done, type) {
  439. console.log(type, 324);
  440. // 如果是添加判断是否选择了左侧类型
  441. if (type == "add") {
  442. if (!this.search.businessTypeId) {
  443. return this.$message.warning("请选择左侧的类型");
  444. }
  445. }
  446. if (["edit", "view"].includes(type)) {
  447. vouchertemplateDetail(this.form.id).then(res => {
  448. this.form = res.data.data;
  449. });
  450. }
  451. done();
  452. },
  453. searchReset() {
  454. this.query = {};
  455. // this.onLoad(this.page);
  456. },
  457. searchChange(params, done) {
  458. this.query = params;
  459. this.page.currentPage = 1;
  460. this.onLoad(this.page, params);
  461. done();
  462. },
  463. selectionChange(list) {
  464. this.selectionList = list;
  465. },
  466. selectionClear() {
  467. this.selectionList = [];
  468. this.$refs.crud.toggleSelection();
  469. },
  470. currentChange(currentPage) {
  471. this.page.currentPage = currentPage;
  472. },
  473. sizeChange(pageSize) {
  474. this.page.pageSize = pageSize;
  475. },
  476. refreshChange() {
  477. this.onLoad(this.page, this.query);
  478. },
  479. onLoad(page, params = {}) {
  480. this.loading = true;
  481. vouchertemplatelist(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  482. const data = res.data.data;
  483. this.page.total = data.total;
  484. this.data = data.records;
  485. this.loading = false;
  486. this.selectionClear();
  487. });
  488. },
  489. // 初始化
  490. initializationfun() {
  491. if (!this.search.businessTypeId) {
  492. return this.$message.warning("请选择左侧的类型");
  493. }
  494. this.$confirm("初始化会清空数据", {
  495. confirmButtonText: "确定",
  496. cancelButtonText: "取消",
  497. type: "warning"
  498. }).then(() => {
  499. initialization({
  500. businessTypeId: this.search.businessTypeId,
  501. businessType: this.search.businessType
  502. }).then(res => {
  503. this.page.currentPage = 1;
  504. this.onLoad(this.page, this.search);
  505. });
  506. });
  507. },
  508. // 左侧筛选
  509. nodeClick(data) {
  510. this.search.businessTypeId = data.id;
  511. this.search.businessType = data.code;
  512. this.form.businessTypeId = data.id;
  513. this.form.businessType = data.code;
  514. // this.detailData.businessTypeId = data.id
  515. // this.detailData.businessTypeCnName = data.cnName
  516. // this.detailData.businessTypeEnName = data.enName
  517. // this.detailData.businessTypeCode = data.code
  518. this.onLoad(this.page, this.search);
  519. },
  520. // 获取左侧业务类别数据
  521. bbusinesstypeListfun() {
  522. bbusinesstypeList(1, 100, { enableVoucher: "1" }).then(res => {
  523. this.feesTypeData = res.data.data.records;
  524. });
  525. },
  526. // 类别弹窗关闭
  527. corpTypeClose(done) {
  528. done();
  529. // this.$confirm('确认关闭?')
  530. // .then(_ => {
  531. // done();
  532. // })
  533. // .catch(_ => { });
  534. },
  535. //自定义列保存
  536. async saveColumnTwo(ref, option, optionBack, code) {
  537. /**
  538. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  539. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  540. * 一定要执行异步操作,要等接口成功返回,才能执行下一行编码
  541. */
  542. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  543. if (inSave) {
  544. this.$message.success("保存成功");
  545. //关闭窗口
  546. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  547. }
  548. },
  549. //自定义列重置
  550. async resetColumnTwo(ref, option, optionBack, code) {
  551. this[option] = this[optionBack];
  552. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  553. if (inSave) {
  554. this.$message.success("重置成功");
  555. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  556. }
  557. },
  558. // 更改表格颜色
  559. headerClassName(tab) {
  560. //颜色间隔
  561. let back = "";
  562. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  563. if (tab.columnIndex % 2 === 0) {
  564. back = "back-one";
  565. } else if (tab.columnIndex % 2 === 1) {
  566. back = "back-two";
  567. }
  568. }
  569. return back;
  570. }
  571. }
  572. };
  573. </script>
  574. <style scoped>
  575. ::v-deep#out-table .back-one {
  576. background: #ecf5ff !important;
  577. }
  578. ::v-deep#out-table .back-two {
  579. background: #ecf5ff !important;
  580. }
  581. </style>