Parcourir la source

修复刷新时,设备设施页面,子系统没有选对的问题

yx il y a 4 ans
Parent
commit
2ecf24f9c5
3 fichiers modifiés avec 35 ajouts et 2 suppressions
  1. 6 0
      src/App.vue
  2. 2 2
      src/store/index.js
  3. 27 0
      src/views/equipment/index.vue

+ 6 - 0
src/App.vue

@@ -26,6 +26,8 @@ export default {
      */
     created() {
         this.$store.replaceState(Object.assign(this.$store.state, JSON.parse(localStorage.getItem('beforeunload'))))
+        //    刷新时,将haveFengMap 置为false,解决设备设施页面,刷新时不出新楼层图的问题
+        this.SETHAVEFENGMAP(false)
         localStorage.removeItem('beforeunload')
         window.addEventListener('beforeunload', () => {
             let state = JSON.stringify(this.$store.state)
@@ -62,6 +64,10 @@ export default {
                     this.mapthemeUrl
                 )
                 window.fengmapData.loadMap(this.fmapID, () => {
+                    console.log('-------------')
+                    console.log(window.fengmapData)
+                    console.log(window.fengmapData.gnameToGid)
+                    console.log('-------------')
                     // 获取主题数据
                     window.fengmapData.loadTheme(`${this.mapServerURL}/webtheme/${this.fmapID}/${this.fmapID}.theme`).then(res => {
                         this.SETHAVEFENGMAP()

+ 2 - 2
src/store/index.js

@@ -104,8 +104,8 @@ export default new Vuex.Store({
         SETMAPID(state, data) {
             state.fmapID = data
         },
-        SETHAVEFENGMAP(state) {
-            state.haveFengMap = true
+        SETHAVEFENGMAP(state, data = true) {
+            state.haveFengMap = data
         },
         // 土建的图例
         SETSCPZTABLE(state, data) {

+ 27 - 0
src/views/equipment/index.vue

@@ -166,7 +166,23 @@ export default {
             }
         }
     },
+    /* mounted() {
+        if (this.$route.query.smsxt) {
+            this.smsxt = this.$route.query.smsxt
+            this.system.forEach(el => {
+                if (el.smsxt == this.smsxt) {
+                    this.everySystem = el.children
+                    this.systemName = el.name
+                    this.systemId = el.id
+                }
+            })``
+        }
+        this.everySystem = this.system[0].children
+        this.init()
+        this.$refs.floorMap.init(this.floorInfo.gname)
+    }, */
     mounted() {
+        window._vm = this
         if (this.$route.query.smsxt) {
             this.smsxt = this.$route.query.smsxt
             this.system.forEach(el => {
@@ -178,6 +194,17 @@ export default {
             })
         }
         this.everySystem = this.system[0].children
+        // 刷新时,store中有categoryId时,选中子系统状态
+        if (this.$store.state.categoryId) {
+            let item = this.system.filter(item => item.categoryId === this.$store.state.categoryId)[0]
+            this.systemId = item.id
+            this.everySystem = item.children
+            this.systemName = item.name
+            this.smsxt = item.smsxt
+            // this.$refs.floorMap.init(this.floorInfo.gname)
+            this.querySmsxt()
+            this.viewLengend()
+        }
         this.init()
         this.$refs.floorMap.init(this.floorInfo.gname)
     },