From b200eed05d5bff2e12a45331bdc062f4b00bebf7 Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期四, 28 七月 2022 10:20:51 +0800
Subject: [PATCH] 列表样式

---
 src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue |   42 +++++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue b/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
index 1ed8212..8503ddb 100644
--- a/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
+++ b/src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue
@@ -7,9 +7,9 @@
 
     <div class="close iconfont" @click="close">&#xe60f;</div>
 
-    <el-form :model="ruleForm">
+    <el-form :model="ruleForm" :rules="rules" ref="form">
       <div class="label">鍦烘櫙鍚嶇О</div>
-      <el-form-item>
+      <el-form-item prop="scene_name">
         <el-input
           class="h32"
           v-model="ruleForm.scene_name"
@@ -34,7 +34,7 @@
       </el-form-item>
 
       <div class="label">鏃堕棿娈�</div>
-      <el-form-item>
+      <el-form-item prop="time_rule_id">
         <el-select
           class="h32 left"
           v-model="ruleForm.time_rule_id"
@@ -114,9 +114,6 @@
     this.eventAudio.addEventListener("ended", () => {
       this.togglePlay = true;
     });
-    if (this.editData.type) {
-      this.initEditData();
-    }
   },
   data() {
     return {
@@ -151,6 +148,14 @@
           value: 5,
         },
       ],
+      rules: {
+        scene_name: [
+          { required: true, message: "璇疯緭鍏ュ満鏅悕绉�", trigger: "blur" },
+        ],
+        time_rule_id: [
+          { required: true, message: "璇烽�夋嫨鏃堕棿娈�", trigger: "blur" },
+        ],
+      },
       soundPath: "",
       togglePlay: true,
       eventAudio: new Audio(),
@@ -172,6 +177,12 @@
         voiceId: this.editData.rule.voiceId,
         index: this.editData.index,
       };
+      this.soundList.forEach((item) => {
+        if (item.id == this.editData.rule.voiceId) {
+          this.ruleForm.voiceId = item.id;
+          this.ruleForm.voice = item;
+        }
+      });
     },
     getSounds() {
       let _this = this;
@@ -179,8 +190,11 @@
         .then((res) => {
           if (res.success) {
             _this.soundList = [{ id: "", name: "绌�", path: "" }].concat(
-              res.data
+              res.data.voices
             );
+            if (_this.editData.type) {
+              _this.initEditData();
+            }
           }
         })
         .catch((e) => console.log(e));
@@ -214,9 +228,15 @@
       this.$emit("close");
     },
     save() {
-      this.$emit("save", {
-        action: this.editData.type ? "edit" : "add",
-        data: this.ruleForm,
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          this.$emit("save", {
+            action: this.editData.type ? "edit" : "add",
+            data: this.ruleForm,
+          });
+        } else {
+          return false;
+        }
       });
     },
   },
@@ -233,7 +253,7 @@
   background-color: #fff;
   box-shadow: 0px 2px 16px 0px rgba(0, 43, 106, 0.25);
 
-  z-index: 2;
+  z-index: 2002;
 
   .title {
     box-sizing: border-box;

--
Gitblit v1.8.0