dedsudiyu 2 년 전
부모
커밋
351492f67b

+ 1 - 1
src/router/index.js

@@ -72,7 +72,7 @@ export const constantRoutes = [
   },
   {
     path: '/emergencyEvacuationBig',
-    component: (resolve) => require(['@/views/emergencyEvacuationBig'], resolve),
+    component: (resolve) => require(['@/views/emergencyEvacuationBigOne'], resolve),
     hidden: true
   },
   {

+ 48 - 26
src/views/comprehensive/laboratoryManagement/subject/index.vue

@@ -705,6 +705,7 @@ export default {
       let self = this;
       if(val.id != this.checkedSubject.id){
         this.videoOff();
+        this.offMQTT();
         this.subjectInfo(val.id);
         this.subId = val.id;
         this.$set(this,'queryParamsTwo',{
@@ -713,6 +714,7 @@ export default {
         });
         this.getEnablelist();
         this.getHxpAlarmRecordNoAuthList();
+        this.subscriptionMQTT();
       }
     },
     //获取实验室详情
@@ -801,7 +803,7 @@ export default {
     /** 查询实验室列表 */
     getList() {
       this.loading = true;
-      this.offMQTT();
+      // this.offMQTT();
       authListSubject(this.queryParams).then(response => {
         this.subjectList = response.rows;
         this.total = response.total;
@@ -815,7 +817,7 @@ export default {
           idList.push(response.rows[i].id)
         }
         this.$set(this,'mqttIdList',idList);
-        this.subscriptionMQTT();
+        // this.subscriptionMQTT();
       });
     },
     /** 查询学院列表 */
@@ -833,18 +835,28 @@ export default {
       });
       this.client.on("connect", e =>{
         console.log("连接成功");
-        for(let i = 0; i< self.mqttIdList.length;i++){
-          this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
-            }
-          });
-          this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
-            }
-          });
-        }
+        this.client.subscribe(this.mtopic+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopic+self.subId);
+          }
+        });
+        this.client.subscribe(this.mtopicOne+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopicOne+self.subId);
+          }
+        });
+        // for(let i = 0; i< self.mqttIdList.length;i++){
+        //   this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
+        //     }
+        //   });
+        //   this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
+        //     }
+        //   });
+        // }
       });
       this.client.on("message", (topic, message) => {
         console.log('message',message)
@@ -905,18 +917,28 @@ export default {
     offMQTT(){
       let self = this;
       if (self.mqttIdList[0]){
-        for(let i=0;i<self.mqttIdList.length;i++){
-          self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-          self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-        }
+        // for(let i=0;i<self.mqttIdList.length;i++){
+        //   self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        //   self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        // }
+        self.client.unsubscribe(self.mtopic+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
+        self.client.unsubscribe(self.mtopicOne+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
         self.client.end();
         self.client = {};
       }

+ 48 - 26
src/views/comprehensive/laboratoryManagement/subject/indexOne.vue

@@ -725,6 +725,7 @@ export default {
       let self = this;
       if(val.id != this.checkedSubject.id){
         this.videoOff();
+        this.offMQTT();
         this.subjectInfo(val.id);
         this.subId = val.id;
         this.$set(this,'queryParamsTwo',{
@@ -733,6 +734,7 @@ export default {
         });
         this.getEnablelist();
         this.getHxpAlarmRecordNoAuthList();
+        this.subscriptionMQTT();
       }
     },
     getDetalis(id){
@@ -831,7 +833,7 @@ export default {
     /** 查询实验室列表 */
     getList() {
       this.loading = true;
-      this.offMQTT();
+      // this.offMQTT();
       authListSubject(this.queryParams).then(response => {
         this.subjectList = response.rows;
         this.total = response.total;
@@ -845,7 +847,7 @@ export default {
           idList.push(response.rows[i].id)
         }
         this.$set(this,'mqttIdList',idList);
-        this.subscriptionMQTT();
+        // this.subscriptionMQTT();
       });
     },
     /** 查询学院列表 */
@@ -863,18 +865,28 @@ export default {
       });
       this.client.on("connect", e =>{
         console.log("连接成功");
-        for(let i = 0; i< self.mqttIdList.length;i++){
-          this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
-            }
-          });
-          this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
-            }
-          });
-        }
+        this.client.subscribe(this.mtopic+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopic+self.subId);
+          }
+        });
+        this.client.subscribe(this.mtopicOne+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopicOne+self.subId);
+          }
+        });
+        // for(let i = 0; i< self.mqttIdList.length;i++){
+        //   this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
+        //     }
+        //   });
+        //   this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
+        //     }
+        //   });
+        // }
       });
       this.client.on("message", (topic, message) => {
         console.log('message',message)
@@ -935,18 +947,28 @@ export default {
     offMQTT(){
       let self = this;
       if (self.mqttIdList[0]){
-        for(let i=0;i<self.mqttIdList.length;i++){
-          self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-          self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-        }
+        // for(let i=0;i<self.mqttIdList.length;i++){
+        //   self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        //   self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        // }
+        self.client.unsubscribe(self.mtopic+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
+        self.client.unsubscribe(self.mtopicOne+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
         self.client.end();
         self.client = {};
       }

+ 48 - 26
src/views/comprehensive/laboratoryManagement/subject/indexTwo.vue

@@ -705,6 +705,7 @@ export default {
       let self = this;
       if(val.id != this.checkedSubject.id){
         this.videoOff();
+        this.offMQTT();
         this.subjectInfo(val.id);
         this.subId = val.id;
         this.$set(this,'queryParamsTwo',{
@@ -713,6 +714,7 @@ export default {
         });
         this.getEnablelist();
         this.getHxpAlarmRecordNoAuthList();
+        this.subscriptionMQTT();
       }
     },
     //获取实验室详情
@@ -801,7 +803,7 @@ export default {
     /** 查询实验室列表 */
     getList() {
       this.loading = true;
-      this.offMQTT();
+      // this.offMQTT();
       authListSubject(this.queryParams).then(response => {
         this.subjectList = response.rows;
         this.total = response.total;
@@ -815,7 +817,7 @@ export default {
           idList.push(response.rows[i].id)
         }
         this.$set(this,'mqttIdList',idList);
-        this.subscriptionMQTT();
+        // this.subscriptionMQTT();
       });
     },
     /** 查询学院列表 */
@@ -833,18 +835,28 @@ export default {
       });
       this.client.on("connect", e =>{
         console.log("连接成功");
-        for(let i = 0; i< self.mqttIdList.length;i++){
-          this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
-            }
-          });
-          this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
-            if (!err) {
-              console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
-            }
-          });
-        }
+        this.client.subscribe(this.mtopic+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopic+self.subId);
+          }
+        });
+        this.client.subscribe(this.mtopicOne+self.subId, (err) => {
+          if (!err) {
+            console.log("订阅成功:" + this.mtopicOne+self.subId);
+          }
+        });
+        // for(let i = 0; i< self.mqttIdList.length;i++){
+        //   this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
+        //     }
+        //   });
+        //   this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
+        //     if (!err) {
+        //       console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
+        //     }
+        //   });
+        // }
       });
       this.client.on("message", (topic, message) => {
         console.log('message',message)
@@ -905,18 +917,28 @@ export default {
     offMQTT(){
       let self = this;
       if (self.mqttIdList[0]){
-        for(let i=0;i<self.mqttIdList.length;i++){
-          self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-          self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
-            if (error) {
-              console.log('Unsubscribe error', error)
-            }
-          })
-        }
+        // for(let i=0;i<self.mqttIdList.length;i++){
+        //   self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        //   self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
+        //     if (error) {
+        //       console.log('Unsubscribe error', error)
+        //     }
+        //   })
+        // }
+        self.client.unsubscribe(self.mtopic+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
+        self.client.unsubscribe(self.mtopicOne+self.subId, error => {
+          if (error) {
+            console.log('Unsubscribe error', error)
+          }
+        })
         self.client.end();
         self.client = {};
       }