浏览代码

websocket修改,

王通 2 年之前
父节点
当前提交
9af7c7b3e8
共有 2 个文件被更改,包括 32 次插入3 次删除
  1. 7 0
      src/components/vBottomMenu.vue
  2. 25 3
      src/views/monitor.vue

+ 7 - 0
src/components/vBottomMenu.vue

@@ -514,6 +514,13 @@
 				this.deptOptionsLiandong = response.data
 				this.deptOptionsLiandong = response.data
 			})
 			})
 		},
 		},
+    destroyed() { //离开页面关闭Socket连接
+      if (this.websock) {
+        clearInterval(this.setIntervalWesocketPush)
+        this.websock.close()
+        this.websock = null
+      }
+    },
     mounted() {
     mounted() {
       this.websockSid.userId=Cookies.get("userId")
       this.websockSid.userId=Cookies.get("userId")
     },
     },

+ 25 - 3
src/views/monitor.vue

@@ -200,8 +200,8 @@
       this.selectKeyAreaList()
       this.selectKeyAreaList()
       this.getTreeselect()
       this.getTreeselect()
       this.deptId = Cookies.get("deptId")
       this.deptId = Cookies.get("deptId")
-      // this.getSensorListByDeptId()
-      // this.getDlblistBydeptId()
+       this.getSensorListByDeptIds()
+       this.getDlblistBydeptIds()
       this.selectDeviceType(-1)
       this.selectDeviceType(-1)
       this.bottomMenuList() //获取底部公共组件消息和任务
       this.bottomMenuList() //获取底部公共组件消息和任务
     },
     },
@@ -422,6 +422,16 @@
             console.error(error);
             console.error(error);
           });
           });
       },
       },
+      getDlblistBydeptIds() {
+        let that = this;
+
+        getDlblistBydeptId(that.deptId).then(function(res) {
+          that.loudspeakerNum = res.data.length
+        })
+          .catch(function(error) {
+            console.error(error);
+          });
+      },
       // 传感器
       // 传感器
       getSensorListByDeptId() {
       getSensorListByDeptId() {
         let that = this;
         let that = this;
@@ -484,6 +494,18 @@
             console.error(error);
             console.error(error);
           });
           });
       },
       },
+      getSensorListByDeptIds() {
+        let that = this;
+        let markersList = [];
+        getSensorListByDeptId(that.deptId).then(function(res) {
+
+          that.sensorNum = res.data.length
+
+        })
+          .catch(function(error) {
+            console.error(error);
+          });
+      },
       selectKeyAreaList() {
       selectKeyAreaList() {
         this.keyAreaList = []
         this.keyAreaList = []
         //获取重点区域列表
         //获取重点区域列表
@@ -1045,4 +1067,4 @@
     height: 600px;
     height: 600px;
     border: 1px solid red;
     border: 1px solid red;
   }
   }
-</style>
+</style>