index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <span>
  3. <avue-crud
  4. :option="option"
  5. :data="dataList"
  6. v-model="form"
  7. @row-save="rowSave"
  8. ref="crud"
  9. :key="key"
  10. @selection-change="selectionChange"
  11. @row-update="rowUpdate"
  12. @resetColumn="resetColumn('crud','option','optionBack',codeValue)"
  13. @saveColumn="saveColumn('crud','option','optionBack',codeValue)">
  14. <template slot-scope="{type,size,row,index}" slot="menu">
  15. <el-button icon="el-icon-edit" :size="size" :type="type" :disabled="row.submitPay > 0"
  16. @click="$refs.crud.rowEdit(row,index)">编辑
  17. </el-button>
  18. <el-button icon="el-icon-delete" :size="size" :type="type" :disabled="row.submitPay > 0"
  19. @click="rowDel(row,index)">删除
  20. </el-button>
  21. </template>
  22. <template slot="menuLeft">
  23. <!-- <el-button-->
  24. <!-- class="el-icon-download"-->
  25. <!-- type="info"-->
  26. <!-- size="small"-->
  27. <!-- :disabled="!id || listData.length === 0"-->
  28. <!-- @click="openReport">打印-->
  29. <!-- </el-button>-->
  30. <el-button
  31. class="el-icon-download"
  32. type="warning"
  33. size="small"
  34. :disabled="(selectionList.length === 0 || !(selectionList.findIndex(item => item.submitPay == '1') == -1))"
  35. @click="generateBill">生成账单
  36. </el-button>
  37. <el-button
  38. class="el-icon-download"
  39. type="danger"
  40. size="small"
  41. :disabled="(selectionList.length === 0 || !(selectionList.findIndex(item => item.submitPay == '0') == -1))"
  42. @click="revokeBill">撤销账单
  43. </el-button>
  44. </template>
  45. <template slot="itemNameForm">
  46. <breakdown-select v-model="form.itemId" @selectValue="selectValue"
  47. :configuration="breakConfiguration"></breakdown-select>
  48. </template>
  49. <template slot="corpNameForm">
  50. <crop-select v-model="form.corpId" @getCorpData="getGSDataTwo" corpType="KH"/>
  51. </template>
  52. </avue-crud>
  53. <report-dialog
  54. :switchDialog="switchDialog"
  55. :reportId="id"
  56. :reportName="reportName"
  57. @onClose="onClose()"
  58. />
  59. </span>
  60. </template>
  61. <script>
  62. import {tradingBoxFees} from "@/api/boxManagement";
  63. import reportDialog from "@/components/report-dialog/main.vue";
  64. import {generateBill,revokeBill} from "@/api/oceanShipping/maritimeExport";
  65. export default {
  66. name: "index",
  67. components: {reportDialog},
  68. data() {
  69. return {
  70. code: '',
  71. switchDialog: false,
  72. reportName:'',
  73. option: {},
  74. optionBack: {
  75. align: 'center',
  76. index: true,
  77. height: 500,
  78. addBtnText: "录入明细",
  79. refreshBtn: false,
  80. addBtn: true,
  81. selection: true,
  82. span: 6,
  83. dialogTop: "25%",
  84. addRowBtn: false,
  85. cellBtn: false,
  86. editBtn: false,
  87. delBtn: false,
  88. menuWidth: 140,
  89. dialogDrag: true,
  90. dialogWidth: "80%",
  91. showSummary: true,
  92. sumColumnList: [{
  93. name: 'quantity',
  94. type: 'sum',
  95. decimals: 0
  96. }, {
  97. name: 'amount',
  98. type: 'sum',
  99. decimals: 2
  100. }, {
  101. name: 'settlementAmount',
  102. type: 'sum',
  103. decimals: 2
  104. }],
  105. column: [{
  106. label: '收款对象',
  107. prop: 'corpName',
  108. overHidden: true,
  109. width: 160
  110. }, {
  111. label: '费用名称',
  112. prop: 'itemName',
  113. overHidden: true,
  114. width: 120
  115. }, {
  116. label: '币别',
  117. prop: 'currency',
  118. width: 100,
  119. overHidden: true,
  120. filterable: true,
  121. type: "select",
  122. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  123. props: {
  124. label: "dictValue",
  125. value: "dictKey"
  126. },
  127. }, {
  128. label: '汇率',
  129. prop: 'exchangeRate',
  130. width: 100,
  131. type: 'number',
  132. disabled: true,
  133. overHidden: true,
  134. controls: false,
  135. precision: 4
  136. }, {
  137. label: '单价',
  138. prop: 'price',
  139. type: 'number',
  140. overHidden: true,
  141. precision: 2,
  142. controls: false,
  143. width: 140
  144. }, {
  145. label: '数量',
  146. prop: 'quantity',
  147. type: 'number',
  148. precision: 0,
  149. value: 1,
  150. controls: false,
  151. overHidden: true,
  152. width: 100
  153. }, {
  154. label: '金额',
  155. prop: 'amount',
  156. type: 'number',
  157. precision: 2,
  158. disabled: true,
  159. controls: false,
  160. overHidden: true,
  161. width: 140
  162. }, {
  163. label: '日期起',
  164. prop: 'rentStartDate',
  165. width: 100,
  166. overHidden: true,
  167. type: "date",
  168. disabled: true,
  169. format: "yyyy-MM-dd",
  170. valueFormat: "yyyy-MM-dd HH:mm:ss"
  171. }, {
  172. label: '日期止',
  173. prop: 'rentEndDate',
  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: 'settlementAmount',
  183. type: 'number',
  184. precision: 2,
  185. disabled: true,
  186. controls: false,
  187. overHidden: true,
  188. width: 140
  189. }, {
  190. label: '结算时间',
  191. prop: 'settlementDate',
  192. width: 100,
  193. disabled: true,
  194. overHidden: true,
  195. type: "date",
  196. format: "yyyy-MM-dd",
  197. valueFormat: "yyyy-MM-dd HH:mm:ss"
  198. }, {
  199. label: '业务类型',
  200. prop: 'billType',
  201. display:false,
  202. width: 100
  203. }, {
  204. label: '备注',
  205. prop: 'remarks',
  206. type: 'textarea',
  207. overHidden: true,
  208. minRows: 3,
  209. span: 24,
  210. width: 200
  211. }]
  212. },
  213. selectionList: [],
  214. dataList: [],
  215. form: {},
  216. key: 0,
  217. data_one: [],
  218. data_two: [],
  219. breakConfiguration: {
  220. multipleChoices: false,
  221. multiple: false,
  222. disabled: false,
  223. searchShow: true,
  224. collapseTags: false,
  225. clearable: true,
  226. placeholder: "请点击右边按钮选择",
  227. dicData: []
  228. },
  229. activeNameTwo: "first"
  230. }
  231. },
  232. watch: {
  233. listData(newVla, oldVal) {
  234. this.data_one = newVla.filter(item => item.feesType === 1); //应收
  235. this.data_two = newVla.filter(item => item.feesType === 2); //应付
  236. if (this.activeNameTwo === "first") {
  237. this.dataList = this.data_one;
  238. } else {
  239. this.dataList = this.data_two;
  240. }
  241. this.key++
  242. },
  243. "option.menu":{
  244. handler(newVla,oldVal) {
  245. if (newVla !== oldVal) {
  246. this.key++
  247. }
  248. },
  249. },
  250. code(newVla, oldVal) {
  251. if (this.code){
  252. this.findObject(this.option.column, "code").dicUrl = `/api/blade-box-tube/archives/selectArchivesByCodeList?code=${this.code}`
  253. }
  254. this.key++
  255. },
  256. activeNameTwo(newVla, oldVal) {
  257. if (newVla !== oldVal) {
  258. if (newVla === "first") {
  259. this.data_two = this.dataList;
  260. this.dataList = this.data_one;
  261. } else {
  262. this.data_one = this.dataList;
  263. this.dataList = this.data_two;
  264. }
  265. }
  266. }
  267. },
  268. model: {
  269. prop: "listData",
  270. event: "callBack"
  271. },
  272. props: {
  273. listData: {
  274. type: Array,
  275. default: function () {
  276. return [];
  277. }
  278. },
  279. codeValue: {
  280. type: String
  281. },
  282. type: {
  283. type: String
  284. },
  285. url: {
  286. type: String
  287. },
  288. oceanFreight: {
  289. type: Boolean//切换默认费用和展开费用
  290. },
  291. // 1.显示全部 2.收费 3.付费
  292. tabShow: {
  293. type: Number,
  294. default: 1
  295. },
  296. activeName: {
  297. type: String,
  298. default: 'first'
  299. },
  300. id: {
  301. type: String
  302. }
  303. },
  304. async created() {
  305. if (!this.codeValue) this.codeValue = 235.2
  306. // 判断activeNameTwo默认的显示
  307. this.activeNameTwo = this.activeName
  308. this.option = await this.getColumnData(this.getColumnName(this.codeValue), this.optionBack);
  309. if (this.activeNameTwo === "first") {
  310. this.findObject(this.option.column, "corpName").label = "收款对象"
  311. } else {
  312. this.findObject(this.option.column, "corpName").label = "付款对象"
  313. }
  314. // this.$set(this.option,"selectable",(row,index)=>{
  315. // return row.isCheck === 0;
  316. // })
  317. this.findObject(this.option.column, "price").change = ({value, column}) => {
  318. if (value && this.form.quantity) {
  319. if (this.form.exchangeRate) {
  320. this.form.amount = value * this.form.quantity * this.form.exchangeRate
  321. } else {
  322. this.form.amount = value * this.form.quantity
  323. }
  324. }
  325. }
  326. this.findObject(this.option.column, "currency").change = ({value, column}) => {
  327. for (let item of this.$refs.crud.DIC.currency) {
  328. if (item.dictKey == value) {
  329. this.form.exchangeRate = item.remark
  330. if (this.form.price && this.form.quantity) {
  331. this.form.amount = this.form.price * this.form.quantity * item.remark
  332. }
  333. }
  334. }
  335. }
  336. this.findObject(this.option.column, "quantity").change = ({value, column}) => {
  337. if (this.form.price && value) {
  338. if (this.form.exchangeRate) {
  339. this.form.amount = this.form.price * value * this.form.exchangeRate
  340. } else {
  341. this.form.amount = this.form.price * value
  342. }
  343. }
  344. }
  345. this.key++
  346. },
  347. methods: {
  348. openReport() {
  349. for (let item of this.listData) {
  350. if (!item.id) {
  351. this.$confirm("有未保存的费用,是否继续打印?", {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning"
  355. }).then(() => {
  356. if (this.type === "CK" || this.type === "JK"){
  357. if (this.activeNameTwo === "first"){
  358. this.reportName = "收款费用详情(进出口)"
  359. }else {
  360. this.reportName = "付款费用详情(进出口)"
  361. }
  362. }else {
  363. if (this.activeNameTwo === "first"){
  364. this.reportName = "收款费用详情(箱管)"
  365. }else {
  366. this.reportName = "付款费用详情(箱管)"
  367. }
  368. }
  369. this.switchDialog = true
  370. })
  371. }
  372. }
  373. this.switchDialog = true
  374. },
  375. // 报表关闭
  376. onClose(val) {
  377. this.switchDialog = val;
  378. },
  379. handleClick(tab, event) {
  380. this.activeNameTwo = tab.name
  381. if (tab.name === "first") {
  382. this.findObject(this.option.column, "corpName").label = "收款对象"
  383. } else {
  384. this.findObject(this.option.column, "corpName").label = "付款对象"
  385. }
  386. },
  387. selectionChange(list){
  388. this.selectionList = list
  389. },
  390. //生成账单
  391. generateBill(){
  392. this.$confirm("您确定要生成账单吗?", {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "warning"
  396. }).then(() => {
  397. const loading = this.$loading({
  398. lock: true,
  399. text: '加载中',
  400. spinner: 'el-icon-loading',
  401. background: 'rgba(255,255,255,0.7)'
  402. });
  403. const data = {
  404. id: this.id,
  405. shippingFeesList:this.selectionList
  406. }
  407. generateBill(data).then(rest => {
  408. loading.close();
  409. this.$message.success('生成成功')
  410. this.$emit("generateBill")
  411. }).catch(() => {
  412. loading.close();
  413. })
  414. })
  415. },
  416. //撤销账单
  417. revokeBill(){
  418. this.$confirm("您确定要撤销账单吗?", {
  419. confirmButtonText: "确定",
  420. cancelButtonText: "取消",
  421. type: "warning"
  422. }).then(() => {
  423. const loading = this.$loading({
  424. lock: true,
  425. text: '加载中',
  426. spinner: 'el-icon-loading',
  427. background: 'rgba(255,255,255,0.7)'
  428. });
  429. const data = {
  430. id: this.id,
  431. shippingFeesList:this.selectionList
  432. }
  433. revokeBill(data).then(rest => {
  434. loading.close();
  435. this.$message.success('撤销成功')
  436. this.$emit("generateBill")
  437. }).catch(() => {
  438. loading.close();
  439. })
  440. })
  441. },
  442. rowSave(form, done, loading) {
  443. done({
  444. ...form,
  445. feesType: this.activeNameTwo === "first" ? 1 : 2,
  446. sort: this.dataList.length
  447. })
  448. if (this.activeNameTwo === "first") {
  449. this.dataList = this.dataList.concat(this.data_two)
  450. this.$emit("callBack", this.dataList);
  451. } else {
  452. this.dataList = this.dataList.concat(this.data_one)
  453. this.$emit("callBack", this.dataList);
  454. }
  455. },
  456. rowUpdate(form, index, done, loading) {
  457. done(form)
  458. if (this.activeNameTwo === "first") {
  459. this.$emit("callBack", this.dataList.concat(this.data_two));
  460. } else {
  461. this.$emit("callBack", this.data_one.concat(this.dataList));
  462. }
  463. },
  464. // 明细删除
  465. rowDel(row, index) {
  466. this.$confirm("确定将选择数据删除?", {
  467. confirmButtonText: "确定",
  468. cancelButtonText: "取消",
  469. type: "warning"
  470. }).then(() => {
  471. if (row.id) {
  472. tradingBoxFees(row.id, this.url ? this.url : "/api/blade-box-tube/tradingBoxFees/remove").then(res => {
  473. if (res.data.success) {
  474. this.dataList.splice(index, 1);
  475. this.$message.success("操作成功!");
  476. if (this.activeNameTwo === "first") {
  477. this.$emit("callBack", this.dataList.concat(this.data_two));
  478. } else {
  479. this.$emit("callBack", this.data_one.concat(this.dataList));
  480. }
  481. }
  482. });
  483. } else {
  484. this.dataList.splice(index, 1);
  485. this.$message.success("操作成功!");
  486. if (this.activeNameTwo === "first") {
  487. this.$emit("callBack", this.dataList.concat(this.data_two));
  488. } else {
  489. this.$emit("callBack", this.data_one.concat(this.dataList));
  490. }
  491. }
  492. });
  493. },
  494. //选择费用名称
  495. selectValue(value) {
  496. this.form.itemName = value.cname
  497. },
  498. getGSDataTwo(row) {
  499. this.form.corpName = row.cname
  500. },
  501. //自定义列保存
  502. async saveColumn(ref, option, optionBack, code) {
  503. /**
  504. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  505. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  506. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  507. */
  508. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  509. if (inSave) {
  510. this.$message.success("保存成功");
  511. //关闭窗口
  512. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  513. }
  514. },
  515. //自定义列重置
  516. async resetColumn(ref, option, optionBack, code) {
  517. this[option] = this[optionBack];
  518. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  519. this.$emit("resetTrigger")
  520. if (inSave) {
  521. this.findObject(this.option.column, "price").change = ({value, column}) => {
  522. if (value && this.form.quantity) {
  523. if (this.form.exchangeRate) {
  524. this.form.amount = value * this.form.quantity * this.form.exchangeRate
  525. } else {
  526. this.form.amount = value * this.form.quantity
  527. }
  528. }
  529. }
  530. this.findObject(this.option.column, "currency").change = ({value, column}) => {
  531. for (let item of this.$refs.crud.DIC.currency) {
  532. if (item.dictValue == value) {
  533. this.form.exchangeRate = item.remark
  534. if (this.form.price && this.form.quantity) {
  535. this.form.amount = this.form.price * this.form.quantity * item.remark
  536. }
  537. }
  538. }
  539. }
  540. this.findObject(this.option.column, "quantity").change = ({value, column}) => {
  541. if (this.form.price && value) {
  542. if (this.form.exchangeRate) {
  543. this.form.amount = this.form.price * value * this.form.exchangeRate
  544. } else {
  545. this.form.amount = this.form.price * value
  546. }
  547. }
  548. }
  549. this.$message.success("重置成功");
  550. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  551. }
  552. }
  553. }
  554. }
  555. </script>
  556. <style scoped>
  557. </style>