Browse Source

修改socket 监控中心

JX.LI 2 years ago
parent
commit
2d2773aac0
2 changed files with 33 additions and 3 deletions
  1. 7 0
      src/components/vBottomMenu.vue
  2. 26 3
      src/views/monitor.vue

+ 7 - 0
src/components/vBottomMenu.vue

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

+ 26 - 3
src/views/monitor.vue

@@ -204,8 +204,8 @@
       this.bottomMenuList() //获取底部公共组件消息和任务
       this.getTreeselect()
       this.deptId = Cookies.get("deptId")
-      // this.getSensorListByDeptId()
-      // this.getDlblistBydeptId()
+      this.getSensorListByDeptIds()
+      this.getDlblistBydeptIds()
       this.selectDeviceType(-1)
     },
     data() {
@@ -427,6 +427,29 @@
             console.error(error);
           });
       },
+      // 大喇叭
+      getDlblistBydeptIds() {
+        let that = this;
+        let markersList = [];
+        getDlblistBydeptId(that.deptId).then(function(res) {
+            that.loudspeakerNum = res.data.length
+
+          })
+          .catch(function(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);
+          });
+      },
       // 传感器
       getSensorListByDeptId() {
         let that = this;
@@ -1035,4 +1058,4 @@
     height: 600px;
     border: 1px solid red;
   }
-</style>
+</style>