detailsStatement.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <!-- 计费账单 -->
  2. <template>
  3. <div id="detailsStatement">
  4. <div class="top">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-input v-model="shipName" placeholder="请输入船名" clearable></el-input>
  8. </el-form-item>
  9. <!-- <el-form-item>
  10. <span class="demonstration">离港日期</span>
  11. <el-date-picker
  12. v-model="startTime"
  13. type="date"
  14. placeholder="选择日期"
  15. style="width:200px"
  16. >
  17. </el-date-picker>
  18. <span>至</span>
  19. <el-date-picker
  20. v-model="endTime"
  21. type="date"
  22. placeholder="选择日期"
  23. style="width:200px"
  24. >
  25. </el-date-picker>
  26. </el-form-item> -->
  27. <el-form-item>
  28. <el-button @click="onClick" type="primary" icon="el-icon-search">查询</el-button>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" @click="exportAllReportToExcel"
  32. ><i class="el-icon-download"></i>Excel</el-button
  33. >
  34. </el-form-item>
  35. <!-- <el-form-item>
  36. <span class="totalWillTonage">合计已预开票吨位</span>
  37. <el-input
  38. v-model="totalWillTonageedValue"
  39. disabled
  40. style="width:80px"
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item>
  44. <span class="totalWillTonage">合计已预开金额</span>
  45. <el-input
  46. v-model="totalWillTonageedMoney"
  47. disabled
  48. style="width:80px"
  49. ></el-input>
  50. </el-form-item>
  51. <el-form-item>
  52. <span class="totalWillTonage">合计本次实际开票吨位</span>
  53. <el-input
  54. v-model="totalActuallyTonageedValue"
  55. disabled
  56. style="width:80px"
  57. ></el-input>
  58. </el-form-item>
  59. <el-form-item>
  60. <span class="totalWillTonage">合计本月实际开票金额</span>
  61. <el-input
  62. v-model="totalActuallyTonageedMoney"
  63. disabled
  64. style="width:80px"
  65. ></el-input>
  66. </el-form-item> -->
  67. </el-form>
  68. </div>
  69. <div class="main">
  70. <el-tabs v-model="activeName" @tab-click="handleClick">
  71. <el-tab-pane label="未结算" name="first">
  72. <el-table
  73. :data="tableData"
  74. ref="tableRef"
  75. border
  76. style="width: 100%; margin-top: 0px"
  77. max-height="500px"
  78. :row-style="{ height: '30px' }"
  79. :cell-style="{ fontWeight: '700' }"
  80. class="table"
  81. :span-method="objectSpanMethod"
  82. >
  83. <el-table-column
  84. prop="index"
  85. width="50"
  86. label="序号"
  87. align="center"
  88. :resizable="false"
  89. >
  90. <template slot-scope="scope">{{ scope.row.group + 1 }}</template>
  91. </el-table-column>
  92. <el-table-column
  93. prop="materialName"
  94. label="品种"
  95. width="120px"
  96. align="center"
  97. >
  98. </el-table-column>
  99. <el-table-column
  100. prop="resultForeignShipName"
  101. label="船名"
  102. width="100px"
  103. align="center"
  104. >
  105. </el-table-column>
  106. <el-table-column
  107. prop="portName"
  108. label="放货港口"
  109. width="120px"
  110. align="center"
  111. >
  112. </el-table-column>
  113. <!-- <el-table-column
  114. prop="carrierName"
  115. label="承运单位"
  116. width="100px"
  117. align="center"
  118. >
  119. </el-table-column> -->
  120. <el-table-column
  121. prop="resultOutPortTime"
  122. label="离港日期"
  123. width="100px"
  124. align="center"
  125. >
  126. </el-table-column>
  127. <el-table-column
  128. prop="monthLoadTonnage"
  129. label="月份装船吨位"
  130. width="100px"
  131. align="center"
  132. >
  133. <template slot-scope="scope" v-if="scope.row.unitPriceId">
  134. {{(scope.row.monthLoadTonnage).toFixed(2)}}
  135. </template>
  136. </el-table-column>
  137. <el-table-column
  138. prop="monthLoadingProportion"
  139. label="月份装船比例"
  140. width="70px"
  141. align="center"
  142. >
  143. <template slot-scope="scope" v-if="scope.row.unitPriceId">
  144. {{(scope.row.monthLoadingProportion*100).toFixed(2)}}%
  145. </template>
  146. </el-table-column>
  147. <el-table-column
  148. prop="monthRealTonnage"
  149. label="月份结算吨位"
  150. width="100px"
  151. align="center"
  152. >
  153. <template slot-scope="scope">
  154. {{(scope.row.monthRealTonnage).toFixed(2)}}
  155. </template>
  156. </el-table-column>
  157. <el-table-column
  158. prop="monthMakeTonnage"
  159. label="月份开票吨位"
  160. width="100px"
  161. align="center"
  162. >
  163. <template slot-scope="scope">
  164. {{(scope.row.monthMakeTonnage).toFixed(2)}}
  165. </template>
  166. </el-table-column>
  167. <el-table-column
  168. prop="totalEnTonnage"
  169. label="到厂湿吨"
  170. width="120px"
  171. align="center"
  172. >
  173. <template slot-scope="scope">
  174. <el-input type="number" v-model="scope.row.totalEnTonnage"></el-input>
  175. </template>
  176. </el-table-column>
  177. <el-table-column
  178. prop="unitPrice"
  179. label="合同单价"
  180. width="100px"
  181. align="center"
  182. >
  183. </el-table-column>
  184. <el-table-column
  185. prop="inspectionsFee"
  186. label="水分检测费"
  187. width="120px"
  188. align="center"
  189. >
  190. <template slot-scope="scope">
  191. <el-input type="number" v-model="scope.row.inspectionsFee"></el-input>
  192. </template>
  193. </el-table-column>
  194. <el-table-column
  195. prop="totalPreviewTonnage"
  196. label="已预开总吨位"
  197. width="120px"
  198. align="center"
  199. >
  200. <template slot-scope="scope">
  201. <el-input type="number" v-model="scope.row.totalPreviewTonnage"></el-input>
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. prop="totalPreviewFee"
  206. label="已预开总金额"
  207. width="120px"
  208. align="center"
  209. >
  210. <template slot-scope="scope" v-if="scope.row.totalPreviewFee">
  211. {{(scope.row.totalPreviewFee).toFixed(2)}}
  212. </template>
  213. </el-table-column>
  214. <el-table-column
  215. prop="statementTotalAmount"
  216. label="开票金额"
  217. width="100px"
  218. align="center"
  219. >
  220. </el-table-column>
  221. <!-- <el-table-column
  222. prop="feeMake"
  223. label="本月实际开票金额"
  224. align="center"
  225. >
  226. </el-table-column> -->
  227. <el-table-column
  228. prop="operate"
  229. label="操作"
  230. width="100px"
  231. align="center"
  232. fixed="right"
  233. >
  234. <template slot-scope="scope">
  235. <el-button type="text" @click="operate(scope.row)"
  236. >预开票</el-button
  237. >
  238. <el-button type="text" @click="settlement(scope.row)"
  239. >结算</el-button
  240. >
  241. </template>
  242. </el-table-column>
  243. </el-table>
  244. </el-tab-pane>
  245. <el-tab-pane label="已结算" name="second">
  246. <el-table
  247. :data="tableData1"
  248. ref="tableRef"
  249. border
  250. style="width: 100%; margin-top: 0px"
  251. max-height="500px"
  252. :row-style="{ height: '30px' }"
  253. :cell-style="{ fontWeight: '700' }"
  254. class="table"
  255. :span-method="objectSpanMethod1"
  256. >
  257. <el-table-column
  258. prop="index"
  259. width="50"
  260. label="序号"
  261. align="center"
  262. :resizable="false"
  263. >
  264. <template slot-scope="scope">{{ scope.row.group + 1 }}</template>
  265. </el-table-column>
  266. <el-table-column
  267. prop="materialName"
  268. label="品种"
  269. width="120px"
  270. align="center"
  271. >
  272. </el-table-column>
  273. <el-table-column
  274. prop="resultForeignShipName"
  275. label="船名"
  276. width="100px"
  277. align="center"
  278. >
  279. </el-table-column>
  280. <el-table-column
  281. prop="portName"
  282. label="放货港口"
  283. width="120px"
  284. align="center"
  285. >
  286. </el-table-column>
  287. <!-- <el-table-column
  288. prop="carrierName"
  289. label="承运单位"
  290. width="100px"
  291. align="center"
  292. >
  293. </el-table-column> -->
  294. <el-table-column
  295. prop="resultOutPortTime"
  296. label="离港日期"
  297. width="100px"
  298. align="center"
  299. >
  300. </el-table-column>
  301. <el-table-column
  302. prop="monthMakeTonnage"
  303. label="月份开票吨位"
  304. width="100px"
  305. align="center"
  306. >
  307. </el-table-column>
  308. <el-table-column
  309. prop="unitPrice"
  310. label="合同单价"
  311. width="100px"
  312. align="center"
  313. >
  314. </el-table-column>
  315. <el-table-column
  316. prop="inspectionsFee"
  317. label="水分检测费"
  318. width="120px"
  319. align="center"
  320. >
  321. </el-table-column>
  322. <el-table-column
  323. prop="totalPreviewTonnage"
  324. label="已预开总吨位"
  325. width="120px"
  326. align="center"
  327. >
  328. </el-table-column>
  329. <el-table-column
  330. prop="totalPreviewFee"
  331. label="已预开总金额"
  332. width="120px"
  333. align="center"
  334. >
  335. </el-table-column>
  336. <el-table-column
  337. prop="statementTotalAmount"
  338. label="开票金额"
  339. width="100px"
  340. align="center"
  341. >
  342. </el-table-column>
  343. <el-table-column
  344. prop="monthLoadTonnage"
  345. label="月份装船吨位"
  346. width="100px"
  347. align="center"
  348. >
  349. </el-table-column>
  350. <el-table-column
  351. prop="monthLoadingProportion"
  352. label="月份装船比例"
  353. width="70px"
  354. align="center"
  355. >
  356. <template slot-scope="scope" >
  357. {{(scope.row.monthLoadingProportion*100).toFixed(2)}}%
  358. </template>
  359. </el-table-column>
  360. <el-table-column
  361. prop="monthRealTonnage"
  362. label="月份结算吨位"
  363. width="100px"
  364. align="center"
  365. >
  366. </el-table-column>
  367. </el-table>
  368. </el-tab-pane>
  369. </el-tabs>
  370. </div>
  371. </div>
  372. </template>
  373. <script>
  374. import { getCookie } from "@/utils/util.js";
  375. import { sjTime } from "@/utils/sharedJsFile";
  376. import BigNumber, {bigNumber} from "bignumber.js"
  377. export default {
  378. data() {
  379. return {
  380. totalWillTonageedValue: 0,
  381. totalWillTonageedMoney: 0,
  382. totalActuallyTonageedMoney: 0,
  383. totalActuallyTonageedValue: 0,
  384. shipName: null,
  385. tableData: [],
  386. tableData1: [],
  387. spanArr: [],
  388. spanArr1: [],
  389. pos: null,
  390. mergeList: [
  391. "index",
  392. "resultForeignShipName",
  393. "materialName",
  394. "totalEnTonnage",
  395. "operate",
  396. ],
  397. activeName: "first",
  398. tableTitle: "结算账单报表",
  399. startTime: null,
  400. endTime: null
  401. };
  402. },
  403. watch: {
  404. tableData: {
  405. handler(newVal) {
  406. console.log("执行一次汇总函数");
  407. this.computedTableData(newVal);
  408. },
  409. deep: true,
  410. immediate: false
  411. },
  412. tableData1: {
  413. handler(newVal) {
  414. //console.log("执行一次汇总函数");
  415. //this.computedTableData1(newVal);
  416. },
  417. deep: true,
  418. immediate: false
  419. }
  420. },
  421. methods: {
  422. //结算
  423. settlement(row) {
  424. console.log("row:",row);
  425. //遍历tableData,找出相同批次的行数
  426. let arr = this.tableData.filter(e => {
  427. return e.batchId == row.batchId;
  428. });
  429. let map = {
  430. list: arr,
  431. userId: getCookie("userId"),
  432. statementStatus:1
  433. };
  434. console.log("map:",map);
  435. this.axios
  436. .post("/api/v1/bms/addShipFeeStatement", map)
  437. .then(res => {
  438. if (res.data.code == "200") {
  439. this.getNoDetailsStament();
  440. this.$message.success("结算成功");
  441. }
  442. })
  443. .catch(() => {
  444. this.$message.error("结算失败");
  445. });
  446. },
  447. //预开保存
  448. operate(row) {
  449. console.log("row:",row);
  450. //遍历tableData,找出相同批次的行数
  451. let arr = this.tableData.filter(e => {
  452. return e.batchId == row.batchId;
  453. });
  454. let map = {
  455. list: arr,
  456. userId: getCookie("userId"),
  457. statementStatus:0
  458. };
  459. console.log("map:",map);
  460. this.axios
  461. .post("/api/v1/bms/addShipFeeStatement", map)
  462. .then(res => {
  463. if (res.data.code == "200") {
  464. this.getNoDetailsStament();
  465. this.$message.success("预开成功");
  466. }
  467. })
  468. .catch(() => {
  469. this.$message.error("预开失败");
  470. });
  471. },
  472. //处理表格数据
  473. computedTableData(data) {
  474. data.forEach((item, index) => {
  475. if (index == 0) {
  476. } else if (item.batchId == data[index - 1].batchId) {
  477. item.totalEnTonnage = data[index - 1].totalEnTonnage;
  478. }
  479. //总计预开票金额
  480. item.totalPreviewFee=item.totalPreviewTonnage*item.unitPrice;
  481. //月份结算吨位/
  482. item.monthRealTonnage = item.totalEnTonnage*item.monthLoadingProportion;
  483. //月份开票吨位
  484. item.monthMakeTonnage = item.monthRealTonnage-item.totalPreviewTonnage;
  485. //月份开票金额
  486. item.statementTotalAmount=(item.monthMakeTonnage.toFixed(2)*item.unitPrice-item.inspectionsFee).toFixed(2);
  487. });
  488. this.getSpanArr(this.tableData);
  489. },
  490. //根据表格据汇总顶部展示
  491. getTotalArr(data) {
  492. this.totalWillTonageedValue = data.reduce((pre, item) => {
  493. return pre + item.willTonanged;
  494. }, 0);
  495. this.totalWillTonageedMoney = data.reduce((pre, item) => {
  496. return pre + item.willMoneyed;
  497. });
  498. this.totalActuallyTonageedValue = data.reduce((pre, item) => {
  499. return pre + item.actuallyMoney;
  500. });
  501. this.totalActuallyTonageedMoney = data.reduce((pre, item) => {
  502. return pre + item.actuallyMonthMoney;
  503. });
  504. },
  505. handleClick() {
  506. console.log("我正在进行账单");
  507. },
  508. onClick() {
  509. if(this.activeName=='first'){
  510. this.getNoDetailsStament();
  511. }else if(this.activeName=='second'){
  512. this.getDetailsStamented();
  513. }
  514. },
  515. //获取未结算账单数据
  516. getNoDetailsStament() {
  517. let startTime = null;
  518. let endTime = null;
  519. let map={con:this.shipName};
  520. // if (this.startTime) {
  521. // startTime = sjTime(this.startTime);
  522. // }
  523. // if (this.endTime) {
  524. // endTime = sjTime(this.endTime);
  525. // }
  526. // if(startTime && endTime && startTime < endTime){
  527. // map.startTime=startTime;
  528. // map.endTime=endTime;
  529. // }
  530. this.axios.post("/api/v1/bms/getShipFeeStatement",map).then(res => {
  531. console.log(res.data.data);
  532. this.tableData = res.data.data;
  533. this.computedTableData(this.tableData);
  534. });
  535. },
  536. //已结算账单数据
  537. getDetailsStamented() {
  538. let startTime = null;
  539. let endTime = null;
  540. let map={con:this.shipName};
  541. if (this.startTime) {
  542. startTime = sjTime(this.startTime);
  543. }
  544. if (this.endTime) {
  545. endTime = sjTime(this.endTime);
  546. }
  547. if(startTime && endTime && startTime < endTime){
  548. map.startTime=startTime;
  549. map.endTime=endTime;
  550. }
  551. this.axios.post("/api/v1/bms/getShipFeeStatemented",map).then(res => {
  552. console.log(res.data.data);
  553. this.tableData1 = res.data.data;
  554. this.getSpanArr1(this.tableData1);
  555. });
  556. },
  557. //合并表格数据
  558. getSpanArr(data) {
  559. //每次调用方法初始化
  560. this.spanArr = [];
  561. for (var i = 0; i < data.length; i++) {
  562. if (i === 0) {
  563. this.spanArr.push(1);
  564. data[i].group = i;
  565. this.pos = 0;
  566. } else {
  567. // 判断当前元素与上一个元素是否相同
  568. if (data[i].batchId === data[i - 1].batchId) {
  569. this.spanArr[this.pos] += 1;
  570. data[i].group = data[i - 1].group;
  571. this.spanArr.push(0);
  572. } else {
  573. this.spanArr.push(1);
  574. this.pos = i;
  575. data[i].group = data[i - 1].group + 1;
  576. }
  577. }
  578. }
  579. },
  580. //合并表格数据
  581. getSpanArr1(data) {
  582. //每次调用方法初始化
  583. this.spanArr1 = [];
  584. for (var i = 0; i < data.length; i++) {
  585. if (i === 0) {
  586. this.spanArr1.push(1);
  587. data[i].group = i;
  588. this.pos = 0;
  589. } else {
  590. // 判断当前元素与上一个元素是否相同
  591. if (data[i].batchId === data[i - 1].batchId) {
  592. this.spanArr1[this.pos] += 1;
  593. data[i].group = data[i - 1].group;
  594. this.spanArr1.push(0);
  595. } else {
  596. this.spanArr1.push(1);
  597. this.pos = i;
  598. data[i].group = data[i - 1].group + 1;
  599. }
  600. }
  601. }
  602. },
  603. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  604. if (this.mergeList.includes(column.property)) {
  605. const _row = this.spanArr[rowIndex];
  606. const _col = _row > 0 ? 1 : 0;
  607. return {
  608. rowspan: _row,
  609. colspan: _col
  610. };
  611. }
  612. },
  613. objectSpanMethod1({ row, column, rowIndex, columnIndex }) {
  614. if (this.mergeList.includes(column.property)) {
  615. const _row = this.spanArr1[rowIndex];
  616. const _col = _row > 0 ? 1 : 0;
  617. return {
  618. rowspan: _row,
  619. colspan: _col
  620. };
  621. }
  622. },
  623. //导出账单数据
  624. exportAllReportToExcel() {
  625. console.log(this.$refs.tableRef);
  626. const loading = this.$loading({
  627. lock: true,
  628. text: "正在导出Excel",
  629. spinner: "el-icon-loading",
  630. background: "rgba(0, 0, 0, 0.7)"
  631. });
  632. var title = this.tableTitle;
  633. let tHeader = [];
  634. let filterVal = [];
  635. let data = [];
  636. if (this.activeName == "first") {
  637. data = this.$refs.tableRef.$children;
  638. } else {
  639. data = this.$refs.tableRef1.$children;
  640. }
  641. data.forEach(item => {
  642. if (item.label != undefined && item.prop != undefined) {
  643. if (tHeader.indexOf(item.label) === -1) {
  644. tHeader.push(item.label);
  645. }
  646. if (filterVal.indexOf(item.prop) === -1) {
  647. filterVal.push(item.prop);
  648. }
  649. }
  650. });
  651. this.downloadLoading = true;
  652. require.ensure([], () => {
  653. const {
  654. export_json_to_excel
  655. } = require("@/assets/excel/Export2Excel.js"); //这里必须使用绝对路径,使用@/+存放export2Excel的路径
  656. let data = this.tableData.map(v => filterVal.map(j => v[j])); //3.formatJson格式转换
  657. export_json_to_excel(tHeader, data, title); // (title)导出的表格名称
  658. });
  659. loading.close();
  660. }
  661. },
  662. mounted() {
  663. this.getNoDetailsStament();
  664. this.getDetailsStamented();
  665. }
  666. };
  667. </script>
  668. <style lang="scss" scoped>
  669. #detailsStatement {
  670. .top {
  671. margin-left: 10px;
  672. margin-top: 10px;
  673. }
  674. .main {
  675. margin-left: 10px;
  676. ::-webkit-scrollbar {
  677. // width: 20px;
  678. height: 20px;
  679. background-color: transparent;
  680. }
  681. }
  682. }
  683. </style>