From d889eaf990af99c06970e51f2bc421ac0015489c Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期四, 05 五月 2022 13:30:31 +0800
Subject: [PATCH] bug修复

---
 src/views/hashrate/CameraManage/index.vue |  104 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 83 insertions(+), 21 deletions(-)

diff --git a/src/views/hashrate/CameraManage/index.vue b/src/views/hashrate/CameraManage/index.vue
index 8d6b11b..9396978 100644
--- a/src/views/hashrate/CameraManage/index.vue
+++ b/src/views/hashrate/CameraManage/index.vue
@@ -2,7 +2,7 @@
   <div class="CameraManage">
     <div class="cluster">
       <div class="title">闆嗙兢閫夋嫨</div>
-      <el-select v-model="cluster" placeholder="璇烽�夋嫨">
+      <el-select v-model="cluster" placeholder="璇烽�夋嫨" @change="selectCluster">
         <el-option
           v-for="item in clusterArr"
           :key="item.value"
@@ -49,6 +49,9 @@
 import CameraLeft from "@/components/CameraLeft";
 import CameraInfo from "./CameraInfo";
 import CameraRules from "./CameraRules";
+import VideoRuleData from "@/Pool/VideoRuleData";
+
+import { getClusterDevList } from "@/api/clusterManage";
 
 import bus from "@/plugin/bus";
 export default {
@@ -61,17 +64,9 @@
   data() {
     return {
       activeTab: "淇℃伅缁存姢",
-      clusterArr: [
-        {
-          value: 0,
-          label: "闆嗙兢涓�",
-        },
-        {
-          value: 1,
-          label: "闆嗙兢浜�",
-        },
-      ],
+      clusterArr: [],
       cluster: "",
+      clusterData: [],
       intervalTimer: null,
       leftWith: 0,
       screenHeight: 0,
@@ -83,7 +78,8 @@
   },
 
   watch: {
-    "TreeDataPool.selectedNode": function (node) {
+    "TreeDataPool.activeNode": function (node) {
+      console.log("cclickaaa");
       if (this.activeTab == "淇℃伅缁存姢") {
         if (this.TreeDataPool.treeActiveName == "camera") {
           this.$refs.cameraInfo.selectCamera(node);
@@ -95,7 +91,17 @@
     "TreeDataPool.selectedNodes": {
       handler(nodes) {
         if (this.activeTab == "鍦烘櫙閰嶇疆") {
-          // this.$refs.sepRule.initCameraData();
+          console.log(this.TreeDataPool.multiple);
+          //  this.$refs.sepRule.initCameraData(nodes[nodes.length - 1]);
+          let CameraArr = [];
+
+          nodes.forEach((id) => {
+            let newCamera = new VideoRuleData(id);
+            CameraArr.push(newCamera);
+          });
+
+          this.$refs.sepRule.Carmeras = CameraArr;
+          console.log(CameraArr);
         }
       },
       deep: true,
@@ -117,7 +123,8 @@
     },
   },
   created() {
-    this.PollData.statistics();
+    console.log("------------");
+    this.getCluster();
     this.TreeDataPool.readonly = false;
 
     //  this.TreeDataPool.readonly = true;
@@ -125,11 +132,12 @@
     this.TreeDataPool.multiple = false;
     this.TreeDataPool.selectedNode = "";
     this.selectedNodes = [];
-    this.VideoManageData.init();
   },
   beforeDestroy() {
     clearInterval(this.intervalTimer);
     //this.TreeDataPool.treeActiveName = "camera";
+    sessionStorage.removeItem("devId");
+    sessionStorage.removeItem("clusterId");
   },
   mounted() {
     this.$nextTick(() => {
@@ -141,12 +149,6 @@
       });
       this.TreeDataPool.clean();
     });
-
-    let _this = this;
-    _this.PollData.statisticTaskInfo();
-    this.intervalTimer = setInterval(() => {
-      _this.PollData.statisticTaskInfo();
-    }, 10000);
   },
   methods: {
     handAddDevice(node) {
@@ -181,6 +183,66 @@
         }
       }
     },
+    async getCluster() {
+      const res = await getClusterDevList();
+      if (res && res.success) {
+        this.clusterData = res.data.clusterList;
+        if (res.data.clusterList <= 0 && res.data.devList <= 0) {
+          this.$confirm(
+            "绯荤粺妫�娴嬪埌鎮ㄨ繕鏈坊鍔犺澶�, 璇峰湪璁惧绠$悊椤甸潰缁存姢",
+            "鎻愮ず",
+            {
+              confirmButtonText: "璺宠浆",
+              cancelButtonText: "鍙栨秷",
+              type: "warning",
+            }
+          )
+            .then(() => {
+              this.$router.push("/manageCenter");
+            })
+            .catch(() => {});
+        }
+
+        res.data.clusterList.forEach((item) => {
+          this.clusterArr.push({
+            label: item.cluster_name,
+            value: "0$$" + item.cluster_id,
+          });
+        });
+
+        res.data.devList.forEach((item) => {
+          this.clusterArr.push({
+            label: item.devName,
+            value: "1$$" + item.devId,
+          });
+        });
+
+        this.cluster = this.clusterArr[0].value;
+        this.selectCluster(this.clusterArr[0].value);
+      }
+    },
+    selectCluster(val) {
+      const arr = val.split("$$");
+      if (arr[0] == "0") {
+        sessionStorage.setItem("clusterId", arr[1]);
+        sessionStorage.setItem("devId", "");
+        console.log(this.clusterData);
+        this.clusterData.forEach((item) => {
+          if (arr[1] == item.cluster_id) {
+            sessionStorage.setItem("nodeId", item.nodeList[0].devId);
+          }
+        });
+      }
+      if (arr[0] == "1") {
+        sessionStorage.setItem("clusterId", "");
+        sessionStorage.setItem("devId", arr[1]);
+        sessionStorage.setItem("nodeId", arr[1]);
+      }
+      this.TreeDataPool.fetchTreeData();
+      this.PollData.statisticTaskInfo();
+      this.VideoManageData.init();
+      this.PollData.statistics();
+    },
   },
 };
 </script>

--
Gitblit v1.8.0