index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <trade-card title="费用信息">
  3. <el-tabs v-model="activeName" @tab-click="handleClick">
  4. <el-tab-pane label="应收" name="first" :key="'first'" v-if="tabShow == 1 || tabShow == 2">
  5. </el-tab-pane>
  6. <el-tab-pane label="应付" name="second" :key="'second'" v-if="tabShow == 1 || tabShow == 3">
  7. </el-tab-pane>
  8. </el-tabs>
  9. <avue-crud
  10. :option="option"
  11. :data="dataList"
  12. v-model="form"
  13. @row-save="rowSave"
  14. ref="crud"
  15. :key="key"
  16. @row-update="rowUpdate"
  17. @resetColumn="resetColumn('crud','option','optionBack',codeValue)"
  18. @saveColumn="saveColumn('crud','option','optionBack',codeValue)">
  19. <template slot-scope="{type,size,row,index}" slot="menu">
  20. <el-button icon="el-icon-edit" :size="size" :type="type" :disabled="row.settlementAmount > 0" @click="$refs.crud.rowEdit(row,index)">编辑
  21. </el-button>
  22. <el-button icon="el-icon-delete" :size="size" :type="type" :disabled="row.settlementAmount > 0" @click="rowDel(row,index)">删除</el-button>
  23. </template>
  24. <template slot="itemNameForm">
  25. <breakdown-select v-model="form.itemId" @selectValue="selectValue"
  26. :configuration="breakConfiguration"></breakdown-select>
  27. </template>
  28. <template slot="corpNameForm">
  29. <crop-select v-model="form.corpId" @getCorpData="getGSDataTwo" corpType="KH"/>
  30. </template>
  31. </avue-crud>
  32. </trade-card>
  33. </template>
  34. <script>
  35. import {tradingBoxFees} from "@/api/boxManagement";
  36. import {mapStates} from "element-ui/packages/table/src/store/helper";
  37. export default {
  38. name: "index",
  39. data() {
  40. return {
  41. code:'',
  42. option: {},
  43. optionBack: {},
  44. leaseIn:{
  45. align: 'center',
  46. index: true,
  47. height:500,
  48. addBtnText: "录入明细",
  49. refreshBtn: false,
  50. addBtn: true,
  51. selection: true,
  52. span: 6,
  53. dialogTop: "25%",
  54. addRowBtn: false,
  55. cellBtn: false,
  56. editBtn: false,
  57. delBtn: false,
  58. menuWidth: 140,
  59. dialogDrag: true,
  60. dialogWidth: "80%",
  61. showSummary: true,
  62. sumColumnList: [{
  63. name: 'quantity',
  64. type: 'sum',
  65. decimals: 0
  66. }, {
  67. name: 'amount',
  68. type: 'sum',
  69. decimals: 2
  70. }, {
  71. name: 'settlementAmount',
  72. type: 'sum',
  73. decimals: 2
  74. }],
  75. column: [{
  76. label: '收款对象',
  77. prop: 'corpName',
  78. overHidden: true,
  79. width: 160
  80. }, {
  81. label: '箱号',
  82. prop: 'code',
  83. width: 140,
  84. overHidden: true,
  85. filterable: true,
  86. type: "select",
  87. dicUrl: `/api/blade-box-tube/archives/selectArchivesByCodeList?code=${this.code}`,
  88. props: {
  89. label: "code",
  90. value: "code"
  91. },
  92. }, {
  93. label: '费用名称',
  94. prop: 'itemName',
  95. overHidden: true,
  96. width: 120
  97. }, {
  98. label: '币别',
  99. prop: 'currency',
  100. width: 100,
  101. overHidden: true,
  102. filterable: true,
  103. type: "select",
  104. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  105. props: {
  106. label: "dictValue",
  107. value: "dictKey"
  108. },
  109. }, {
  110. label: '汇率',
  111. prop: 'exchangeRate',
  112. width: 100,
  113. type: 'number',
  114. disabled: true,
  115. overHidden: true,
  116. controls: false,
  117. precision: 4
  118. }, {
  119. label: '单价',
  120. prop: 'price',
  121. type: 'number',
  122. overHidden: true,
  123. precision: 2,
  124. controls: false,
  125. width: 140
  126. }, {
  127. label: '数量',
  128. prop: 'quantity',
  129. type: 'number',
  130. precision: 0,
  131. value: 1,
  132. controls: false,
  133. overHidden: true,
  134. width: 100
  135. }, {
  136. label: '金额',
  137. prop: 'amount',
  138. type: 'number',
  139. precision: 2,
  140. disabled: true,
  141. controls: false,
  142. overHidden: true,
  143. width: 140
  144. }, {
  145. label: '日期起',
  146. prop: 'rentStartDate',
  147. width: 100,
  148. overHidden: true,
  149. type: "date",
  150. disabled: true,
  151. format: "yyyy-MM-dd",
  152. valueFormat: "yyyy-MM-dd HH:mm:ss"
  153. }, {
  154. label: '日期止',
  155. prop: 'rentEndDate',
  156. width: 100,
  157. disabled: true,
  158. overHidden: true,
  159. type: "date",
  160. format: "yyyy-MM-dd",
  161. valueFormat: "yyyy-MM-dd HH:mm:ss"
  162. }, {
  163. label: '结算金额',
  164. prop: 'settlementAmount',
  165. type: 'number',
  166. precision: 2,
  167. disabled: true,
  168. controls: false,
  169. overHidden: true,
  170. width: 140
  171. }, {
  172. label: '结算时间',
  173. prop: 'settlementDate',
  174. width: 100,
  175. disabled: true,
  176. overHidden: true,
  177. type: "date",
  178. format: "yyyy-MM-dd",
  179. valueFormat: "yyyy-MM-dd HH:mm:ss"
  180. }, {
  181. label: '业务类型',
  182. prop: 'billType',
  183. display:false,
  184. width: 100
  185. }, {
  186. label: '备注',
  187. prop: 'remarks',
  188. type: 'textarea',
  189. overHidden: true,
  190. minRows: 3,
  191. span: 24,
  192. width: 200
  193. }]
  194. },
  195. boxTube:{
  196. align: 'center',
  197. index: true,
  198. height:500,
  199. addBtnText: "录入明细",
  200. refreshBtn: false,
  201. addBtn: true,
  202. span: 6,
  203. dialogTop: "25%",
  204. addRowBtn: false,
  205. cellBtn: false,
  206. editBtn: false,
  207. delBtn: false,
  208. menuWidth: 140,
  209. dialogDrag: true,
  210. dialogWidth: "80%",
  211. showSummary: true,
  212. sumColumnList: [{
  213. name: 'quantity',
  214. type: 'sum',
  215. decimals: 0
  216. }, {
  217. name: 'amount',
  218. type: 'sum',
  219. decimals: 2
  220. }, {
  221. name: 'settlementAmount',
  222. type: 'sum',
  223. decimals: 2
  224. }],
  225. column: [{
  226. label: '收款对象',
  227. prop: 'corpName',
  228. overHidden: true,
  229. width: 160
  230. }, {
  231. label: '箱号',
  232. prop: 'code',
  233. width: 140,
  234. overHidden: true,
  235. filterable: true,
  236. type: "select",
  237. dicUrl: `/api/blade-box-tube/archives/selectArchivesByCodeList?code=${this.code}`,
  238. props: {
  239. label: "code",
  240. value: "code"
  241. },
  242. }, {
  243. label: '费用名称',
  244. prop: 'itemName',
  245. overHidden: true,
  246. width: 120
  247. }, {
  248. label: '币别',
  249. prop: 'currency',
  250. width: 100,
  251. overHidden: true,
  252. filterable: true,
  253. type: "select",
  254. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  255. props: {
  256. label: "dictValue",
  257. value: "dictKey"
  258. },
  259. }, {
  260. label: '汇率',
  261. prop: 'exchangeRate',
  262. width: 100,
  263. type: 'number',
  264. disabled: true,
  265. overHidden: true,
  266. controls: false,
  267. precision: 4
  268. }, {
  269. label: '单价',
  270. prop: 'price',
  271. type: 'number',
  272. overHidden: true,
  273. precision: 2,
  274. controls: false,
  275. width: 140
  276. }, {
  277. label: '数量',
  278. prop: 'quantity',
  279. type: 'number',
  280. precision: 0,
  281. value: 1,
  282. controls: false,
  283. overHidden: true,
  284. width: 100
  285. }, {
  286. label: '金额',
  287. prop: 'amount',
  288. type: 'number',
  289. precision: 2,
  290. disabled: true,
  291. controls: false,
  292. overHidden: true,
  293. width: 140
  294. }, {
  295. label: '结算金额',
  296. prop: 'settlementAmount',
  297. type: 'number',
  298. precision: 2,
  299. disabled: true,
  300. controls: false,
  301. overHidden: true,
  302. width: 140
  303. }, {
  304. label: '结算时间',
  305. prop: 'settlementDate',
  306. width: 100,
  307. disabled: true,
  308. overHidden: true,
  309. type: "date",
  310. format: "yyyy-MM-dd",
  311. valueFormat: "yyyy-MM-dd HH:mm:ss"
  312. }, {
  313. label: '业务类型',
  314. prop: 'billType',
  315. display:false,
  316. width: 100
  317. }, {
  318. label: '备注',
  319. prop: 'remarks',
  320. type: 'textarea',
  321. overHidden: true,
  322. minRows: 3,
  323. span: 24,
  324. width: 200
  325. }]
  326. },
  327. customsList: {
  328. align: 'center',
  329. index: true,
  330. height:500,
  331. addBtnText: "录入明细",
  332. refreshBtn: false,
  333. addBtn: true,
  334. span: 6,
  335. dialogTop: "25%",
  336. addRowBtn: false,
  337. cellBtn: false,
  338. editBtn: false,
  339. delBtn: false,
  340. menuWidth: 140,
  341. dialogDrag: true,
  342. dialogWidth: "80%",
  343. showSummary: true,
  344. sumColumnList: [{
  345. name: 'quantity',
  346. type: 'sum',
  347. decimals: 0
  348. },{
  349. name: 'amount',
  350. type: 'sum',
  351. decimals: 2
  352. },{
  353. name: 'settlementAmount',
  354. type: 'sum',
  355. decimals: 2
  356. }],
  357. column: [{
  358. label: '收款对象',
  359. prop: 'corpName',
  360. overHidden: true,
  361. width: 160
  362. }, {
  363. label: '费用名称',
  364. prop: 'itemName',
  365. overHidden: true,
  366. width: 120
  367. }, {
  368. label: '币别',
  369. prop: 'currency',
  370. width: 100,
  371. overHidden: true,
  372. filterable: true,
  373. type: "select",
  374. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  375. props: {
  376. label: "dictValue",
  377. value: "dictKey"
  378. },
  379. }, {
  380. label: '汇率',
  381. prop: 'exchangeRate',
  382. width: 100,
  383. type: 'number',
  384. disabled: true,
  385. overHidden: true,
  386. controls: false,
  387. precision: 4
  388. }, {
  389. label: '单价',
  390. prop: 'price',
  391. type: 'number',
  392. overHidden: true,
  393. precision: 2,
  394. controls: false,
  395. width: 140
  396. }, {
  397. label: '数量',
  398. prop: 'quantity',
  399. type: 'number',
  400. precision: 0,
  401. value: 1,
  402. controls: false,
  403. overHidden: true,
  404. width: 100
  405. }, {
  406. label: '金额',
  407. prop: 'amount',
  408. type: 'number',
  409. precision: 2,
  410. disabled: true,
  411. controls: false,
  412. overHidden: true,
  413. width: 140
  414. },
  415. // {
  416. // label: '结算金额',
  417. // prop: 'settlementAmount',
  418. // type: 'number',
  419. // precision: 2,
  420. // disabled: true,
  421. // controls: false,
  422. // overHidden: true,
  423. // width: 140
  424. // }, {
  425. // label: '结算时间',
  426. // prop: 'settlementDate',
  427. // width: 100,
  428. // disabled: true,
  429. // overHidden: true,
  430. // type: "date",
  431. // format: "yyyy-MM-dd",
  432. // valueFormat: "yyyy-MM-dd HH:mm:ss"
  433. // }, {
  434. // label: '业务类型',
  435. // prop: 'billType',
  436. // display:false,
  437. // width: 100
  438. // },
  439. {
  440. label: '备注',
  441. prop: 'remark',
  442. type: 'textarea',
  443. overHidden: true,
  444. minRows: 3,
  445. span: 24
  446. }]
  447. },
  448. dataList: [],
  449. form: {},
  450. key: 0,
  451. data_one: [],
  452. data_two: [],
  453. breakConfiguration: {
  454. multipleChoices: false,
  455. multiple: false,
  456. disabled: false,
  457. searchShow: true,
  458. collapseTags: false,
  459. clearable: true,
  460. placeholder: "请点击右边按钮选择",
  461. dicData: []
  462. },
  463. activeName: "first"
  464. }
  465. },
  466. watch: {
  467. listData(newVla, oldVal) {
  468. this.data_one = newVla.filter(item => item.feesType === 1); //应收
  469. this.data_two = newVla.filter(item => item.feesType === 2); //应付
  470. if (this.activeName === "first") {
  471. this.dataList = this.data_one;
  472. } else {
  473. this.dataList = this.data_two;
  474. }
  475. },
  476. code(newVla, oldVal) {
  477. if (this.code){
  478. this.findObject(this.option.column, "code").dicUrl = `/api/blade-box-tube/archives/selectArchivesByCodeList?code=${this.code}`
  479. }
  480. console.log(this.code)
  481. this.key++
  482. },
  483. activeName(newVla, oldVal) {
  484. if (newVla !== oldVal) {
  485. if (newVla === "first") {
  486. this.data_two = this.dataList;
  487. this.dataList = this.data_one;
  488. } else {
  489. this.data_one = this.dataList;
  490. this.dataList = this.data_two;
  491. }
  492. }
  493. }
  494. },
  495. model: {
  496. prop: "listData",
  497. event: "callBack"
  498. },
  499. props: {
  500. listData: {
  501. type: Array,
  502. default: function () {
  503. return [];
  504. }
  505. },
  506. codeValue: {
  507. type: String
  508. },
  509. type:{
  510. type: String
  511. },
  512. url: {
  513. type: String
  514. },
  515. // 1.显示全部 2.收费 3.付费
  516. tabShow: {
  517. type: Number,
  518. default: 1
  519. },
  520. activeName: {
  521. type: String,
  522. default: 'first'
  523. }
  524. },
  525. async created() {
  526. if (this.type === 'BG'){
  527. this.optionBack = this.customsList
  528. }else if (this.type === 'ZR' || this.type === 'ZC'){
  529. this.optionBack = this.leaseIn
  530. }else {
  531. this.optionBack = this.boxTube
  532. }
  533. if (!this.codeValue) this.codeValue = 235.2
  534. // 判断tabShow的activeName默认的显示
  535. this.activeName = this.tabShow == 1 ? "first" : this.tabShow == 2 ? "first" : "second";
  536. this.option = await this.getColumnData(this.getColumnName(this.codeValue), this.optionBack);
  537. if (this.activeName === "first") {
  538. this.findObject(this.option.column, "corpName").label = "收款对象"
  539. } else {
  540. this.findObject(this.option.column, "corpName").label = "付款对象"
  541. }
  542. this.findObject(this.option.column, "price").change = ({value, column}) => {
  543. if (value && this.form.quantity) {
  544. if (this.form.exchangeRate) {
  545. this.form.amount = value * this.form.quantity * this.form.exchangeRate
  546. } else {
  547. this.form.amount = value * this.form.quantity
  548. }
  549. }
  550. }
  551. this.findObject(this.option.column, "currency").change = ({value, column}) => {
  552. for (let item of this.$refs.crud.DIC.currency) {
  553. if (item.dictValue == value) {
  554. this.form.exchangeRate = item.remark
  555. if (this.form.price && this.form.quantity) {
  556. this.form.amount = this.form.price * this.form.quantity * item.remark
  557. }
  558. }
  559. }
  560. }
  561. this.findObject(this.option.column, "quantity").change = ({value, column}) => {
  562. if (this.form.price && value) {
  563. if (this.form.exchangeRate) {
  564. this.form.amount = this.form.price * value * this.form.exchangeRate
  565. } else {
  566. this.form.amount = this.form.price * value
  567. }
  568. }
  569. }
  570. this.key++
  571. },
  572. methods: {
  573. handleClick(tab, event) {
  574. // this.activeName = tab.name
  575. if (tab.name === "first") {
  576. this.findObject(this.option.column, "corpName").label = "收款对象"
  577. } else {
  578. this.findObject(this.option.column, "corpName").label = "付款对象"
  579. }
  580. },
  581. rowSave(form, done, loading) {
  582. done({
  583. ...form,
  584. feesType: this.activeName === "first" ? 1 : 2,
  585. sort: this.dataList.length
  586. })
  587. if (this.activeName === "first") {
  588. this.$emit("callBack", this.dataList.concat(this.data_two));
  589. } else {
  590. this.$emit("callBack", this.data_one.concat(this.dataList));
  591. }
  592. },
  593. rowUpdate(form, index, done, loading) {
  594. done(form)
  595. if (this.activeName === "first") {
  596. this.$emit("callBack", this.dataList.concat(this.data_two));
  597. } else {
  598. this.$emit("callBack", this.data_one.concat(this.dataList));
  599. }
  600. },
  601. // 明细删除
  602. rowDel(row, index) {
  603. this.$confirm("确定将选择数据删除?", {
  604. confirmButtonText: "确定",
  605. cancelButtonText: "取消",
  606. type: "warning"
  607. }).then(() => {
  608. if (row.id) {
  609. tradingBoxFees(row.id, this.url ? this.url : "/api/blade-box-tube/tradingBoxFees/remove").then(res => {
  610. if (res.data.success) {
  611. this.dataList.splice(index, 1);
  612. this.$message.success("操作成功!");
  613. if (this.activeName === "first") {
  614. this.$emit("callBack", this.dataList.concat(this.data_two));
  615. } else {
  616. this.$emit("callBack", this.data_one.concat(this.dataList));
  617. }
  618. }
  619. });
  620. } else {
  621. this.dataList.splice(index, 1);
  622. this.$message.success("操作成功!");
  623. if (this.activeName === "first") {
  624. this.$emit("callBack", this.dataList.concat(this.data_two));
  625. } else {
  626. this.$emit("callBack", this.data_one.concat(this.dataList));
  627. }
  628. }
  629. });
  630. },
  631. //选择费用名称
  632. selectValue(value) {
  633. this.form.itemName = value.cname
  634. },
  635. getGSDataTwo(row) {
  636. this.form.corpName = row.cname
  637. },
  638. //自定义列保存
  639. async saveColumn(ref, option, optionBack, code) {
  640. /**
  641. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  642. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  643. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  644. */
  645. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  646. if (inSave) {
  647. this.$message.success("保存成功");
  648. //关闭窗口
  649. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  650. }
  651. },
  652. //自定义列重置
  653. async resetColumn(ref, option, optionBack, code) {
  654. this[option] = this[optionBack];
  655. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  656. this.$emit("resetTrigger")
  657. if (inSave) {
  658. this.findObject(this.option.column, "price").change = ({value, column}) => {
  659. if (value && this.form.quantity) {
  660. if (this.form.exchangeRate) {
  661. this.form.amount = value * this.form.quantity * this.form.exchangeRate
  662. } else {
  663. this.form.amount = value * this.form.quantity
  664. }
  665. }
  666. }
  667. this.findObject(this.option.column, "currency").change = ({value, column}) => {
  668. for (let item of this.$refs.crud.DIC.currency) {
  669. if (item.dictValue == value) {
  670. this.form.exchangeRate = item.remark
  671. if (this.form.price && this.form.quantity) {
  672. this.form.amount = this.form.price * this.form.quantity * item.remark
  673. }
  674. }
  675. }
  676. }
  677. this.findObject(this.option.column, "quantity").change = ({value, column}) => {
  678. if (this.form.price && value) {
  679. if (this.form.exchangeRate) {
  680. this.form.amount = this.form.price * value * this.form.exchangeRate
  681. } else {
  682. this.form.amount = this.form.price * value
  683. }
  684. }
  685. }
  686. this.$message.success("重置成功");
  687. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  688. }
  689. }
  690. }
  691. }
  692. </script>
  693. <style scoped>
  694. </style>