Index.vue 19 KB

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