Kaynağa Gözat

更新 船舶卡片渲染逻辑

wzh 3 yıl önce
ebeveyn
işleme
91a4a8fa95
1 değiştirilmiş dosya ile 41 ekleme ve 27 silme
  1. 41 27
      src/views/transportationSafetyCenter.vue

+ 41 - 27
src/views/transportationSafetyCenter.vue

@@ -3,7 +3,7 @@
     <div id="bmap"></div>
     <ShipSearch
       class="ship-search z20"
-      :api="'searchShipSelect'"
+      :searchapi="isSafety ? 'searchSafetyShipSelect' : 'searchShipSelect'"
       v-model="shipStr"
       @selectItem="selectShip($event, 1)"
       style="position: absolute; top: 40px; right: 524px"
@@ -44,6 +44,8 @@ import router from "router/index";
 import store from "store/index";
 import api from "apis/fetch";
 import { ref, onMounted, watch } from "vue";
+import { useRoute } from "vue-router";
+
 export default {
   components: {
     ShipSearch,
@@ -51,6 +53,7 @@ export default {
   setup() {
     const bmap = ref({});
     let shipStr = ref("");
+    const route = useRoute();
 
     // 初始化地图
     function initMap() {
@@ -179,7 +182,11 @@ export default {
     watch(
       () => store.state.currentTabText,
       (a, b) => {
+        if (a == "数字化赋能中心") return;
         store.dispatch("GetNumbers");
+        isSafety.value = a == "运输安全管理中心";
+        clearShipsOverlay();
+        getAllShipLocation();
       }
     );
 
@@ -256,29 +263,7 @@ export default {
           objE.innerHTML = arg;
           return objE;
         }
-        let content = `
-        <div
-                style="
-                  display: flex;
-                  align-items:center;
-                  text-shadow: 0px 0px 5px rgba(100, 185, 255, 0.6);
-                  position:relative;
-                  transform:scale(${scale});
-                  left:${137 * (scale - 1) + offset}px
-                "
-              >
-                <img
-                  style="
-                    margin: 0px;
-                    padding: 0px;
-                    height: 55px;
-                    width: 55px;
-                    margin-right: 20px;
-                  "
-                  src="https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/data-platform/map-ship-icon.png"
-                  alt=""
-                />
-                <div style="display: flex;
+        let c2 = `  <div style="display: flex;
                   align-items:center;position:relative;top:${offsetX}px;left:${offsetY}px">
                 <div
                   style="
@@ -370,7 +355,30 @@ export default {
                     </div>
                   </div>
                   </div>
-                </div>
+                </div>`;
+        let content = `
+        <div
+                style="
+                  display: flex;
+                  align-items:center;
+                  text-shadow: 0px 0px 5px rgba(100, 185, 255, 0.6);
+                  position:relative;
+                  transform:scale(${scale});
+                  left:${137 * (scale - 1) + offset}px
+                "
+              >
+                <img
+                  style="
+                    margin: 0px;
+                    padding: 0px;
+                    height: 55px;
+                    width: 55px;
+                    margin-right: 20px;
+                  "
+                  src="https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/data-platform/map-ship-icon.png"
+                  alt=""
+                />
+${isSafety.value ? c2 : ""}
               </div>
         `;
         let shipBox = parseDom(content);
@@ -422,9 +430,11 @@ export default {
 
     // 获取所有船舶
     async function getAllShipLocation() {
-      let res = await api.getAllShipLocation();
+      let res = await api[
+        `${isSafety.value ? "getSafetyShipLocation" : "getAllShipLocation"}`
+      ]();
       let data = res.data.result;
-      data.length = 30;
+      // data.length = 30;
       shipsDataCache.value = data;
       for (let i of data) {
         let overlay = cpxOverlay(i);
@@ -436,10 +446,13 @@ export default {
       }
     }
 
+    let isSafety = ref(true);
+
     onMounted(() => {
       initMap();
       store.dispatch("GetNumbers");
       bmap.value.addOverlay(cpxOverlay(-1));
+      isSafety.value = store.state.currentTabText == "运输安全管理中心";
       getAllShipLocation();
     });
     return {
@@ -447,6 +460,7 @@ export default {
       shipStr,
       selectShip,
       polylineCache,
+      isSafety,
     };
   },
 };