ZZJ
2022-07-14 2b99047683332624832c1dfcae596e957a710b7d
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;