From 994e5e08cba4e6b9ce321b7cf5cb1ec8d19dfa22 Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期二, 12 四月 2022 17:50:21 +0800
Subject: [PATCH] 摄像机管理

---
 src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue |   64 +++++++++++++++++++++----------
 1 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue b/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue
index f385dce..f8d8476 100644
--- a/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue
+++ b/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue
@@ -87,6 +87,7 @@
     </div>
     <div class="control">
       <div class="title">鍦烘櫙鎿嶄綔</div>
+      <span class="close iconfont" @click="deleteRule">&#xe60f;</span>
       <div class="content">
         <div class="btns">
           <div class="button cancel" @click="backToOrigin">鍙栨秷</div>
@@ -100,12 +101,13 @@
 
 <script>
 import bus from "@/plugin/bus";
-import { saveLinkScene, saveCameraScene } from "@/api/scene";
+import { saveLinkScene, saveCameraScene, deleteCameraScene } from "@/api/scene";
 
 export default {
   props: {
     rule: {},
     ruleType: {},
+    cameraId: {},
   },
   created() {
     this.getSdkConnection();
@@ -204,36 +206,46 @@
     },
     save() {
       if (this.ruleType === "separate") {
-        this.rule.cameraIds = [this.rule.cameraId];
+        this.rule.cameraIds = [this.cameraId];
         saveCameraScene(this.rule).then((rsp) => {
           if (rsp && rsp.success) {
             this.$notify({
               type: "success",
               message: "绛栫暐淇濆瓨鎴愬姛锛�",
             });
+            this.backToOrigin();
           }
         });
       } else {
-        saveLinkScene(this.rule)
-          .then((rsp) => {
-            if (rsp && rsp.success) {
-              this.$notify({
-                type: "success",
-                message: "浠诲姟淇濆瓨鎴愬姛锛�",
-              });
-            } else {
-              this.$notify({
-                type: "error",
-                message: rsp.data,
-              });
-            }
-          })
-          .catch((err) => {
-            this.$message({
-              type: "error",
-              message: "淇濆瓨澶辫触锛�",
+        saveLinkScene(this.rule).then((rsp) => {
+          if (rsp && rsp.success) {
+            this.$notify({
+              type: "success",
+              message: "浠诲姟淇濆瓨鎴愬姛锛�",
             });
-          });
+            this.backToOrigin();
+          } else {
+            this.$notify({
+              type: "error",
+              message: rsp.data,
+            });
+          }
+        });
+      }
+    },
+    async deleteRule() {
+      if (!this.rule.id) {
+        console.log("87878");
+        this.backToOrigin();
+        return;
+      }
+      const res = await deleteCameraScene(this.rule.id);
+      if (res && res.success) {
+        this.$notify({
+          type: "success",
+          message: "鍒犻櫎鎴愬姛",
+        });
+        this.$emit("deletRule");
       }
     },
     update() {
@@ -387,8 +399,18 @@
   }
 
   .control {
+    position: relative;
     width: 128px;
 
+    .close {
+      position: absolute;
+      top: 12px;
+      right: 15px;
+      font-size: 12px;
+      color: #e34d59;
+      cursor: pointer;
+    }
+
     .btns {
       display: flex;
       margin-top: 68px;

--
Gitblit v1.8.0