Browse Source

修改重复加载;切换时f1报错

haojianlong 4 years ago
parent
commit
afbb012d0a
4 changed files with 29 additions and 25 deletions
  1. 1 1
      package.json
  2. 24 20
      src/components/floorMap/index.vue
  3. 2 2
      src/views/equipment/index.vue
  4. 2 2
      src/views/floorFunc/index.vue

+ 1 - 1
package.json

@@ -9,7 +9,7 @@
     },
     "dependencies": {
         "@saga-web/base": "2.1.19",
-        "@saga-web/big": "1.0.39",
+        "@saga-web/big": "1.0.40",
         "@saga-web/draw": "2.1.94",
         "@saga-web/feng-map": "1.0.11",
         "@saga-web/graph": "2.1.82",

+ 24 - 20
src/components/floorMap/index.vue

@@ -1,8 +1,8 @@
 <!-- 底图 -->
 <template>
     <div id='floor_base' v-loading='loading' ref='graphy'>
-        <div id='fengMap'></div>
-        <canvas id='canvas' :width='canvasWidth' :height='canvasHeight' tabindex='0'></canvas>
+        <div :id='`fengMap${id}`' class="fengMap"></div>
+        <canvas :id='`canvas${id}`' :width='canvasWidth' :height='canvasHeight' tabindex='0'></canvas>
         <!-- 地图底部操作按钮 -->
         <div class='strip-bottom'>
             <canvasFun @fit='fit' @savePng='savePng' @saveSvg='saveSvg' @saveJson='saveJson' @scale='scale' ref='canvasFun'></canvasFun>
@@ -32,13 +32,19 @@ export default {
             mapServerURL: `/wdfn`,
             canvasWidth: 1100,
             canvasHeight: 800,
-            loading: false,
+            loading: false,// 限制重复查询
             view: null,
-            isQuerying: false, // 限制重复查询
-            urlMsg: {}
+            urlMsg: {},
+            canvasID: 'canvas'
             // fmapID:'1001012_42'
         }
     },
+    props:{
+        id:{
+            default: '1',
+            type: String
+        }
+    },
     components: { RoomBox, canvasFun },
     computed: {
         ...mapGetters(['plazaId', 'fmapID'])
@@ -46,6 +52,11 @@ export default {
     methods: {
         ...mapActions(['getfmapID']),
         init(floorid) {
+            if (this.loading) {
+                console.log('正在查询...')
+                return
+            }
+            this.loading = true
             if (!this.fmapID) {
                 this.getfmapID().then(() => {
                     this.urlMsg.fmapID = this.fmapID
@@ -56,18 +67,13 @@ export default {
             this.getMap(floorid)
         },
         getMap(floorid) {
-            if (this.isQuerying) {
-                console.log('正在查询...')
-                return
-            }
-            this.isQuerying = true
             this.clearGraphy()
             this.scene = new FloorScene()
             this.scene.selectContainer.connect('listChange', this, this.listChange)
-            if (!fengmap) {
-                fengmap = new SFengParser('fengMap', `${this.mapServerURL}/fmap/${this.fmapID}`, this.key, this.appName, null)
-                fengmap.loadMap(this.fmapID, res => {
-                    this.floorList = res
+            if (!fengmap || this.canvasID!=`canvas${this.id}`) {
+                this.canvasID = `canvas${this.id}`
+                fengmap = new SFengParser(`fengMap${this.id}`, `${this.mapServerURL}/fmap/${this.fmapID}`, this.key, this.appName, null)
+                fengmap.loadMap(this.fmapID, () => {
                     this.parserData(floorid)
                 })
                 // 获取主题数据
@@ -121,11 +127,10 @@ export default {
                     this.view.scene = this.scene
                     this.view.fitSceneToView()
                     this.loading = false
-                    this.isQuerying = false
                 }
             } else {
-                if (this.floorList[floor]) {
-                    fengmap.parseData(this.floorList[floor], res => {
+                if (fengmap.gnameToGid[floor]) {
+                    fengmap.parseData(fengmap.gnameToGid[floor], res => {
                         if (res.err) {
                             console.log(res.err)
                             return
@@ -144,7 +149,6 @@ export default {
                         this.view.scene = this.scene
                         this.view.fitSceneToView()
                         this.loading = false
-                        this.isQuerying = false
                         console.log('success')
                     })
                 } else {
@@ -157,7 +161,7 @@ export default {
                 this.view.scene = null
                 return
             }
-            this.view = new FloorView('canvas')
+            this.view = new FloorView(`canvas${this.id}`)
         },
         listChange(item, ev) {
             let name = ev[0][0].data.Name
@@ -230,7 +234,7 @@ export default {
 <style lang="less" scoped>
 #floor_base {
     position: relative;
-    #fengMap {
+    .fengMap {
         position: fixed;
         width: 100px;
         height: 100px;

+ 2 - 2
src/views/equipment/index.vue

@@ -34,7 +34,7 @@
                         <div class='legend-boxs'>
                             <Legend :systemName='systemName'></Legend>
                         </div>
-                        <floorMap ref='floorMap'></floorMap>
+                        <floorMap ref='floorMap' :id="'equip'"></floorMap>
                         <div class='additional-box' v-if='fqPic.length>0'>
                             <div class='additional' @click='additionalColl'>
                                 <img src='../../assets/imgs/bg.png' alt />
@@ -125,7 +125,7 @@ export default {
     },
     mounted() {
         this.everySystem = this.system[0].children
-        this.$refs.floorMap.init(this.floorInfo.gname)
+        // this.$refs.floorMap.init(this.floorInfo.gname)
     }
 }
 </script>

+ 2 - 2
src/views/floorFunc/index.vue

@@ -7,7 +7,7 @@
         <div class='legend-boxs'>
             <Legend></Legend>
         </div>
-        <floor-list @emitFloor='emitFloor'></floor-list>
+        <floor-list @emitFloor='emitFloor' :id="'floor'"></floor-list>
         <!-- <div class='additional-box'>
             <div class='additional' @click='additionalColl'>
                 <img src='../../assets/imgs/bg.png' alt />
@@ -44,7 +44,7 @@ export default {
         }
     },
     mounted() {
-        this.$refs.floorMap.init(this.floorInfo.gname)
+        // this.$refs.floorMap.init(this.floorInfo.gname)
     }
 }
 </script>