Explorar el Código

更新 轨迹数据获取方法;无合同不调取货主及船舶详情

wzh hace 4 años
padre
commit
03e688eabf
Se han modificado 2 ficheros con 21 adiciones y 68 borrados
  1. 10 4
      src/store/index.js
  2. 11 64
      src/views/transportationSafetyCenter.vue

+ 10 - 4
src/store/index.js

@@ -205,13 +205,19 @@ const store = createStore({
       }
     },
     GetManageShipDetail({ commit }, shipId) {
-      api.getManageShipDetail({ shipId }).then((e) => {
-        commit("setManageShipDetail", e.data.result);
+      return new Promise((resolve, reject) => {
+        api.getManageShipDetail({ shipId }).then((e) => {
+          commit("setManageShipDetail", e.data.result);
+          resolve(e.data.result.trackDetail);
+        });
       });
     },
     GetTradeShipDetail({ commit }, shipId) {
-      api.getTradeShipDetail({ shipId }).then((e) => {
-        commit("setTradeShipDetail", e.data.result);
+      return new Promise((resolve, reject) => {
+        api.getTradeShipDetail({ shipId }).then((e) => {
+          commit("setTradeShipDetail", e.data.result);
+          resolve(e.data.result.trackDetail);
+        });
       });
     },
   },

+ 11 - 64
src/views/transportationSafetyCenter.vue

@@ -5,7 +5,7 @@
       class="ship-search z20"
       :api="'searchShipSelect'"
       v-model="shipStr"
-      @selectItem="selectShip"
+      @selectItem="selectShip($event, 1)"
       style="position: absolute; top: 40px; right: 524px"
     ></ShipSearch>
     <NumberVue
@@ -200,66 +200,20 @@ export default {
     }
 
     // 查询选择船舶或地图点选船舶
-    function selectShip(item) {
+    async function selectShip(item, cargo) {
+      if (!cargo) return;
       clearPolyline();
+      let res;
       if (store.state.currentTabText == "运输安全管理中心") {
-        store.dispatch("GetManageShipDetail", item.key);
+        res = await store.dispatch("GetManageShipDetail", item.key);
       }
       if (store.state.currentTabText == "智能交易中心") {
-        store.dispatch("GetTradeShipDetail", item.key);
+        res = await store.dispatch("GetTradeShipDetail", item.key);
       }
       return;
-      let arr1 = [
-        {
-          lng: 120.60686,
-          lat: 32.00782,
-        },
-        {
-          lng: 120.460976,
-          lat: 32.046392,
-        },
-        {
-          lng: 120.384512,
-          lat: 32.005248,
-        },
-        {
-          lng: 120.384512,
-          lat: 32.005248,
-        },
-        {
-          lng: 120.199389,
-          lat: 31.932712,
-        },
-        {
-          lng: 120.071183,
-          lat: 31.962125,
-        },
-      ];
-
-      let arr2 = [
-        {
-          lng: 119.966548,
-          lat: 32.03268,
-        },
-        {
-          lng: 119.940677,
-          lat: 32.070384,
-        },
-        {
-          lng: 119.909057,
-          lat: 32.17509,
-        },
-        {
-          lng: 119.892384,
-          lat: 32.233262,
-        },
-        {
-          lng: 119.862489,
-          lat: 32.29042,
-        },
-      ];
+      if (res.length == 0) return;
       let points = [];
-      for (let i of Math.random() > 0.5 ? arr1 : arr2) {
+      for (let i of res) {
         points.push(new BMapGL.Point(i.lng, i.lat));
       }
       drawLine(points);
@@ -370,7 +324,7 @@ export default {
                   </div>
                   <div
                     style="
-                      display: flex;
+                      display: ${cargo ? "flex" : "none"};
                       font-size: 20px;
                       font-family: DINAlternate-Bold, DINAlternate;
                       font-weight: bold;
@@ -421,13 +375,7 @@ export default {
         `;
         let shipBox = parseDom(content);
         div.addEventListener("click", function () {
-          if (store.state.currentTabText == "运输安全管理中心") {
-            store.dispatch("GetManageShipDetail", shipId);
-          }
-          if (store.state.currentTabText == "智能交易中心") {
-            store.dispatch("GetTradeShipDetail", shipId);
-          }
-          selectShip({ key: shipId });
+          selectShip({ key: shipId }, cargo);
         });
         if (item != -1) {
           div.appendChild(shipBox);
@@ -466,8 +414,6 @@ export default {
 
     // 清除地图船舶覆盖物
     function clearShipsOverlay() {
-      bmap.value.clearOverlays();
-      return;
       for (let i of shipsOverlayCache.value) {
         bmap.value.removeOverlay(i);
       }
@@ -478,6 +424,7 @@ export default {
     async function getAllShipLocation() {
       let res = await api.getAllShipLocation();
       let data = res.data.result;
+      data.length = 30;
       shipsDataCache.value = data;
       for (let i of data) {
         let overlay = cpxOverlay(i);