index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <div class="airportInfo">
  3. <div class="header">
  4. <div
  5. :class="action === index ? 'navs' : 'nav'"
  6. v-for="(item, index) in levelList"
  7. :key="index"
  8. @click="up(index)"
  9. >
  10. {{ item.name }}
  11. </div>
  12. </div>
  13. <div class="variable">
  14. <StatisticsHeader
  15. :title="titleTop"
  16. :items="formItems"
  17. :data="formData"
  18. :eledata="eledata"
  19. with-setting
  20. :withSetting="false"
  21. :withExport="true"
  22. :set="set"
  23. @getFormData="getFormData"
  24. @export="tableToExcel"
  25. @upset="upset"
  26. />
  27. </div>
  28. <div class="echart">
  29. <Echarts
  30. :id="dataid"
  31. :option="tableData"
  32. v-if="picShow == true ? true : false"
  33. />
  34. <Tableformbrs
  35. :tableList="tableList"
  36. :action="action"
  37. v-if="!picShow"
  38. :set="set"
  39. />
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import Echarts from "../components/echart/index.vue";
  45. import Tableformbrs from "../components/echart/tableforms.vue";
  46. import StatisticsHeader from "../components/echart/statisticsHeader.vue";
  47. import { export_json_to_excel } from "@/utils/Export2Excel";
  48. import { Query } from "@/api/webApi";
  49. export default {
  50. name: "ChartsBar",
  51. data() {
  52. return {
  53. picShow: true, //图片表格切换
  54. action: 0,
  55. dataid: "collection_ecahrt0",
  56. listqueryTemplateID: DATACONTENT_ID.modeLoadingweight,
  57. eledata: null,
  58. set: "",
  59. isShow: Echarts,
  60. tableList: [],
  61. tableListcop: [],
  62. listname: "",
  63. listHeader: [],
  64. tableData: {
  65. time: [],
  66. data1: [],
  67. data2: [],
  68. kg: "",
  69. tyol: "",
  70. },
  71. formData: {
  72. airport: "",
  73. dateTime: "",
  74. },
  75. titleTop: "加货重量统计",
  76. levelList: [
  77. {
  78. name: "加货重量统计",
  79. },
  80. {
  81. name: "航班量统计",
  82. },
  83. {
  84. name: "特货统计",
  85. },
  86. {
  87. name: "货量统计",
  88. },
  89. {
  90. name: "拉货统计",
  91. },
  92. ],
  93. formItems: [
  94. {
  95. prop: "fttp",
  96. inputType: "select",
  97. placeholder: "国内国际",
  98. requiredWarning: "请先选择国内国际",
  99. clearable: true,
  100. options: [
  101. {
  102. value: "国内离港",
  103. label: "国内离港",
  104. },
  105. {
  106. value: "国际离港",
  107. label: "国际离港",
  108. },
  109. ],
  110. },
  111. {
  112. prop: "kht",
  113. inputType: "select",
  114. placeholder: "客货类型",
  115. requiredWarning: "请先选择客货类型",
  116. clearable: true,
  117. options: [
  118. {
  119. value: "客机",
  120. label: "客机",
  121. },
  122. {
  123. value: "货机",
  124. label: "货机",
  125. },
  126. {
  127. value: "其它",
  128. label: "其它",
  129. },
  130. {
  131. value: "全部",
  132. label: "全部",
  133. },
  134. ],
  135. },
  136. {
  137. prop: "td",
  138. inputType: "select",
  139. placeholder: "统计维度",
  140. requiredWarning: "请先选择统计时间维度",
  141. clearable: true,
  142. options: [
  143. {
  144. value: "月",
  145. label: "月",
  146. },
  147. {
  148. value: "年",
  149. label: "年",
  150. },
  151. ],
  152. },
  153. {
  154. prop: "spe",
  155. inputType: "select",
  156. placeholder: "特货类型",
  157. requiredWarning: "",
  158. clearable: true,
  159. disabled: true,
  160. options: [
  161. {
  162. value: "贵重物品",
  163. label: "贵重物品",
  164. },
  165. {
  166. value: "鲜活",
  167. label: "鲜活",
  168. },
  169. {
  170. value: "动物",
  171. label: "动物",
  172. },
  173. {
  174. value: "邮件",
  175. label: "邮件",
  176. },
  177. {
  178. value: "锂电池",
  179. label: "锂电池",
  180. },
  181. {
  182. value: "全部",
  183. label: "全部",
  184. },
  185. ],
  186. },
  187. {
  188. prop: "set",
  189. inputType: "select",
  190. placeholder: "统计运单",
  191. requiredWarning: "",
  192. clearable: true,
  193. disabled: true,
  194. options: [
  195. {
  196. value: "1",
  197. label: "统计运单",
  198. },
  199. {
  200. value: "2",
  201. label: "统计重量",
  202. },
  203. ],
  204. },
  205. {
  206. prop: "dateTime",
  207. inputType: "datePicker",
  208. clearable: true,
  209. width: "240px",
  210. options: [],
  211. },
  212. ],
  213. };
  214. },
  215. mounted() {
  216. // this.getQuery([]);
  217. },
  218. watch: {
  219. // 监听数据变化,重绘折线图
  220. option: {
  221. deep: true,
  222. handler(newVal) {},
  223. },
  224. },
  225. destroyed() {},
  226. methods: {
  227. up(index) {
  228. this.action = index;
  229. if (index === 0) {
  230. this.eledata = 0;
  231. this.dataid = "collection_ecahrt0";
  232. this.listqueryTemplateID = DATACONTENT_ID.modeLoadingweight;
  233. this.titleTop = "加货重量统计";
  234. this.tableData.time = [];
  235. this.tableData.data1 = [];
  236. this.tableData.data2 = [];
  237. this.formItems[3].disabled = true;
  238. this.formItems[4].disabled = true;
  239. this.formItems[0].options = [
  240. {
  241. value: "国内离港",
  242. label: "国内离港",
  243. },
  244. {
  245. value: "国际离港",
  246. label: "国际离港",
  247. },
  248. ];
  249. } else if (index === 1) {
  250. this.eledata = 1;
  251. this.dataid = "collection_ecahrt1";
  252. this.formItems[3].disabled = true;
  253. this.formItems[4].disabled = true;
  254. this.formItems[0].options = [
  255. {
  256. value: "国内离港",
  257. label: "国内离港",
  258. },
  259. {
  260. value: "国际离港",
  261. label: "国际离港",
  262. },
  263. {
  264. value: "国内进港",
  265. label: "国内进港",
  266. },
  267. {
  268. value: "国际进港",
  269. label: "国际进港",
  270. },
  271. ];
  272. this.tableData.time = [];
  273. this.tableData.data1 = [];
  274. this.tableData.data2 = [];
  275. this.listqueryTemplateID = DATACONTENT_ID.modeFlightvolume;
  276. // this.getQuery();
  277. this.titleTop = "航班量统计";
  278. } else if (index === 2) {
  279. this.dataid = "collection_ecahrt2";
  280. this.formItems[3].disabled = false;
  281. this.formItems[4].disabled = false;
  282. this.tableData.time = [];
  283. this.tableData.data1 = [];
  284. this.tableData.data2 = [];
  285. this.formItems[0].options = [
  286. {
  287. value: "国内离港",
  288. label: "国内离港",
  289. },
  290. {
  291. value: "国际离港",
  292. label: "国际离港",
  293. },
  294. {
  295. value: "国内进港",
  296. label: "国内进港",
  297. },
  298. {
  299. value: "国际进港",
  300. label: "国际进港",
  301. },
  302. ];
  303. this.eledata = 2;
  304. this.listqueryTemplateID = DATACONTENT_ID.modeSpecialgoods;
  305. this.titleTop = "特货统计";
  306. } else if (index === 3) {
  307. this.dataid = "collection_ecahrt3";
  308. this.tableData.time = [];
  309. this.tableData.data1 = [];
  310. this.tableData.data2 = [];
  311. this.formItems[0].options = [
  312. {
  313. value: "国内离港",
  314. label: "国内离港",
  315. },
  316. {
  317. value: "国际离港",
  318. label: "国际离港",
  319. },
  320. {
  321. value: "国内进港",
  322. label: "国内进港",
  323. },
  324. {
  325. value: "国际进港",
  326. label: "国际进港",
  327. },
  328. ];
  329. this.formItems[3].disabled = true;
  330. this.formItems[4].disabled = true;
  331. this.eledata = 3;
  332. this.titleTop = "货量统计";
  333. this.listqueryTemplateID = DATACONTENT_ID.modeCargostatistics;
  334. } else if (index === 4) {
  335. this.dataid = "collection_ecahrt3";
  336. this.tableData.time = [];
  337. this.tableData.data1 = [];
  338. this.tableData.data2 = [];
  339. this.formItems[0].options = [
  340. {
  341. value: "国内离港",
  342. label: "国内离港",
  343. },
  344. {
  345. value: "国际离港",
  346. label: "国际离港",
  347. },
  348. {
  349. value: "国内进港",
  350. label: "国内进港",
  351. },
  352. {
  353. value: "国际进港",
  354. label: "国际进港",
  355. },
  356. ];
  357. this.formItems[3].disabled = true;
  358. this.formItems[4].disabled = false;
  359. this.eledata = 3;
  360. this.titleTop = "拉货统计";
  361. this.listqueryTemplateID = DATACONTENT_ID.modePullgoods;
  362. }
  363. },
  364. getFormData(data) {
  365. this.tableData.time = [];
  366. this.tableData.data1 = [];
  367. this.tableData.data2 = [];
  368. if (this.action === 2 || this.action === 4) {
  369. this.set = data.set;
  370. let option = [
  371. {
  372. fttp: data.fttp,
  373. kht: data.kht,
  374. td: data.td,
  375. fd1: data.dateTime[0],
  376. fd2: data.dateTime[1],
  377. spe: data.spe,
  378. },
  379. ];
  380. this.getQuery(option, data.set);
  381. } else {
  382. let option = [
  383. {
  384. fttp: data.fttp,
  385. kht: data.kht,
  386. td: data.td,
  387. fd1: data.dateTime[0],
  388. fd2: data.dateTime[1],
  389. },
  390. ];
  391. this.getQuery(option, null);
  392. }
  393. if (this.action === 0) {
  394. this.listname =
  395. "加货重量统计" +
  396. data.fttp +
  397. data.kht +
  398. data.td +
  399. data.dateTime[0] +
  400. "--" +
  401. data.dateTime[1];
  402. this.listHeader = ["序号", "时间", "重量", "环比"];
  403. } else if (this.action === 1) {
  404. this.listname =
  405. "航班量统计" +
  406. data.fttp +
  407. data.kht +
  408. data.td +
  409. data.dateTime[0] +
  410. "--" +
  411. data.dateTime[1];
  412. this.listHeader = ["序号", "时间", "重量", "环比"];
  413. } else if (this.action === 2) {
  414. this.listname =
  415. "特货统计" +
  416. data.fttp +
  417. data.kht +
  418. data.td +
  419. data.spe +
  420. data.dateTime[0] +
  421. "--" +
  422. data.dateTime[1];
  423. if (data.set == 1) {
  424. this.listHeader = ["序号", "时间", "单", "环比"];
  425. } else if (data.set == 2) {
  426. this.listHeader = ["序号", "时间", "重量", "环比"];
  427. }
  428. } else if (this.action === 3) {
  429. this.listname =
  430. "货量统计" +
  431. data.fttp +
  432. data.kht +
  433. data.td +
  434. data.dateTime[0] +
  435. "--" +
  436. data.dateTime[1];
  437. this.listHeader = ["序号", "时间", "重量", "环比"];
  438. } else if (this.action === 4) {
  439. this.listname =
  440. "拉货统计" +
  441. data.fttp +
  442. data.kht +
  443. data.td +
  444. data.dateTime[0] +
  445. "--" +
  446. data.dateTime[1];
  447. if (data.set == 1) {
  448. this.listHeader = ["序号", "时间", "单", "环比"];
  449. } else if (data.set == 2) {
  450. this.listHeader = ["序号", "时间", "重量", "环比"];
  451. }
  452. }
  453. },
  454. //获取表格数据
  455. async getQuery(data, dat) {
  456. try {
  457. const { code, returnData } = await Query({
  458. id: this.listqueryTemplateID,
  459. dataContent: data,
  460. });
  461. if (code == 0) {
  462. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  463. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  464. this.tableList.forEach((item, index) => {
  465. item.indexs = index + 1;
  466. });
  467. this.tableListcop.forEach((item, index) => {
  468. item.indexs = index + 1;
  469. });
  470. if (this.action === 0) {
  471. let objar = {
  472. indexs: "合计",
  473. weight: returnData.listValues[0].totalWeight,
  474. };
  475. this.tableListcop.push(objar);
  476. } else if (this.action === 1) {
  477. let objar = {
  478. indexs: "合计",
  479. weight: returnData.listValues[0].totalWeight,
  480. };
  481. } else if (this.action === 2) {
  482. let objar = {
  483. indexs: "合计",
  484. weight:
  485. dat == 1
  486. ? returnData.listValues[0].totalFlightNum
  487. : returnData.listValues[0].totalWeight,
  488. };
  489. } else if (this.action === 3) {
  490. let objar = {
  491. indexs: "合计",
  492. weight: returnData.listValues[0].totalWeight,
  493. };
  494. } else if (this.action === 4) {
  495. let objar = {
  496. indexs: "合计",
  497. weight:
  498. dat == 1
  499. ? returnData.listValues[0].totalFlightNum
  500. : returnData.listValues[0].totalWeight,
  501. };
  502. }
  503. returnData.listValues.forEach((element) => {
  504. if (this.action === 0) {
  505. this.tableData.data2.push(element.weight ? element.weight : 0);
  506. this.tableData.time.push(element.dat);
  507. this.tableData.kg = "单位:吨";
  508. } else if (this.action === 1) {
  509. this.tableData.data2.push(
  510. element.flightNum ? element.flightNum : 0
  511. );
  512. this.tableData.time.push(element.dat);
  513. this.tableData.kg = "单位:班";
  514. } else if (this.action === 2) {
  515. this.tableData.time.push(element.dat);
  516. if (dat == 1) {
  517. this.tableData.data2.push(
  518. element.flightNum ? element.flightNum : 0
  519. );
  520. this.tableData.kg = "单位:单";
  521. } else if (dat == 2) {
  522. this.tableData.kg = "单位:吨";
  523. this.tableData.data2.push(element.weight ? element.weight : 0);
  524. }
  525. } else if (this.action === 3) {
  526. this.tableData.data2.push(element.weight ? element.weight : 0);
  527. this.tableData.time.push(element.fdt);
  528. this.tableData.kg = "单位:吨";
  529. } else if (this.action === 4) {
  530. this.tableData.time.push(element.dat);
  531. this.tableData.kg = "单位:吨";
  532. if (dat == 1) {
  533. this.tableData.data2.push(
  534. element.pullFlightNum ? element.pullFlightNum : 0
  535. );
  536. this.tableData.kg = "单位:单";
  537. } else if (dat == 2) {
  538. this.tableData.kg = "单位:吨";
  539. this.tableData.data2.push(
  540. element.pullWeight ? element.pullWeight : 0
  541. );
  542. }
  543. }
  544. this.tableData.data1 = [];
  545. });
  546. this.tableData.data1.push(0);
  547. for (let index = 0; index < this.tableData.data2.length; index++) {
  548. // const element =
  549. // (this.tableData.data2[index + 1] - this.tableData.data2[index]) /
  550. // this.tableData.data2[index];
  551. // console.log(element);
  552. if (index > 0) {
  553. const element =
  554. (this.tableData.data2[index] -
  555. this.tableData.data2[index - 1]) /
  556. this.tableData.data2[index - 1];
  557. this.tableData.data1.push(
  558. element.toFixed(2) ? element.toFixed(2) : 0
  559. );
  560. this.tableData.data1.forEach((element) => {
  561. element = Number(element);
  562. if (typeof element !== "number") {
  563. element = 0;
  564. }
  565. });
  566. }
  567. }
  568. // this.tableData = returnData.listValues;
  569. // console.log(this.tableData[0])
  570. }
  571. } catch (error) {
  572. this.page--;
  573. }
  574. },
  575. //导出
  576. tableToExcel() {
  577. import("../../../utils/Export2Excel").then((excel) => {
  578. // 设置导出表格的头部
  579. const tHeader = this.listHeader;
  580. // 将要导出的数据进行一个过滤
  581. /**
  582. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  583. */
  584. const data = this.tableListcop.map((item, index) => {
  585. if (this.action === 0) {
  586. return [item.indexs, item.dat, item.weight, item.weightChain];
  587. } else if (this.action === 1) {
  588. return [item.indexs, item.dat, item.flightNum, item.weightChain];
  589. } else if (this.action === 2) {
  590. if (this.set == 1) {
  591. return [item.indexs, item.dat, item.flightNum, item.weightChain];
  592. } else if (this.set == 2) {
  593. return [item.indexs, item.dat, item.weight, item.weightChain];
  594. }
  595. } else if (this.action === 3) {
  596. return [item.indexs, item.fdt, item.weight, item.weightChain];
  597. } else if (this.action === 4) {
  598. if (this.set == 1) {
  599. return [
  600. item.indexs,
  601. item.dat,
  602. item.pullFlightNum,
  603. item.flightChain,
  604. ];
  605. } else if (this.set == 2) {
  606. return [item.indexs, item.dat, item.pullWeight, item.weightChain];
  607. }
  608. }
  609. });
  610. data[data.length - 1].indexs = "总计";
  611. // 调用我们封装好的方法进行导出Excel
  612. excel.export_json_to_excel({
  613. // 导出的头部
  614. header: tHeader,
  615. // 导出的内容
  616. data,
  617. // 导出的文件名称
  618. filename: this.listname,
  619. // 导出的表格宽度是否自动
  620. autoWidth: true,
  621. // 导出文件的后缀类型
  622. bookType: "xlsx",
  623. });
  624. });
  625. },
  626. upset(data) {
  627. this.picShow = data;
  628. },
  629. },
  630. components: {
  631. Echarts,
  632. StatisticsHeader,
  633. Tableformbrs,
  634. },
  635. };
  636. </script>
  637. <style lang="scss" scoped>
  638. .airportInfo {
  639. position: relative;
  640. .header {
  641. width: 103%;
  642. height: 36px;
  643. display: flex;
  644. align-items: center;
  645. justify-content: center;
  646. background: #f7f7f7;
  647. position: relative;
  648. left: -23px;
  649. > .nav {
  650. padding: 0 30px 0 30px;
  651. cursor: pointer;
  652. font-size: 16px;
  653. font-family: Microsoft YaHei;
  654. font-weight: 400;
  655. color: #101116;
  656. }
  657. > .navs {
  658. height: 100%;
  659. padding: 0 30px 0 30px;
  660. cursor: pointer;
  661. display: flex;
  662. align-items: center;
  663. font-size: 16px;
  664. font-family: Microsoft YaHei;
  665. font-weight: bold;
  666. color: #ac014d;
  667. border-bottom: 2px solid #ac014d;
  668. }
  669. }
  670. .variable {
  671. width: 100%;
  672. height: 64px;
  673. }
  674. .echart {
  675. width: 100%;
  676. height: 710px;
  677. position: absolute;
  678. background: #ffffff;
  679. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  680. border-radius: 4px;
  681. }
  682. }
  683. </style>