From 3d95e04bf544177c9e847a96d903f9596b4f2cfa Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期二, 02 八月 2022 19:52:48 +0800
Subject: [PATCH] 山东最新版本

---
 src/views/hashrate/CameraManage/index.vue |  162 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 135 insertions(+), 27 deletions(-)

diff --git a/src/views/hashrate/CameraManage/index.vue b/src/views/hashrate/CameraManage/index.vue
index 61cc152..5101a13 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"
@@ -13,7 +13,10 @@
       </el-select>
     </div>
     <div class="content">
-      <CameraLeft :appName="'Camera'" ref="left"></CameraLeft>
+      <div class="column-left" ref="left">
+        <div class="resize-line" @mousedown="TextWidthChange"></div>
+        <CameraLeft :appName="'Camera'" ref="left"></CameraLeft>
+      </div>
       <div class="right">
         <div class="tabs">
           <div
@@ -51,6 +54,8 @@
 import CameraRules from "./CameraRules";
 import VideoRuleData from "@/Pool/VideoRuleData";
 
+import { getClusterDevList } from "@/api/clusterManage";
+
 import bus from "@/plugin/bus";
 export default {
   components: {
@@ -62,17 +67,9 @@
   data() {
     return {
       activeTab: "淇℃伅缁存姢",
-      clusterArr: [
-        {
-          value: 0,
-          label: "闆嗙兢涓�",
-        },
-        {
-          value: 1,
-          label: "闆嗙兢浜�",
-        },
-      ],
+      clusterArr: [],
       cluster: "",
+      clusterData: [],
       intervalTimer: null,
       leftWith: 0,
       screenHeight: 0,
@@ -84,31 +81,45 @@
   },
 
   watch: {
-    "TreeDataPool.selectedNode": function (node) {
-      if (this.TreeDataPool.multiple) {
-        return;
-      }
-
+    "TreeDataPool.activeNode": function (node) {
+      sessionStorage.setItem("cameraDevId", node.devId);
       if (this.activeTab == "淇℃伅缁存姢") {
         if (this.TreeDataPool.treeActiveName == "camera") {
           this.$refs.cameraInfo.selectCamera(node);
         }
       } else if (this.activeTab === "鍦烘櫙閰嶇疆") {
         this.$refs.sepRule.initCameraData(node.id);
+        if (!this.TreeDataPool.multiple) {
+          this.$refs.sepRule.showRules(node.id);
+        }
       }
     },
     "TreeDataPool.selectedNodes": {
-      handler(nodes) {
+      handler(nodes, oldVal) {
         if (this.activeTab == "鍦烘櫙閰嶇疆") {
           //  this.$refs.sepRule.initCameraData(nodes[nodes.length - 1]);
           let CameraArr = [];
+          let CameraIds = [];
 
           nodes.forEach((id) => {
             let newCamera = new VideoRuleData(id);
             CameraArr.push(newCamera);
+            CameraIds.push(id);
           });
 
           this.$refs.sepRule.Carmeras = CameraArr;
+          if (
+            nodes.length == 1 &&
+            oldVal.length == 1 &&
+            nodes[0] == oldVal[0]
+          ) {
+            return;
+          }
+          if (this.TreeDataPool.multiple && oldVal[0]) {
+            this.$refs.sepRule.showRules(CameraIds);
+          }
+
+          console.log(CameraArr);
         }
       },
       deep: true,
@@ -130,7 +141,7 @@
     },
   },
   created() {
-    this.PollData.statistics();
+    this.getCluster();
     this.TreeDataPool.readonly = false;
 
     //  this.TreeDataPool.readonly = true;
@@ -138,9 +149,10 @@
     this.TreeDataPool.multiple = false;
     this.TreeDataPool.selectedNode = "";
     this.selectedNodes = [];
-    this.VideoManageData.init();
   },
   beforeDestroy() {
+    sessionStorage.removeItem("devId");
+    sessionStorage.removeItem("clusterId");
     clearInterval(this.intervalTimer);
     //this.TreeDataPool.treeActiveName = "camera";
   },
@@ -154,14 +166,33 @@
       });
       this.TreeDataPool.clean();
     });
-
-    let _this = this;
-    _this.PollData.statisticTaskInfo();
-    this.intervalTimer = setInterval(() => {
-      _this.PollData.statisticTaskInfo();
-    }, 10000);
   },
   methods: {
+    TextWidthChange(e) {
+      console.log(1212);
+      let odivParent = e.currentTarget.parentNode; //鑾峰彇鐩爣鐖跺厓绱�
+      let dx = e.clientX; //褰撲綘绗竴娆″崟鍑荤殑鏃跺�欙紝瀛樺偍x杞寸殑鍧愭爣銆�
+      let dw = odivParent.offsetWidth; //瀛樺偍榛樿鐨刣iv鐨勫搴︺��
+      document.onmousemove = (e) => {
+        odivParent.style.width = dw + (e.clientX - dx) + "px";
+
+        if (odivParent.offsetWidth <= 100) {
+          //褰撶洅瀛愮缉灏忓埌涓�瀹氳寖鍥村唴鐨勬椂鍊欙紝璁╀粬淇濇寔涓�涓浐瀹氬�硷紝涓嶅啀缁х画鏀瑰彉
+          odivParent.style.width = "100px";
+        }
+
+        if (odivParent.offsetWidth + odivParent.offsetLeft >= this.pdfWidth) {
+          odivParent.style.width = this.pdfWidth - odivParent.offsetLeft + "px";
+        }
+      };
+      document.onmouseup = (e) => {
+        document.onmousemove = null;
+        document.onmouseup = null;
+      };
+      e.stopPropagation();
+      e.preventDefault();
+      return false;
+    },
     handAddDevice(node) {
       let _this = this;
       setTimeout(() => {
@@ -189,10 +220,71 @@
       } else if (tab === "鍦烘櫙閰嶇疆") {
         if (this.TreeDataPool.treeActiveName == "camera") {
           this.$refs.sepRule.initCameraData(this.TreeDataPool.selectedNode.id);
+          this.$refs.sepRule.showRules(this.TreeDataPool.selectedNode.id);
         } else if (this.TreeDataPool.treeActiveName == "dataStack") {
           this.$refs.sepRule.initCameraData(this.DataStackPool.selectedDir.id);
         }
       }
+    },
+    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();
     },
   },
 };
@@ -248,9 +340,25 @@
     margin-bottom: 60px;
     display: flex;
     align-items: stretch;
-    .CameraLeft {
+    .column-left {
+      position: relative;
       margin-right: 24px;
       width: 292px;
+      background-color: #fff;
+    }
+
+    .resize-line {
+      position: absolute;
+      right: 0;
+      top: 0;
+      bottom: 0;
+      border-right: 2px solid #efefef;
+      border-left: 2px solid #e0e0e0;
+      z-index: 1;
+      cursor: ew-resize;
+    }
+    .resize-line:hover {
+      border-left: 2px dashed skyblue;
     }
 
     .right {

--
Gitblit v1.8.0