From f7f0e44c4be8eb0e77fd310296c3b43bde21e4f9 Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期四, 23 六月 2022 14:17:01 +0800
Subject: [PATCH] 新增联动场景

---
 src/views/hashrate/CameraManage/CameraRules/index.vue |   52 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/src/views/hashrate/CameraManage/CameraRules/index.vue b/src/views/hashrate/CameraManage/CameraRules/index.vue
index 5a8aea3..f951851 100644
--- a/src/views/hashrate/CameraManage/CameraRules/index.vue
+++ b/src/views/hashrate/CameraManage/CameraRules/index.vue
@@ -178,7 +178,9 @@
           <!-- 鎽勫儚鏈� -->
           <LinkageCameraBox
             :cameras="item.cameraIds"
-            @addLinkageRule="addLinkageRule(item.cameraIds)"
+            @addLinkageRule="
+              addLinkageRule(item.cameraIds, item.camera_polygons)
+            "
           ></LinkageCameraBox>
           <div class="Anchor" :id="'linkage_camera' + index"></div>
 
@@ -242,7 +244,7 @@
       :linkEditCamera="
         ruleType === 'linkage' && editSdkObj ? editSdkObj.camera_polygons : null
       "
-      :Cameras="ruleType === 'linkage' ? Carmeras : [Camera]"
+      :Cameras="ruleType === 'linkage' ? addData.cameras : [Camera]"
     ></SdkSettingBox>
 
     <!-- 閬僵灞� -->
@@ -355,6 +357,7 @@
       },
       showNewLinkage: false,
       newLinkageIds: [],
+      newLinkPlg: null,
 
       // swiperOption: {
       //   slidesPerView: 5,
@@ -543,8 +546,6 @@
         return;
       }
 
-      console.log("init");
-
       this.plumbIns.deleteEveryConnection();
       this.connectArr.forEach((item) => {
         item.deleteEveryConnection();
@@ -587,10 +588,6 @@
         .then((rsp) => {
           if (rsp && rsp.success) {
             rules = rsp.data.rules;
-            // 缁熶竴瑙勫垯缂栬緫鐨勬暟鎹粨鏋�
-            for (let i = 0; i < rules.length; i++) {
-              rules[i].group_rules = rules[i].rules;
-            }
 
             this.linkageRule = rules;
 
@@ -813,7 +810,9 @@
       this.showAddBox = true;
     },
 
-    addLinkageRule(ids) {
+    addLinkageRule(ids, camera_polygons) {
+      console.log(7979);
+      console.log(camera_polygons);
       if (ids.length < 2) {
         this.$message({
           message: "璇疯嚦灏戦�夋嫨涓ゅ彴鎽勫儚鏈�",
@@ -824,6 +823,7 @@
       this.newLinkageIds = ids;
       this.ruleType = "linkage";
       this.showAddBox = true;
+      this.newLinkPlg = camera_polygons;
     },
 
     //鍥炲~鏂扮殑鐙珛鍦烘櫙
@@ -841,6 +841,9 @@
           });
         } else {
           //鑱斿姩鍦烘櫙
+          if (this.newLinkPlg) {
+            newRule.data.camera_polygons = this.newLinkPlg;
+          }
           newRule.data.cameraIds = this.newLinkageIds;
           this.linkageRule.push(newRule.data);
           this.$nextTick(() => {
@@ -905,6 +908,35 @@
         type,
         index,
       };
+      if (this.addData.type === "linkage") {
+        this.addData.cameras = [];
+        if (
+          this.linkageRule[index].camera_polygons &&
+          this.linkageRule[index].camera_polygons.length > 0
+        ) {
+          this.linkageRule[index].camera_polygons.forEach((camera) => {
+            this.addData.cameras.push({
+              polygonData: camera.polygon,
+              cameraName: camera.camera_name,
+              cameraId: camera.camera_id,
+            });
+          });
+        } else {
+          this.linkageRule[index].camera_polygons = [];
+          this.Carmeras.forEach((camera) => {
+            this.addData.cameras.push({
+              polygonData: camera.polygonData,
+              cameraName: camera.cameraName,
+              cameraId: camera.cameraId,
+            });
+            this.linkageRule[index].camera_polygons.push({
+              polygon: camera.polygonData,
+              camera_name: camera.cameraName,
+              camera_id: camera.cameraId,
+            });
+          });
+        }
+      }
       this.showSdkBox = false;
       this.showSdkSettingBox = true;
     },
@@ -917,6 +949,7 @@
           newRule.rule_with_pre = "&&";
           newRule.is_save_anyhow = true;
         }
+
         this.SeparateRules[this.addData.index].rules.push(newRule);
       }
 
@@ -964,7 +997,6 @@
             let rules = rsp.data.rules ? rsp.data.rules : [];
             if (rules[index]) {
               this.linkageRule[index] = rules[index];
-              this.linkageRule.group_rules = this.linkageRule.rules;
             } else {
               this.linkageRule.splice(index, 1);
             }

--
Gitblit v1.8.0