Bladeren bron

websocket修改,

王通 2 jaren geleden
bovenliggende
commit
9af7c7b3e8
2 gewijzigde bestanden met toevoegingen van 32 en 3 verwijderingen
  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
 			})
 		},
+    destroyed() { //离开页面关闭Socket连接
+      if (this.websock) {
+        clearInterval(this.setIntervalWesocketPush)
+        this.websock.close()
+        this.websock = null
+      }
+    },
     mounted() {
       this.websockSid.userId=Cookies.get("userId")
     },

+ 25 - 3
src/views/monitor.vue

@@ -200,8 +200,8 @@
       this.selectKeyAreaList()
       this.getTreeselect()
       this.deptId = Cookies.get("deptId")
-      // this.getSensorListByDeptId()
-      // this.getDlblistBydeptId()
+       this.getSensorListByDeptIds()
+       this.getDlblistBydeptIds()
       this.selectDeviceType(-1)
       this.bottomMenuList() //获取底部公共组件消息和任务
     },
@@ -422,6 +422,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;
@@ -484,6 +494,18 @@
             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() {
         this.keyAreaList = []
         //获取重点区域列表
@@ -1045,4 +1067,4 @@
     height: 600px;
     border: 1px solid red;
   }
-</style>
+</style>