From a6119509e09abadc65f020f594ae446883567bd5 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 04 八月 2022 04:05:44 +0800
Subject: [PATCH] 修复场景无法编辑的bug

---
 src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue |  160 +++++++++++++++++++---------------------------------
 1 files changed, 59 insertions(+), 101 deletions(-)

diff --git a/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue b/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
index 8503ddb..14f5a92 100644
--- a/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
+++ b/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
@@ -1,8 +1,7 @@
 <template>
   <div class="AddBox">
     <div class="title">
-      {{ editData.type ? "淇敼" : "娣诲姞"
-      }}{{ type === "separate" ? "鐙珛" : "鑱斿姩" }}鍦烘櫙
+      {{ editData.type ? "淇敼" : "娣诲姞" }}{{ editData.type === "separate" ? "鐙珛" : "鑱斿姩" }}鍦烘櫙
     </div>
 
     <div class="close iconfont" @click="close">&#xe60f;</div>
@@ -10,36 +9,19 @@
     <el-form :model="ruleForm" :rules="rules" ref="form">
       <div class="label">鍦烘櫙鍚嶇О</div>
       <el-form-item prop="scene_name">
-        <el-input
-          class="h32"
-          v-model="ruleForm.scene_name"
-          placeholder="璇疯緭鍏�"
-        ></el-input>
+        <el-input class="h32" v-model="ruleForm.scene_name" placeholder="璇疯緭鍏�"></el-input>
       </el-form-item>
 
       <div class="label">浜嬩欢绛夌骇</div>
       <el-form-item>
-        <el-select
-          class="h32"
-          v-model="ruleForm.alarm_level"
-          placeholder="璇烽�夋嫨"
-        >
-          <el-option
-            v-for="item in eventLevel"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value"
-          ></el-option>
+        <el-select class="h32" v-model="ruleForm.alarm_level" placeholder="璇烽�夋嫨">
+          <el-option v-for="item in eventLevel" :key="item.value" :label="item.label" :value="item.value"></el-option>
         </el-select>
       </el-form-item>
 
       <div class="label">鏃堕棿娈�</div>
       <el-form-item prop="time_rule_id">
-        <el-select
-          class="h32 left"
-          v-model="ruleForm.time_rule_id"
-          placeholder="璇烽�夋嫨"
-        >
+        <el-select class="h32 left" v-model="ruleForm.time_rule_id" placeholder="璇烽�夋嫨">
           <el-option
             v-for="item in VideoManageData.TimeRules"
             :key="item.id"
@@ -53,28 +35,13 @@
 
       <div class="label">鍦烘櫙鎻忚堪</div>
       <el-form-item>
-        <el-input
-          class="h32"
-          v-model="ruleForm.desc"
-          type="textarea"
-        ></el-input>
+        <el-input class="h32" v-model="ruleForm.desc" type="textarea"></el-input>
       </el-form-item>
 
       <div class="label">浜嬩欢澹伴煶</div>
       <el-form-item>
-        <el-select
-          v-model="ruleForm.voice"
-          placeholder="璇烽�夋嫨"
-          value-key="id"
-          @change="selSound"
-          class="h32 left"
-        >
-          <el-option
-            v-for="item in soundList"
-            :key="item.id"
-            :label="item.name"
-            :value="item"
-          ></el-option>
+        <el-select v-model="ruleForm.voice" placeholder="璇烽�夋嫨" value-key="id" @change="selSound" class="h32 left">
+          <el-option v-for="item in soundList" :key="item.id" :label="item.name" :value="item"></el-option>
         </el-select>
         <span @click="togglePlayer" v-show="ruleForm.voiceId.length">
           <i v-if="togglePlay" class="iconfont">&#xe628;</i>
@@ -88,32 +55,29 @@
       <div class="cancelBtn button" @click="close">鍙栨秷</div>
     </div>
 
-    <TimeSlider
-      v-if="showTimeSlider"
-      @close="showTimeSlider = false"
-    ></TimeSlider>
+    <TimeSlider v-if="showTimeSlider" @close="showTimeSlider = false"></TimeSlider>
   </div>
 </template>
 
 <script>
