sd
2025-07-28 84f19ab0d37599400959e85e63cfda5df4869bc8
src/pages/cameraAccess/components/SceneRule.vue
@@ -22,7 +22,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="时间段">
            <el-select v-model="sceneForm.workingTimes" placeholder="请选择" size="mini">
            <el-select v-model="sceneForm.workTimeId" placeholder="请选择" size="mini">
              <el-option v-for="item in VideoManageData.TimeRules" :key="item.id" :label="item.name"
                :value="item.id"></el-option>
            </el-select>
@@ -35,7 +35,7 @@
            </el-select>
          </el-form-item>
        </div>
        <div class="right">
          <el-form-item label="任务描述">
@@ -124,10 +124,13 @@
            <template slot-scope="scope">
              <span v-html="scope.row.group_text"></span>
            </template>
          </el-table-column> -->
          </el-table-column>workTimeId -->
          <el-table-column label="时间段" prop="time_name" align="center">
            <template slot-scope="scope">
              {{(scope.row.workingTime || []).map(r => r.labelName).join(' / ') || ''}}
              <!-- {{(scope.row.workingTime || []).map(r => r.labelName).join(' / ') || ''}} -->
              <span v-for="(tag, idx) in VideoManageData.TimeRules.filter(t => t.id === scope.row.workTimeId)"
                :key="idx">
                {{ tag.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="检测内容" prop="checkContent" align="center">
@@ -178,6 +181,7 @@
import RuleEditor from "@/components/subComponents/RuleEditor";
import SceneEditor from "./scene/Editor";
import { getSoundList } from "@/api/event";
import { forEach } from "jszip";
export default {
  name: "SceneRuleEditor",
@@ -438,7 +442,7 @@
          message: "事件等级不能为空",
        });
        return false;
      } else if (!this.sceneForm.workingTimes) {
      } else if (!this.sceneForm.workTimeId) {
        this.$notify({
          type: "warning",
          message: "时间段不能为空",
@@ -450,19 +454,20 @@
          message: "检测内容不能为空",
        });
        return false;
      } else if (!this.sceneForm.workingTimes) {
      } else if (!this.sceneForm.warningRules) {
        this.$notify({
          type: "warning",
          message: "预警规则不能为空",
        });
        return false;
      } else if (!this.sceneForm.knowsList) {
        this.$notify({
          type: "warning",
          message: "知识库不能为空",
        });
        return false;
      }
      //  else if (!this.sceneForm.knowsList) {
      //   this.$notify({
      //     type: "warning",
      //     message: "知识库不能为空",
      //   });
      //   return false;
      // }
      return true;
    },
    saveSceneRule() {
@@ -476,25 +481,28 @@
      // this.sceneForm.rules = editorResp.rules;
      // this.sceneForm.id = editorResp.id;
      // this.sceneForm.group_text = editorResp.text;
      const workTimes = [this.sceneForm.workingTimes].map(id => {
        const timeOption = this.VideoManageData.TimeRules.find(opt => opt.id === id)
        return {
          labelId: id,
          labelName: timeOption ? timeOption.name : ''
        }
      })
      const fileIds = this.sceneForm.knowsList.map(
        path => {
          // 提取最后一级的文件ID并转换为数字
          const id = path[path.length - 1];
          return Number(id); // 或者使用 parseInt(id) 或 +id
        }
      )
      // const workTimes = [this.sceneForm.workingTimes].map(id => {
      //   const timeOption = this.VideoManageData.TimeRules.find(opt => opt.id === id)
      //   return {
      //     labelId: id,
      //     labelName: timeOption ? timeOption.name : ''
      //   }
      // })
      let fileIds = []
      if (this.sceneForm.knowsList) {
        fileIds = this.sceneForm.knowsList.map(
          path => {
            // 提取最后一级的文件ID并转换为数字
            const id = path[path.length - 1];
            return Number(id); // 或者使用 parseInt(id) 或 +id
          }
        )
      }
      this.sceneForm.taskName = this.sceneForm.scene_name
      this.sceneForm.eventLevel = this.sceneForm.alarm_level
      this.sceneForm.checks = this.sceneForm.checkContents
      this.sceneForm.rules = this.sceneForm.warningRules
      this.sceneForm.workTimes = workTimes
      // this.sceneForm.workTimes = workTimes
      this.sceneForm.taskDescription = this.sceneForm.desc
      this.sceneForm.knows = fileIds,
        this.onSaveScene(this.sceneForm);