Parcourir la source

websocket修改,

王通 il y a 2 ans
Parent
commit
92fcc02875
2 fichiers modifiés avec 30 ajouts et 3 suppressions
  1. 7 0
      src/components/vBottomMenu.vue
  2. 23 3
      src/views/monitor.vue

+ 7 - 0
src/components/vBottomMenu.vue

@@ -514,6 +514,13 @@
 				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")
     },

+ 23 - 3
src/views/monitor.vue

@@ -201,8 +201,8 @@
       this.bottomMenuList() //获取底部公共组件消息和任务
       this.getTreeselect()
       this.deptId = Cookies.get("deptId")
-      // this.getSensorListByDeptId()
-      // this.getDlblistBydeptId()
+       this.getSensorListByDeptIds()
+       this.getDlblistBydeptIds()
       this.selectDeviceType(-1)
       // this.showTVWall();
     },
@@ -426,6 +426,16 @@
             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() {
         let that = this;
@@ -489,6 +499,16 @@
             console.error(error);
           });
       },
+      getSensorListByDeptIds() {
+        let that = this;
+        getSensorListByDeptId(that.deptId).then(function(res) {
+          that.sensorNum = res.data.length
+
+        })
+          .catch(function(error) {
+            console.error(error);
+          });
+      },
       selectKeyAreaList() {
         this.keyAreaList = []
         //获取重点区域列表
@@ -1033,4 +1053,4 @@
     height: 600px;
     border: 1px solid red;
   }
-</style>
+</style>