瀏覽代碼

fix: 空间搜索问题

chenzhen2 2 年之前
父節點
當前提交
23560223ac

+ 3 - 0
src/App.vue

@@ -39,6 +39,9 @@ export default defineComponent({
         event.preventDefault()
       })
     })
+    onMounted(() => {
+      // debugger
+    });
     return {
       ...toRefs(data
       )

+ 1 - 0
src/permission.ts

@@ -8,6 +8,7 @@ import { Toast } from 'vant'
 import Cookies from 'js-cookie'
 
 router.beforeEach(async(to: RouteLocationNormalized, _: RouteLocationNormalized, next: any) => {
+  // debugger
   const store = useStore()
   await store.dispatch(UserActionTypes.ACTION_GET_USER_INFO, undefined)
   next()

+ 6 - 1
src/views/envmonitor/components/Map/MapBox.vue

@@ -172,6 +172,10 @@ export default defineComponent({
       type: Boolean,
       default: () => false,
     },
+    floorId: {
+      type: String,
+      default: () => ""
+    },
   },
   components: {
     SpaceSearch,
@@ -982,7 +986,8 @@ export default defineComponent({
       getMapInfo(flag: boolean = true, searchItem: any = null) {
         let params: any = {
           projectId: props.projectId,
-          floorId: proxyData.floorItem.id,
+          floorId:props.floorId
+          // floorId: proxyData.floorItem.id,
         };
         getMapInfo(params)
           .then((res) => {

+ 33 - 6
src/views/envmonitor/components/Map/index.vue

@@ -1,6 +1,11 @@
 <template>
   <div class="map-home">
-    <space-box :spaceData="spaceData" @changeSpace="changeSpace"></space-box>
+    <map-box v-if="showMap && floorId" :projectId="projectId" :floorId="floorId"></map-box>
+    <space-box
+      v-else
+      :spaceData="spaceData"
+      @changeSpace="changeSpace"
+    ></space-box>
   </div>
 </template>
   
@@ -35,10 +40,14 @@ export default defineComponent({
       type: String,
       default: () => "",
     },
+    floorId: {
+      type: String,
+      default: () => "",
+    },
     spaceInfo: {
       type: Object,
       default: () => {},
-    }
+    },
   },
   components: {
     vanForm: Form,
@@ -53,31 +62,49 @@ export default defineComponent({
     const store = useStore();
     const proxyData = reactive({
       spaceData: props.spaceData,
+      showMap: false, // 是否展示地图
       changeSpace(item: any) {
         contex.emit("changeSpace", item, 1);
       },
+      floorId:props.floorId,
       /**
        * 获取地图信息
        */
       getMapInfo() {
         let params: any = {
-          // projectId: props.projectId,
-          // floorId: proxyData.floorItem.id,
+          projectId: props.projectId,
+          floorId: proxyData.floorId,
         };
         getMapInfo(params)
           .then((res) => {
             let resData: any = res;
             if (resData.result === "success") {
+              let data: any = resData?.data ?? null;
+              // debugger
+              if (data) {
+                proxyData.showMap = true;
+              } else {
+                proxyData.showMap = false;
+              }
+            } else {
+              proxyData.showMap = false;
             }
           })
-          .catch(() => {});
+          .catch(() => {
+            proxyData.showMap = false;
+          });
       },
     });
-    onMounted(() => {});
+    onMounted(() => {
+    });
     watch(
       props,
       (newProps: any) => {
         proxyData.spaceData = newProps.spaceData;
+        proxyData.floorId = newProps.floorId;
+        console.log("proxyData.floorId===")
+        console.log(proxyData.floorId)
+        proxyData.getMapInfo();
       },
       {
         deep: false,

+ 0 - 1
src/views/envmonitor/components/workOvertime/index.vue

@@ -160,7 +160,6 @@ export default defineComponent({
         } else if (formatTimer < cusStartTime) {
           timerArr.map((item: any, index: any) => {
             if (item.formatTimer === cusStartTime) {
-              console.log("index===", index);
               obj.len = index - nowIndex;
               if (obj.len > 4) {
                 obj.len = 4;

+ 6 - 0
src/views/envmonitor/index.vue

@@ -189,6 +189,7 @@
         :spaceData="spaceData"
         :spaceId="spaceInfo.spaceId"
         :projectId="projectId"
+        :floorId="floorId"
         @changeSpace="changeSpace"
       ></com-map>
     </van-popup>
@@ -1495,6 +1496,7 @@ export default defineComponent({
       },
       // 平板当前空间
       spaceData: spaceData,
+      floorId: "",
       queryWorkSpace() {
         let params: any = {
           criteria: {
@@ -1520,6 +1522,9 @@ export default defineComponent({
           proxyData.spaceData.map((item: any) => {
             if (item.isMajorSpace) {
               item.active = true;
+              proxyData.floorId = item.floorId;
+              console.log("=====")
+              console.log(proxyData.floorId)
             } else {
               item.active = false;
             }
@@ -1588,6 +1593,7 @@ export default defineComponent({
       }
     });
     onMounted(() => {
+      // debugger
       // 获取天气信息
       // console.log("router====")
       // console.log(route.query)