Index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. <template>
  2. <div v-loading="isLoading" style="height: 100%">
  3. <div class="df main">
  4. <div class="left">
  5. <AMapContainer
  6. ref="mapRef"
  7. class="map-container"
  8. :ships="ships"
  9. :showLabel="true"
  10. :handleAble="true"
  11. ></AMapContainer>
  12. <div class="df aic tabs">
  13. <div
  14. @click="changeVoyageType(0)"
  15. :class="
  16. status == 0
  17. ? 'currentbtn radio-btns left-radius'
  18. : 'radio-btns left-radius'
  19. "
  20. >
  21. 全部航次
  22. </div>
  23. <div
  24. style="border-left: none"
  25. @click="changeVoyageType(1)"
  26. :class="status == 1 ? 'currentbtn radio-btns' : 'radio-btns'"
  27. >
  28. 装货中
  29. </div>
  30. <div
  31. style="border-left: none"
  32. @click="changeVoyageType(2)"
  33. :class="status == 2 ? 'currentbtn radio-btns' : 'radio-btns'"
  34. >
  35. 运输中
  36. </div>
  37. <div
  38. style="border-left: none"
  39. @click="changeVoyageType(3)"
  40. :class="
  41. status == 3
  42. ? 'currentbtn radio-btns right-radius'
  43. : 'radio-btns right-radius '
  44. "
  45. >
  46. 卸货中
  47. </div>
  48. </div>
  49. <div class="df aic filter">
  50. <div class="mr4">装货港</div>
  51. <el-select
  52. style="width: 90px"
  53. v-model="postData.loadPortId"
  54. placeholder="装货港"
  55. size="mini"
  56. @change="getIndexData(1)"
  57. filterable
  58. clearable
  59. >
  60. <el-option
  61. v-for="item in loadPortOptions"
  62. :key="item"
  63. :label="item.value"
  64. :value="item.key"
  65. />
  66. </el-select>
  67. <div class="mr4 mr10">卸货港</div>
  68. <el-select
  69. style="width: 90px"
  70. v-model="postData.discPortId"
  71. placeholder="卸货港"
  72. size="mini"
  73. @change="getIndexData(1)"
  74. filterable
  75. clearable
  76. >
  77. <el-option
  78. v-for="item in discPortOptions"
  79. :key="item"
  80. :label="item.value"
  81. :value="item.key"
  82. />
  83. </el-select>
  84. <div class="mr4 mr10">到港状态</div>
  85. <el-select
  86. style="width: 90px"
  87. v-model="postData.isArrived"
  88. placeholder="到港状态"
  89. size="mini"
  90. @change="getIndexData(1)"
  91. >
  92. <el-option label="已到港" :value="0" />
  93. <el-option label="未到港" :value="1" />
  94. </el-select>
  95. <div class="mr4 mr10">航次状态</div>
  96. <el-select
  97. style="width: 90px"
  98. v-model="postData.abnormalStatus"
  99. placeholder="航次状态"
  100. size="mini"
  101. @change="getIndexData(1)"
  102. >
  103. <el-option label="正常" :value="0" />
  104. <el-option label="异常" :value="1" />
  105. </el-select>
  106. <div class="mr4 mr10">货种</div>
  107. <el-select
  108. style="width: 90px"
  109. v-model="postData.cargoId"
  110. placeholder="货种"
  111. size="mini"
  112. @change="getIndexData(1)"
  113. filterable
  114. clearable
  115. >
  116. <el-option
  117. v-for="item in cargoOptions"
  118. :key="item"
  119. :label="item.value"
  120. :value="item.key"
  121. />
  122. </el-select>
  123. <div @click="resetFilter" class="all mr10">全部</div>
  124. </div>
  125. </div>
  126. <div class="right">
  127. <div class="df jcfe">
  128. <el-popover placement="bottom" :width="100" trigger="hover">
  129. <template #reference>
  130. <div class="export">导出报告</div>
  131. </template>
  132. <div
  133. style="
  134. display: flex;
  135. flex-direction: column;
  136. height: 180px;
  137. justify-content: space-between;
  138. align-items: center;
  139. "
  140. >
  141. <div>
  142. <el-button
  143. type="primary"
  144. size="small"
  145. v-auth="'DOWNLOADVOYAGELIST'"
  146. @click="showExportModal('航次列表')"
  147. >
  148. 导出航次列表
  149. </el-button>
  150. </div>
  151. <div>
  152. <el-button
  153. type="primary"
  154. size="small"
  155. v-auth="'MULTDOWNLOADSHIPTRACK'"
  156. @click="showExportModal('航次跟踪')"
  157. >
  158. 导出航次跟踪
  159. </el-button>
  160. </div>
  161. <div>
  162. <el-button
  163. type="primary"
  164. size="small"
  165. @click="showExportModal('卸货记录')"
  166. v-auth="'MULTDOWNLOADDISCHARGE'"
  167. >
  168. 导出卸货记录
  169. </el-button>
  170. </div>
  171. <div>
  172. <el-button
  173. v-auth="'DOWNLOADFYDI'"
  174. type="primary"
  175. size="small"
  176. @click="downloadFYDI"
  177. >
  178. 下载FYDI指数
  179. </el-button>
  180. </div>
  181. </div>
  182. </el-popover>
  183. <el-dialog
  184. v-model="exportModalVisable"
  185. :title="exportModalTitle"
  186. :close-on-click-modal="false"
  187. @close="isLoadingZip = false"
  188. width="200px"
  189. >
  190. <div class="df aic jcsb">
  191. <div
  192. v-if="exportModalTitle != '航次列表' || cargoOwnerId == 7"
  193. class="df aic"
  194. >
  195. <div class="mr20">请选择月份:</div>
  196. <el-date-picker
  197. v-model="currentMonth"
  198. type="month"
  199. placeholder="请选择年月"
  200. value-format="YYYYMM"
  201. :disabled="isLoadingZip"
  202. />
  203. </div>
  204. <div></div>
  205. <el-button
  206. type="primary"
  207. @click="exportZip"
  208. :loading="isLoadingZip"
  209. >
  210. 导出{{ exportModalTitle }}
  211. </el-button>
  212. </div>
  213. </el-dialog>
  214. </div>
  215. <div class="data">
  216. <div class="df aic">
  217. <div class="shu"></div>
  218. <div class="right-title">数据统计</div>
  219. </div>
  220. <div class="df data-line">
  221. <img class="icon" src="../../assets/ship.png" />
  222. <div class="data-text">
  223. <div class="data-title">总航次数</div>
  224. <div class="df aib">
  225. <div class="num">{{ indexData.totalVoyageNum }}</div>
  226. <div class="unit">次</div>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="df data-line">
  231. <img class="icon" src="../../assets/rubber.png" />
  232. <div class="data-text">
  233. <div class="data-title">总实际装载吨数</div>
  234. <div class="df aib">
  235. <div class="num">{{ indexData.totalLoadTons }}</div>
  236. <div class="unit">吨</div>
  237. </div>
  238. </div>
  239. </div>
  240. <div class="df data-line">
  241. <img class="icon" src="../../assets/unload.png" />
  242. <div class="data-text">
  243. <div class="data-title">总已完成卸货吨位</div>
  244. <div class="df aib">
  245. <div class="num">{{ indexData.finshDiscTons }}</div>
  246. <div class="unit">吨</div>
  247. </div>
  248. </div>
  249. </div>
  250. <div class="df data-line">
  251. <img class="icon" src="../../assets/chain.png" />
  252. <div class="data-text">
  253. <div class="data-title">总剩余卸货吨位</div>
  254. <div class="df aib">
  255. <div class="num">{{ indexData.unfinshDiscTons }}</div>
  256. <div class="unit">吨</div>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="pie">
  262. <div class="df aic">
  263. <div class="shu"></div>
  264. <div class="right-title">卸货占比</div>
  265. </div>
  266. <div id="pie" class="card-5">
  267. <div>饼图</div>
  268. <div>卸货</div>
  269. </div>
  270. <div class="df aic jcc mt10">
  271. <div class="pie-point"></div>
  272. <div class="pie-text mr20">已卸货吨位</div>
  273. <div class="pie-point" style="background: #58daea"></div>
  274. <div class="pie-text">剩余卸货吨位</div>
  275. </div>
  276. </div>
  277. </div>
  278. </div>
  279. </div>
  280. </template>
  281. <script setup>
  282. import {
  283. ref,
  284. reactive,
  285. toRefs,
  286. computed,
  287. onMounted,
  288. inject,
  289. nextTick,
  290. onUnmounted,
  291. } from "vue";
  292. import { ElNotification } from "element-plus";
  293. import store from "../../store";
  294. import router from "../../router";
  295. import md5 from "md5";
  296. import api from "../../apis/fetch";
  297. import downloadBlobFile from "../../utils/downloadBlobFile";
  298. import url from "../../apis/config";
  299. let map = ref({});
  300. let cargoOwnerId = localStorage.userId;
  301. let echarts = inject("ec");
  302. let status = ref(3);
  303. const mapRef = ref(null);
  304. function changeVoyageType(s) {
  305. status.value = s;
  306. postData.value = {
  307. loadPortId: "",
  308. discPortId: "",
  309. isArrived: "",
  310. abnormalStatus: "",
  311. cargoId: "",
  312. };
  313. mapRef.value.clearMap();
  314. getIndexSelect();
  315. getIndexData();
  316. }
  317. let postData = ref({
  318. status: 0,
  319. loadPortId: "",
  320. discPortId: "",
  321. isArrived: "",
  322. abnormalStatus: "",
  323. cargoId: "",
  324. });
  325. let indexData = ref({
  326. finshDiscTons: "",
  327. mapPoints: [],
  328. totalLoadTons: "",
  329. totalVoyageNum: "",
  330. unfinshDiscTons: "",
  331. });
  332. let isLoading = ref(false);
  333. const ships = ref([]);
  334. async function getIndexData(type) {
  335. isLoading.value = true;
  336. postData.value.status = status.value;
  337. try {
  338. let res = await api.getIndexData({
  339. ...postData.value,
  340. });
  341. isLoading.value = false;
  342. if (res.data.status == 0) {
  343. indexData.value = res.data.result;
  344. ships.value = indexData.value.mapPoints;
  345. if (type == "init") {
  346. drawPie("init");
  347. } else {
  348. drawPie();
  349. }
  350. await nextTick();
  351. mapRef.value.drawMarkers();
  352. } else {
  353. indexData.value = {
  354. finshDiscTons: 0,
  355. mapPoints: [],
  356. totalLoadTons: 0,
  357. totalVoyageNum: 0,
  358. unfinshDiscTons: 0,
  359. };
  360. if (type == "init") {
  361. drawPie("init");
  362. } else {
  363. drawPie();
  364. mapRef.value.drawMarkers();
  365. }
  366. }
  367. } catch (error) {
  368. console.log(error);
  369. isLoading.value = false;
  370. }
  371. }
  372. let chartDom = ref({});
  373. let myChart = ref({});
  374. function drawPie(type) {
  375. if (!myChart.value.id) {
  376. chartDom.value = document.getElementById("pie");
  377. myChart.value = echarts.init(chartDom.value);
  378. }
  379. if (
  380. indexData.value.finshDiscTons == 0 &&
  381. indexData.value.unfinshDiscTons == 0
  382. ) {
  383. myChart.value.clear();
  384. return;
  385. }
  386. let option;
  387. option = {
  388. grid: {
  389. bottom: 500,
  390. },
  391. tooltip: {
  392. trigger: "item",
  393. },
  394. color: ["#0A6EFA", "#58DAEA"],
  395. series: [
  396. {
  397. center: ["50%", "50%"],
  398. type: "pie",
  399. radius: ["60%", "85%"],
  400. data: [
  401. { value: indexData.value.finshDiscTons, name: "已卸货吨位" },
  402. { value: indexData.value.unfinshDiscTons, name: "剩余卸货吨位" },
  403. ],
  404. emphasis: {
  405. itemStyle: {
  406. shadowBlur: 10,
  407. shadowOffsetX: 0,
  408. shadowColor: "rgba(0, 0, 0, 0.5)",
  409. },
  410. },
  411. label: {
  412. show: true,
  413. position: "inner", // 数值显示在内部
  414. formatter: "{d}%", // 格式化数值百分比输出
  415. },
  416. },
  417. ],
  418. };
  419. myChart.value.setOption(option);
  420. }
  421. let portOptions = ref([]);
  422. async function getPortSelect() {
  423. if (portOptions.value.length) return;
  424. let res = await api.getCol({
  425. term: "",
  426. });
  427. portOptions.value = res.data.result;
  428. }
  429. let loadPortOptions = ref([]);
  430. let discPortOptions = ref([]);
  431. let cargoOptions = ref([]);
  432. async function getCargoSelect() {
  433. if (cargoOptions.value.length) return;
  434. let res = await api.getCargoSelect({
  435. status: 2,
  436. term: "",
  437. });
  438. cargoOptions.value = res.data.result;
  439. }
  440. async function downloadFYDI() {
  441. let res0 = await api.getFYFIDownloadUrl({
  442. loginAccountId: localStorage.loginAccountId,
  443. });
  444. if (res0.data.result == 1) {
  445. ElNotification({
  446. type: "info",
  447. title: "更新中",
  448. });
  449. } else {
  450. let url = res0.data.result;
  451. let a = document.createElement("a");
  452. a.setAttribute("href", url);
  453. a.click();
  454. }
  455. }
  456. let exportModalVisable = ref(false);
  457. let exportModalTitle = ref("");
  458. let currentMonth = ref("");
  459. function showExportModal(type) {
  460. exportModalVisable.value = true;
  461. exportModalTitle.value = type;
  462. }
  463. let isLoadingZip = ref(false);
  464. async function exportZip() {
  465. if (!currentMonth.value && exportModalTitle.value != "航次列表") return;
  466. isLoadingZip.value = true;
  467. let path = "";
  468. let type = "";
  469. let postData = {
  470. loginAccountId: localStorage.loginAccountId,
  471. };
  472. let title = "";
  473. switch (exportModalTitle.value) {
  474. case "航次列表": {
  475. if (localStorage.userId == 7) {
  476. path = "/voyage/exportVoyageReportExcel";
  477. postData.loginAccountId = localStorage.loginAccountId;
  478. postData.date = currentMonth.value;
  479. } else {
  480. path = "/voyage/exportListExcel";
  481. let arr = [];
  482. for (let i of tableData.value) {
  483. arr.push(i.id);
  484. }
  485. postData.voyageIds = arr.join(",");
  486. }
  487. type =
  488. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
  489. title = `${exportModalTitle.value}`;
  490. break;
  491. }
  492. case "航次跟踪": {
  493. path = "/voyage/exportMultExcel";
  494. type = "application/zip";
  495. postData.date = currentMonth.value;
  496. title = `${exportModalTitle.value}${currentMonth.value}`;
  497. break;
  498. }
  499. case "卸货记录": {
  500. path = "/voyage/exportMultDischargeExcel";
  501. type = "application/zip";
  502. postData.date = currentMonth.value;
  503. title = `${exportModalTitle.value}${currentMonth.value}`;
  504. break;
  505. }
  506. }
  507. try {
  508. let res = await downloadBlobFile(
  509. `${url.baseurl}${path}`,
  510. postData,
  511. title,
  512. "post",
  513. type
  514. );
  515. if (res.status == 0) {
  516. ElNotification({
  517. title: "导出成功!",
  518. type: "success",
  519. });
  520. } else {
  521. ElNotification({
  522. title: "暂无数据",
  523. });
  524. }
  525. } catch (error) {
  526. ElNotification({
  527. title: "暂无数据",
  528. });
  529. } finally {
  530. isLoadingZip.value = false;
  531. currentMonth.value = "";
  532. exportModalVisable.value = false;
  533. }
  534. }
  535. function resetFilter() {
  536. postData.value = {
  537. loadPortId: "",
  538. discPortId: "",
  539. isArrived: "",
  540. abnormalStatus: "",
  541. cargoId: "",
  542. };
  543. getIndexData();
  544. }
  545. async function getIndexSelect() {
  546. let res = await api.getIndexSelect({
  547. status: status.value,
  548. });
  549. if (res.data.status == 0) {
  550. loadPortOptions.value = res.data.result.loadPortSelect;
  551. discPortOptions.value = res.data.result.discPortSelect;
  552. cargoOptions.value = res.data.result.cargoSelect;
  553. } else {
  554. loadPortOptions.value = [];
  555. discPortOptions.value = [];
  556. cargoOptions.value = [];
  557. }
  558. }
  559. // router.beforeEach(() => {
  560. // try {
  561. // myChart.value.dispose();
  562. // } catch (error) {}
  563. // });
  564. onUnmounted(() => {
  565. echarts.dispose(myChart.value); // 在组件销毁前销毁 ECharts 实例
  566. });
  567. onMounted(() => {
  568. getIndexData("init");
  569. getIndexSelect();
  570. });
  571. </script>
  572. <style scoped>
  573. .map-container {
  574. width: 100%;
  575. height: calc(100% - 94px);
  576. }
  577. .tabs {
  578. position: absolute;
  579. top: 20px;
  580. left: 25px;
  581. }
  582. .radio-btns {
  583. height: 30px;
  584. width: 60px;
  585. border: 1px solid #008efe;
  586. line-height: 28px;
  587. text-align: center;
  588. font-size: 14px;
  589. font-family: PingFangSC-Regular, PingFang SC;
  590. font-weight: 400;
  591. color: #0094fe;
  592. cursor: pointer;
  593. background: #fff;
  594. }
  595. .left-radius {
  596. /* border-top-left-radius: 15px;
  597. border-bottom-left-radius: 15px; */
  598. width: 80px;
  599. }
  600. .right-radius {
  601. /* border-top-right-radius: 15px; */
  602. /* border-bottom-right-radius: 15px; */
  603. width: 80px;
  604. }
  605. .currentbtn {
  606. background: #008efe;
  607. color: #fff;
  608. }
  609. :deep() .el-dialog {
  610. width: 800px;
  611. }
  612. .window-title {
  613. display: none;
  614. }
  615. .window-title:hover {
  616. display: block;
  617. }
  618. .export {
  619. font-size: 14px;
  620. font-family: PingFangSC-Medium, PingFang SC;
  621. font-weight: 500;
  622. color: #ffffff;
  623. line-height: 14px;
  624. width: 90px;
  625. height: 32px;
  626. background: #008efe;
  627. border-radius: 2px;
  628. color: #fff;
  629. line-height: 32px;
  630. text-align: center;
  631. }
  632. .main {
  633. width: 100%;
  634. height: 100%;
  635. background: #f4f5f6;
  636. }
  637. .left {
  638. width: calc(100% - 315px);
  639. position: relative;
  640. }
  641. .filter {
  642. font-size: 12px;
  643. color: #353a42;
  644. width: calc(100vw - 320px);
  645. flex-wrap: wrap;
  646. margin-top: 36px;
  647. }
  648. .mr10 {
  649. margin-left: 14px;
  650. }
  651. .all {
  652. width: 60px;
  653. height: 32px;
  654. line-height: 32px;
  655. background: #008efe;
  656. border-radius: 2px;
  657. font-size: 14px;
  658. font-family: PingFangSC-Medium, PingFang SC;
  659. font-weight: 500;
  660. color: #ffffff;
  661. text-align: center;
  662. }
  663. .right {
  664. width: 267px;
  665. border-radius: 4px;
  666. height: calc(100% - 30px);
  667. margin-left: 26px;
  668. overflow-y: auto;
  669. overflow-x: clip;
  670. }
  671. .data {
  672. width: 267px;
  673. background: #ffffff;
  674. border-radius: 4px;
  675. margin-top: 12px;
  676. margin-bottom: 18px;
  677. padding-top: 16px;
  678. padding-left: 24px;
  679. padding-bottom: 20px;
  680. height: calc(50vh - 160px);
  681. min-height: 356px;
  682. }
  683. .pie {
  684. width: 267px;
  685. background: #ffffff;
  686. border-radius: 4px;
  687. padding-top: 24px;
  688. padding-left: 20px;
  689. height: calc(50vh - 206px);
  690. min-height: 260px;
  691. }
  692. .icon {
  693. width: 48px;
  694. height: 48px;
  695. border-radius: 4px;
  696. margin-right: 16px;
  697. }
  698. .data-line {
  699. align-items: center;
  700. width: 219px;
  701. border-bottom: 1px solid rgba(216, 216, 216, 0.24);
  702. padding: 12px 0;
  703. }
  704. .shu {
  705. width: 3px;
  706. height: 16px;
  707. background: #008efe;
  708. margin-right: 16px;
  709. }
  710. .right-title {
  711. font-size: 20px;
  712. font-family: PingFangSC-Medium, PingFang SC;
  713. font-weight: 500;
  714. color: #333333;
  715. }
  716. .data-title {
  717. font-size: 14px;
  718. font-family: PingFangSC-Regular, PingFang SC;
  719. font-weight: 400;
  720. color: #616975;
  721. }
  722. .num {
  723. font-size: 30px;
  724. font-family: PingFangSC-Medium, PingFang SC;
  725. font-weight: 500;
  726. color: #333333;
  727. margin-right: 5px;
  728. }
  729. .unit {
  730. font-size: 12px;
  731. font-family: PingFangSC-Regular, PingFang SC;
  732. font-weight: 400;
  733. color: #353a42;
  734. }
  735. #pie {
  736. width: 220px;
  737. height: 200px;
  738. margin: 0 auto;
  739. }
  740. /* :deep().amap-marker-label {
  741. top: -22px;
  742. left: 41px;
  743. color: #fff !important;
  744. width: 74px;
  745. height: 28px;
  746. line-height: 22px;
  747. background: #212029;
  748. border: none;
  749. text-align: center;
  750. font-size: 12px !important;
  751. font-family: PingFangSC-Regular, PingFang SC;
  752. font-weight: 400;
  753. } */
  754. .pie-point {
  755. width: 6px;
  756. height: 6px;
  757. background: #0a6efa;
  758. border-radius: 30%;
  759. margin-right: 6px;
  760. }
  761. .pie-text {
  762. height: 12px;
  763. font-size: 12px;
  764. font-family: PingFangSC-Regular, PingFang SC;
  765. font-weight: 400;
  766. color: #7d7d7d;
  767. line-height: 12px;
  768. }
  769. .aib {
  770. align-items: baseline;
  771. }
  772. .mr4 {
  773. margin-right: 4px;
  774. }
  775. </style>