finstlbillsitems2.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <template>
  2. <div>
  3. <avue-crud
  4. :option="option"
  5. :data="pageData"
  6. id="out-table"
  7. ref="crud"
  8. @selection-change="handleSelectionChange"
  9. :header-cell-style="tableHeaderCellStyle"
  10. :row-class-name="rowClassName"
  11. :cell-style="cellStyle"
  12. :page.sync="page"
  13. @size-change="sizeChange"
  14. @current-change="currentChange"
  15. @resetColumn="resetColumn('crud', 'option', 'optionBack', 479)"
  16. @saveColumn="saveColumn('crud', 'option', 'optionBack', 479)"
  17. >
  18. <template slot="menuLeft">
  19. <slot name="menuLeft"></slot>
  20. </template>
  21. <tempalte slot="currentStlAmountRMB" slot-scope="{ row }">
  22. <el-input-number
  23. v-if="brfalse"
  24. v-model="row.currentStlAmountRMB"
  25. @change="armbChange(row)"
  26. :controls="false"
  27. placeholder="请输入 本次签收CNY"
  28. size="mini"
  29. style="width: 100%;"
  30. :disabled="row.currentStlCurCode != 'CNY' || row.isSignfor == 1 || form.advancePaymentRecordList.length"
  31. ></el-input-number>
  32. <span v-else>{{ row.currentStlAmountRMB }}</span>
  33. </tempalte>
  34. <tempalte slot="currentStlAmountUSD" slot-scope="{ row }">
  35. <el-input-number
  36. v-if="brfalse"
  37. v-model="row.currentStlAmountUSD"
  38. @change="ausdChange(row)"
  39. :controls="false"
  40. placeholder="请输入 本次签收USD"
  41. size="mini"
  42. style="width: 100%;"
  43. :disabled="row.currentStlCurCode != 'USD' || row.isSignfor == 1 || form.advancePaymentRecordList.length"
  44. ></el-input-number>
  45. <span v-else>{{ row.currentStlAmountUSD }}</span>
  46. </tempalte>
  47. <template slot="stlAmountDr" slot-scope="{ row }">
  48. <span v-if="row.dc == 'D'">{{ row.stlAmountDr }}</span>
  49. <span v-if="row.dc == 'C'">{{ row.stlAmountCr }}</span>
  50. </template>
  51. <template slot="stlAmountDrUSD" slot-scope="{ row }">
  52. <span v-if="row.dc == 'D'">{{ row.stlAmountDrUSD }}</span>
  53. <span v-if="row.dc == 'C'">{{ row.stlAmountCrUSD }}</span>
  54. </template>
  55. <template slot="remarkss" slot-scope="{ row }">
  56. <el-input style="width: 100%;" v-model="row.remarkss" v-if="brfalse" size="mini" autocomplete="off" clearable placeholder="请输入 备注">
  57. </el-input>
  58. <span v-else>{{ row.remarkss }}</span>
  59. </template>
  60. </avue-crud>
  61. </div>
  62. </template>
  63. <script>
  64. import { getWorkDicts } from "@/api/system/dictbiz";
  65. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  66. import costDetails from "../assembly/costDetails.vue";
  67. import { getRateList } from "@/api/iosBasicData/rateManagement";
  68. import { feecenterSelectByAccNoList } from "@/api/iosBasicData/finstlbills";
  69. export default {
  70. components: { SearchQuery, costDetails },
  71. props: {
  72. tableData: {
  73. type: Array,
  74. default: []
  75. },
  76. brfalse: {
  77. type: Boolean,
  78. default: true
  79. },
  80. handleSelectionData: {
  81. type: Array,
  82. default: []
  83. },
  84. form: {
  85. type: Object,
  86. default: {}
  87. },
  88. editSave: {
  89. type: Boolean,
  90. default: false
  91. }
  92. },
  93. data() {
  94. return {
  95. ifInvoiceData: [], // 是否数据
  96. invoicelosDara: [], // 发票
  97. curCodeData: [], // 币种
  98. option: {},
  99. optionBack: {
  100. height: "auto",
  101. calcHeight: 30,
  102. menuWidth: 60,
  103. tip: false,
  104. menu: false,
  105. border: true,
  106. addBtn: false,
  107. viewBtn: false,
  108. editBtn: false,
  109. delBtn: false,
  110. refreshBtn: false,
  111. index: true,
  112. selection: true,
  113. align: "center",
  114. column: [
  115. {
  116. label: "签收",
  117. prop: "isSignfor",
  118. width: 60,
  119. overHidden: true,
  120. type: "select",
  121. dicData: [
  122. {
  123. label: "否",
  124. value: 0
  125. },
  126. {
  127. label: "是",
  128. value: 1
  129. }
  130. ]
  131. },
  132. {
  133. label: "对账",
  134. prop: "isChecked",
  135. width: 60,
  136. overHidden: true,
  137. type: "select",
  138. dicData: [
  139. {
  140. label: "否",
  141. value: 0
  142. },
  143. {
  144. label: "是",
  145. value: 1
  146. }
  147. ]
  148. },
  149. {
  150. label: "原业务编号",
  151. prop: "billNo",
  152. width: 120,
  153. overHidden: true
  154. },
  155. {
  156. label: "发票号",
  157. prop: "invoiceNo",
  158. width: 80,
  159. overHidden: true
  160. },
  161. {
  162. label: "结算单位",
  163. prop: "corpCnName",
  164. width: 120,
  165. overHidden: true
  166. },
  167. {
  168. label: "MB/L NO",
  169. prop: "mblno",
  170. width: 100,
  171. overHidden: true
  172. },
  173. {
  174. label: "本次签收CNY",
  175. prop: "currentStlAmountRMB",
  176. width: 100,
  177. overHidden: true
  178. },
  179. {
  180. label: "本次签收USD",
  181. prop: "currentStlAmountUSD",
  182. width: 100,
  183. overHidden: true
  184. },
  185. {
  186. label: "币种",
  187. prop: "currentStlCurCode",
  188. width: 60,
  189. overHidden: true
  190. },
  191. {
  192. label: "汇率",
  193. prop: "currentStlExrate",
  194. width: 80,
  195. overHidden: true
  196. },
  197. {
  198. label: "发票状态",
  199. prop: "isInvoice",
  200. width: 80,
  201. type: "select",
  202. dicData: [
  203. {
  204. label: "待开发票",
  205. value: 1
  206. },
  207. {
  208. label: "确认开票",
  209. value: 2
  210. },
  211. {
  212. label: "不开发票",
  213. value: 3
  214. }
  215. ],
  216. overHidden: true
  217. },
  218. {
  219. label: "ETD",
  220. prop: "etd",
  221. width: 100,
  222. overHidden: true
  223. },
  224. {
  225. label: "账单编号",
  226. prop: "accBillNo",
  227. width: 100,
  228. overHidden: true
  229. },
  230. {
  231. label: "签收人",
  232. prop: "signforName",
  233. width: 80,
  234. overHidden: true
  235. },
  236. {
  237. label: "签收日期",
  238. prop: "signforDate",
  239. width: 100,
  240. overHidden: true
  241. },
  242. {
  243. label: "操作人",
  244. prop: "operatorName",
  245. width: 80,
  246. overHidden: true
  247. },
  248. {
  249. label: "BOOKINGNO",
  250. prop: "bookingNo",
  251. width: 100,
  252. overHidden: true
  253. },
  254. {
  255. label: "HB/L NO",
  256. prop: "hblno",
  257. width: 100,
  258. overHidden: true
  259. },
  260. {
  261. label: "船名",
  262. prop: "vesselCnName",
  263. width: 80,
  264. overHidden: true
  265. },
  266. {
  267. label: "航次",
  268. prop: "voyageNo",
  269. width: 80,
  270. overHidden: true
  271. },
  272. {
  273. label: "发票CNY",
  274. prop: "currentInvoiceAmountRMB",
  275. width: 80,
  276. overHidden: true
  277. },
  278. {
  279. label: "发票USD",
  280. prop: "currentInvoiceAmountUSD",
  281. width: 80,
  282. overHidden: true
  283. },
  284. {
  285. label: "箱量",
  286. prop: "quantityCntrTypesDescr",
  287. width: 80,
  288. overHidden: true
  289. },
  290. {
  291. label: "收付",
  292. prop: "dc",
  293. width: 60,
  294. type: "select",
  295. dicData: [
  296. {
  297. label: "收",
  298. value: "D"
  299. },
  300. {
  301. label: "付",
  302. value: "C"
  303. }
  304. ],
  305. overHidden: true
  306. },
  307. {
  308. label: "账单CNY",
  309. prop: "unsettledAmountRMB",
  310. width: 100,
  311. overHidden: true
  312. },
  313. {
  314. label: "账单USD",
  315. prop: "unsettledAmountUSD",
  316. width: 100,
  317. overHidden: true
  318. },
  319. {
  320. label: "已签收CNY",
  321. prop: "reconciliationAmount",
  322. width: 100,
  323. overHidden: true
  324. },
  325. {
  326. label: "已签收USD",
  327. prop: "reconciliationAmountUsd",
  328. width: 100,
  329. overHidden: true
  330. },
  331. {
  332. label: "已结算CNY",
  333. prop: "stlAmountDr",
  334. width: 90,
  335. overHidden: true
  336. },
  337. {
  338. label: "已结算USD",
  339. prop: "stlAmountDrUSD",
  340. width: 90,
  341. overHidden: true
  342. },
  343. // {
  344. // label: "费用名称",
  345. // prop: "feeCnName",
  346. // width: 80,
  347. // overHidden: true
  348. // },
  349. {
  350. label: "业务员",
  351. prop: "srcCnName",
  352. width: 80,
  353. overHidden: true
  354. },
  355. {
  356. label: "备注",
  357. prop: "remarkss",
  358. width: 120,
  359. overHidden: true
  360. }
  361. ]
  362. },
  363. page: {
  364. currentPage: 1,
  365. total: 0,
  366. pageSize: 20,
  367. pageSizes: [20, 50, 100, 200, 500]
  368. },
  369. pageData: []
  370. };
  371. },
  372. async created() {
  373. this.option = await this.getColumnData(this.getColumnName(479), this.optionBack);
  374. this.isSignforWorkDicts();
  375. this.invoicelosWorkDictsfun();
  376. },
  377. methods: {
  378. sizeChange(val) {
  379. this.page.currentPage = 1;
  380. this.page.pageSize = val;
  381. this.getList2();
  382. },
  383. currentChange(val) {
  384. this.page.currentPage = val;
  385. this.getList2();
  386. },
  387. getList2() {
  388. this.page.total = this.tableData.length;
  389. const start = (this.page.currentPage - 1) * this.page.pageSize;
  390. const end = start + this.page.pageSize;
  391. this.pageData = this.tableData.slice(start, end);
  392. },
  393. armbChange(row) {
  394. if (Number(row.amount - row.reconciliationAmount) > 0) {
  395. if (Number(row.currentStlAmountRMB) < 0) {
  396. return this.$message.error("本次金额不能输入负数");
  397. }
  398. if (Number(row.currentStlAmountRMB) > Number(row.amount - row.reconciliationAmount)) {
  399. return this.$message.error("本次金额不能超过未签收金额:" + Number(row.amount - row.reconciliationAmount));
  400. }
  401. }
  402. if (Number(row.amount - row.reconciliationAmount) < 0) {
  403. if (row.currentStlAmountRMB >= 0) {
  404. return this.$message.error("本次金额不能输入非负数");
  405. }
  406. if (Number(row.currentStlAmountRMB) < Number(row.amount - row.reconciliationAmount)) {
  407. return this.$message.error("本次金额不能超过未签收金额:" + Number(row.amount - row.reconciliationAmount));
  408. }
  409. }
  410. },
  411. ausdChange(row) {
  412. if (Number(row.amount - row.reconciliationAmount) > 0) {
  413. if (Number(row.currentStlAmountUSD) < 0) {
  414. return this.$message.error("本次金额不能输入负数");
  415. }
  416. if (Number(row.currentStlAmountUSD) > Number(row.amount - row.reconciliationAmount)) {
  417. return this.$message.error("本次金额不能超过未签收金额:" + Number(row.amount - row.reconciliationAmount));
  418. }
  419. }
  420. if (Number(row.amount - row.reconciliationAmount) < 0) {
  421. if (row.currentStlAmountUSD >= 0) {
  422. return this.$message.error("本次金额不能输入非负数");
  423. }
  424. if (Number(row.currentStlAmountUSD) < Number(row.amount - row.reconciliationAmount)) {
  425. return this.$message.error("本次金额不能超过未签收金额:" + Number(row.amount - row.reconciliationAmount));
  426. }
  427. }
  428. },
  429. // 币别选择监听
  430. corpChange(value, row) {
  431. for (let item of this.curCodeData) {
  432. if (item.code == value) {
  433. this.$set(row, "currentStlCurCode", value);
  434. if (value == "CNY") {
  435. delete row.currentStlAmountUSD;
  436. this.$set(row, "currentStlAmountRMB", row.unsettledAmount);
  437. } else {
  438. delete row.currentStlAmountRMB;
  439. this.$set(row, "currentStlAmountUSD", row.unsettledAmount);
  440. }
  441. }
  442. }
  443. },
  444. // 展开行或者关闭
  445. expandChange(row, expandedRows) {
  446. let accBillId = "";
  447. if (this.form.id) {
  448. accBillId = row.accBillId;
  449. } else {
  450. accBillId = row.id;
  451. }
  452. feecenterSelectByAccNoList({ accBillId }).then(res => {
  453. row.costDate = res.data.data.map(item => {
  454. if (item.curCode == "CNY") {
  455. this.$set(item, "rmbAmount", item.amount);
  456. this.$set(item, "usdAmount", "");
  457. this.$set(item, "rmbAmountNet", item.amountNet);
  458. this.$set(item, "usdAmountNet", "");
  459. } else {
  460. this.$set(item, "usdAmount", item.amount);
  461. this.$set(item, "rmbAmount", "");
  462. this.$set(item, "usdAmountNet", item.amountNet);
  463. this.$set(item, "rmbAmountNet", "");
  464. }
  465. return item;
  466. });
  467. });
  468. },
  469. // 接口请求
  470. // 是否接口
  471. isSignforWorkDicts() {
  472. getWorkDicts("ifInvoice").then(res => {
  473. this.ifInvoiceData = res.data.data;
  474. });
  475. },
  476. // 发票
  477. invoicelosWorkDictsfun() {
  478. getWorkDicts("reconciliation_invoice_los").then(res => {
  479. this.invoicelosDara = res.data.data;
  480. });
  481. },
  482. // 获取币别数据
  483. getRateListfun(cnName) {
  484. getRateList({ current: 1, size: 10, cnName }).then(res => {
  485. this.curCodeData = res.data.data.records;
  486. });
  487. },
  488. // 表头样式
  489. tableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
  490. return "padding:4px 0px;fontSize:12px;color:#000;background:#ecf5ff";
  491. },
  492. // Element UI 表格点击选中行/取消选中 快捷多选 以及快捷连续多选,高亮选中行 ——-------------------------------------——
  493. // 多选选择的数据
  494. handleSelectionChange(arr) {
  495. // // 全选
  496. // if (arr.length == this.tableData.length) {
  497. // for (let item of arr) {
  498. // this.$set(item,'tableSelect',1)
  499. // }
  500. // }
  501. // // 清除全选
  502. // if (arr.length == 0) {
  503. // for (let item of this.tableData) {
  504. // this.$set(item,'tableSelect',0)
  505. // }
  506. // }
  507. this.$emit("handleSelectionChange", arr);
  508. },
  509. // // 多选
  510. // toggleSelection(rows){
  511. // if (rows) {
  512. // rows.forEach(row => {
  513. // this.$refs.tableRef.toggleRowSelection(row);
  514. // });
  515. // } else {
  516. // this.$refs.tableRef.clearSelection();
  517. // }
  518. // },
  519. // 监听点击表格事件
  520. rowClick(row, column, event) {
  521. let refsElTable = this.$refs.tableRef; // 获取表格对象
  522. if (this.CtrlDown) {
  523. refsElTable.toggleRowSelection(row); // ctrl多选 如果点击两次同样会取消选中
  524. return;
  525. }
  526. if (this.shiftOrAltDown && this.handleSelectionData.length > 0) {
  527. // 通过rowIndex判断已选择的行中最上面和最下面的是哪行,再对比按住shift/alt点击的当前行得到新的最上面和最下面的行,把这两行中间的行进行循环选中。
  528. let topAndBottom = this.getTopAndBottom(row, this.bottomSelectionRow, this.topSelectionRow);
  529. refsElTable.clearSelection(); //先清空 不然会导致在这两行中间之外的行状态不变
  530. for (let index = topAndBottom.top; index <= topAndBottom.bottom; index++) {
  531. //选中两行之间的所有行
  532. refsElTable.toggleRowSelection(this.tableData[index], true);
  533. }
  534. } else {
  535. let findRow = this.handleSelectionData.find(c => c.rowIndex == row.rowIndex); //找出当前选中行
  536. //如果只有一行且点击的也是这一行则取消选择 否则清空再选中当前点击行
  537. if (findRow && this.handleSelectionData.length === 1) {
  538. refsElTable.toggleRowSelection(row, false);
  539. return;
  540. }
  541. // refsElTable.clearSelection(); // 清空之前选择的数据(如果放开,选择之前会变成单选)
  542. refsElTable.toggleRowSelection(row); // 调用选中行方法
  543. }
  544. },
  545. // 行的 style 的回调方法
  546. rowStyle({ row, rowIndex }) {
  547. // 直接在一个对象上定义一个新属性,或者修改一个对象的现有属性,并返回此对象
  548. // object: 要添加或者修改属性的目标对象;prop: 要定义或修改属性的名称;descript: 是一个对象,里面是我们上述的对象属性的特性;
  549. Object.defineProperty(row, "rowIndex", {
  550. //给每一行添加不可枚举属性rowIndex来标识当前行
  551. value: rowIndex, // 设置age的值,不设置的话默认为undefined
  552. writable: true, // 表示属性的值true可以修改,false不可以被修改
  553. enumerable: false // 设置为false表示不能通过 for-in 循环返回
  554. // configurable: false, // configurable 设置为 false,意味着这个属性不能从对象上删除
  555. });
  556. },
  557. keyDown(event) {
  558. let key = event.keyCode;
  559. if (key == 17) this.CtrlDown = true;
  560. if (key == 16 || key == 18) this.shiftOrAltDown = true;
  561. },
  562. keyUp(event) {
  563. let key = event.keyCode;
  564. if (key == 17) this.CtrlDown = false;
  565. if (key == 16 || key == 18) this.shiftOrAltDown = false;
  566. },
  567. // 文章说明 https://www.jianshu.com/p/48f2c522d2a2
  568. getTopAndBottom(row, bottom, top) {
  569. let n = row.rowIndex,
  570. mx = bottom.rowIndex,
  571. mi = top.rowIndex;
  572. if (n > mx) {
  573. return {
  574. top: mi,
  575. bottom: n
  576. };
  577. } else if (n < mx && n > mi) {
  578. return {
  579. top: mi,
  580. bottom: n
  581. };
  582. } else if (n < mi) {
  583. return {
  584. top: n,
  585. bottom: mx
  586. };
  587. } else if (n == mi || n == mx) {
  588. return {
  589. top: mi,
  590. bottom: mx
  591. };
  592. }
  593. },
  594. // 给选中行加上current-row这个class类,所以要使用row-class-name这个属性(其实给每一行添加rowIndex也可以用这个属性),
  595. // 判断方式也是通过判断rowIndex对比
  596. rowClassName({ row, rowIndex }) {
  597. let rowName = "",
  598. findRow = this.handleSelectionData.find(c => {
  599. return c.rowIndex === row.rowIndex;
  600. });
  601. if (findRow) {
  602. rowName = "current-row "; // elementUI 默认高亮行的class类 不用再样式了^-^,也可通过css覆盖改变背景颜色
  603. }
  604. return rowName; //也可以再加上其他类名 如果有需求的话
  605. },
  606. // 收付展示不一样的颜色
  607. cellStyle({ row, rowIndex, columnIndex }) {
  608. let rowStyle = "";
  609. if (row.dc == "D") {
  610. rowStyle = "color:#F56C6C;";
  611. } else if (row.dc == "C") {
  612. rowStyle = "color:#67C23A;";
  613. }
  614. return rowStyle + "padding:0px;fontSize:12px";
  615. },
  616. //自定义列保存
  617. async saveColumn(ref, option, optionBack, code) {
  618. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  619. if (inSave) {
  620. this.$message.success("保存成功");
  621. //关闭窗口
  622. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  623. }
  624. },
  625. //自定义列重置
  626. async resetColumn(ref, option, optionBack, code) {
  627. this[option] = this[optionBack];
  628. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  629. if (inSave) {
  630. this.$message.success("重置成功");
  631. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  632. }
  633. }
  634. },
  635. mounted() {
  636. // 按住ctrl实现多选 设置监听keydown事件,以及keyup事件,
  637. addEventListener("keydown", this.keyDown, false);
  638. addEventListener("keyup", this.keyUp, false);
  639. },
  640. beforeDestroy() {
  641. //解绑
  642. removeEventListener("keydown", this.keyDown);
  643. removeEventListener("keyup", this.keyUp);
  644. },
  645. watch: {
  646. tableData: {
  647. // 执行方法
  648. handler(oldValue, newValue) {
  649. this.page.currentPage = 1;
  650. this.pageData = [];
  651. this.getList2();
  652. },
  653. deep: true, // 深度监听
  654. immediate: true // 第一次改变就执行
  655. }
  656. },
  657. computed: {
  658. //实时得到最上行和最下行
  659. bottomSelectionRow() {
  660. if (this.handleSelectionData.length == 0) return null;
  661. return this.handleSelectionData.reduce((start, end) => {
  662. return start.rowIndex > end.rowIndex ? start : end;
  663. });
  664. },
  665. topSelectionRow() {
  666. if (this.handleSelectionData.length == 0) return null;
  667. return this.handleSelectionData.reduce((start, end) => {
  668. return start.rowIndex < end.rowIndex ? start : end;
  669. });
  670. }
  671. }
  672. };
  673. </script>
  674. <style scoped>
  675. .textHide {
  676. width: 100%;
  677. overflow: hidden;
  678. white-space: nowrap;
  679. text-overflow: ellipsis;
  680. }
  681. ::v-deep .current-row {
  682. background: #ecf3ff;
  683. }
  684. </style>