Parcourir la source

fixbug: 修复平面图弹窗,在切换子系统或者
进行其他跳转时,弹窗还在页面中的bug

yx il y a 4 ans
Parent
commit
6d5455f8b6
1 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 21 0
      src/components/floorMap/index.vue

+ 21 - 0
src/components/floorMap/index.vue

@@ -690,6 +690,22 @@ export default {
                     })
             })
         },
+        /**
+         * @description 处理popover显隐
+         * 当点击位置不在canvas内部时 ( 如点击 页面空白,图例,楼层,设备设施左侧列表项时),将popover的display置为none,
+         * 当点击位置在canvas内部时,将popover的display设置为'block'
+         */
+        handlePopover(e) {
+            if (this.$refs.graphy.contains(e.target)) {
+                if (this.$refs.popover && this.$refs.popover.popperElm) {
+                    this.$refs.popover.popperElm.style.display = 'block'
+                }
+            } else {
+                if (this.$refs.popover && this.$refs.popover.popperElm) {
+                    this.$refs.popover.popperElm.style.display = 'none'
+                }
+            }
+        },
     },
     watch: {
         'view.scale': {
@@ -707,6 +723,11 @@ export default {
     mounted() {
         this.mapSize()
         this.getEvent()
+        // 添加监听点击事件,处理popover显隐
+        window.addEventListener('click', this.handlePopover, false)
+        this.$once('hook:beforeDestroy', () => {
+            window.removeEventListener('click', this.handlePopover)
+        })
     },
     created() {
         // document.addEventListener("mousedown", () => {