-import { getSoundList } from "@/api/event";
-import TimeSlider from "@/views/hashrate/CameraManage/CameraRules/components/TimeSlider";
+import { getSoundList } from "@/api/event"
+import TimeSlider from "@/views/hashrate/CameraManage/CameraRules/components/TimeSlider"
 
 export default {
   props: {
     type: {
-      type: String,
+      type: String
     },
-    editData: {},
+    editData: {}
   },
   components: {
-    TimeSlider,
+    TimeSlider
   },
   mounted() {
-    this.getSounds();
+    this.getSounds()
     this.eventAudio.addEventListener("ended", () => {
-      this.togglePlay = true;
-    });
+      this.togglePlay = true
+    })
   },
   data() {
     return {
@@ -124,44 +88,40 @@
         template_id: "",
         time_rule_id: "",
         voice: {},
-        voiceId: "",
+        voiceId: ""
       },
       eventLevel: [
         {
           label: "涓�绾�",
-          value: 1,
+          value: 1
         },
         {
           label: "浜岀骇",
-          value: 2,
+          value: 2
         },
         {
           label: "涓夌骇",
-          value: 3,
+          value: 3
         },
         {
           label: "鍥涚骇",
-          value: 4,
+          value: 4
         },
         {
           label: "浜旂骇",
-          value: 5,
-        },
+          value: 5
+        }
       ],
       rules: {
-        scene_name: [
-          { required: true, message: "璇疯緭鍏ュ満鏅悕绉�", trigger: "blur" },
-        ],
-        time_rule_id: [
-          { required: true, message: "璇烽�夋嫨鏃堕棿娈�", trigger: "blur" },
-        ],
+        scene_name: [{ required: true, message: "璇疯緭鍏ュ満鏅悕绉�", trigger: "blur" }],
+        time_rule_id: [{ required: true, message: "璇烽�夋嫨鏃堕棿娈�", trigger: "blur" }]
       },
       soundPath: "",
       togglePlay: true,
       eventAudio: new Audio(),
       soundList: [],
-      showTimeSlider: false,
-    };
+      showTimeSlider: false
+    }
   },
 
   methods: {
@@ -175,72 +135,70 @@
         time_rule_id: this.editData.rule.time_rule_id,
         voice: this.editData.rule.voice,
         voiceId: this.editData.rule.voiceId,
-        index: this.editData.index,
-      };
+        index: this.editData.index
+      }
       this.soundList.forEach((item) => {
         if (item.id == this.editData.rule.voiceId) {
-          this.ruleForm.voiceId = item.id;
-          this.ruleForm.voice = item;
+          this.ruleForm.voiceId = item.id
+          this.ruleForm.voice = item
         }
-      });
+      })
     },
     getSounds() {
-      let _this = this;
+      let _this = this
       getSoundList()
         .then((res) => {
           if (res.success) {
-            _this.soundList = [{ id: "", name: "绌�", path: "" }].concat(
-              res.data.voices
-            );
+            _this.soundList = [{ id: "", name: "绌�", path: "" }].concat(res.data.voices)
             if (_this.editData.type) {
-              _this.initEditData();
+              _this.initEditData()
             }
           }
         })
-        .catch((e) => console.log(e));
+        .catch((e) => console.log(e))
     },
     selSound(sound) {
-      this.soundPath = sound.path;
-      this.ruleForm.voiceId = sound.id;
-      this.togglePlay = true;
-      this.eventAudio.pause();
-      this.$forceUpdate();
+      this.soundPath = sound.path
+      this.ruleForm.voiceId = sound.id
+      this.togglePlay = true
+      this.eventAudio.pause()
+      this.$forceUpdate()
       // this.eventAudio.
     },
     togglePlayer() {
       if (!this.soundPath) {
         this.$notify({
           type: "info",
-          message: "璇峰厛閫夋嫨涓�涓0闊�!",
-        });
-        return false;
+          message: "璇峰厛閫夋嫨涓�涓0闊�!"
+        })
+        return false
       }
-      this.eventAudio.src = this.soundPath;
+      this.eventAudio.src = this.soundPath
       if (this.togglePlay) {
-        this.eventAudio.play();
-        this.togglePlay = false;
+        this.eventAudio.play()
+        this.togglePlay = false
       } else {
-        this.eventAudio.pause();
-        this.togglePlay = true;
+        this.eventAudio.pause()
+        this.togglePlay = true
       }
     },
     close() {
-      this.$emit("close");
+      this.$emit("close")
     },
     save() {
       this.$refs["form"].validate((valid) => {
         if (valid) {
           this.$emit("save", {
             action: this.editData.type ? "edit" : "add",
-            data: this.ruleForm,
-          });
+            data: this.ruleForm
+          })
         } else {
-          return false;
+          return false
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -328,4 +286,4 @@
     }
   }
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0