zhangzengfei
2022-08-04 a6119509e09abadc65f020f594ae446883567bd5
修复场景无法编辑的bug
5个文件已修改
1169 ■■■■■ 已修改文件
src/Pool/BaseManageData.ts 136 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Pool/PollData.ts 163 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/scripts/httpRequest.ts 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/hashrate/CameraManage/CameraRules/components/AddRuleBox.vue 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/hashrate/CameraManage/CameraRules/index.vue 700 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Pool/BaseManageData.ts
@@ -7,63 +7,58 @@
  getTagList,
  copy,
  move
} from "@/api/baseLibrary";
} from "@/api/baseLibrary"
export default class BaseManageData {
  public syncTables: Array<object> = [];
  public localTables: Array<object> = [];
  public personList: Array<object>;
  public personId: string = "";
  public blackList: Array<object> = [];
  public selectBlacks: Array<object> = [];
  public whiteList: Array<object> = [];
  public selectWhites: Array<object> = [];
  public page: number;
  public size: number;
  public contentValue: string = "";
  public tableId: number;
  public orderName: string = "createTime";
  public orderType: string = "desc";
  public faceUrl: string = "";
  public threshold: number = 60;
  public total: number;
  public picUrl: string = "";
  public syncTables: Array<object> = []
  public localTables: Array<object> = []
  public personList: Array<object>
  public personId: string = ""
  public blackList: Array<object> = []
  public selectBlacks: Array<object> = []
  public whiteList: Array<object> = []
  public selectWhites: Array<object> = []
  public page: number
  public size: number
  public contentValue: string = ""
  public tableId: number
  public orderName: string = "createTime"
  public orderType: string = "desc"
  public faceUrl: string = ""
  public threshold: number = 60
  public total: number
  public picUrl: string = ""
  constructor() {
    this.personList = [];
    this.page = 1;
    this.size = 10;
    this.total = 0;
    this.personList = []
    this.page = 1
    this.size = 10
    this.total = 0
  }
  cleanData() {
    this.personList = [];
    this.page = 1;
    this.size = 10;
    this.total = 0;
    this.personList = []
    this.page = 1
    this.size = 10
    this.total = 0
  }
  async querySyncTables() {
    const rsp: any = await getSyncTables({
    });
    const rsp: any = await getSyncTables({})
    if (rsp && rsp.success) {
      this.syncTables.splice(0, this.syncTables.length)
      rsp.data.datalist.forEach(element => {
        this.syncTables.push((element as any))
      });
      rsp.data.datalist.forEach((element) => {
        this.syncTables.push(element as any)
      })
    }
  }
  async queryLocalTables() {
    const rsp: any = await getLocalTables({
    });
    const rsp: any = await getLocalTables({})
    if (rsp && rsp.success) {
      this.localTables.splice(0, this.localTables.length)
      rsp.data.datalist.forEach(element => {
        this.localTables.push((element as any))
      });
      rsp.data.datalist.forEach((element) => {
        this.localTables.push(element as any)
      })
    }
  }
@@ -75,37 +70,34 @@
      contentValue: this.contentValue,
      orderType: this.orderType,
      orderName: this.orderName
    });
    })
    if (rsp && rsp.success) {
      this.personList.splice(0, this.personList.length)
      rsp.data.datalist.forEach(element => {
      rsp.data.datalist.forEach((element) => {
        let carUrls = element.carPicUrls.split(";")
        element.carUrls = []
        carUrls.forEach(picUrl => {
        carUrls.forEach((picUrl) => {
          element.carUrls.push({ url: "/httpImage/" + picUrl })
        });
        })
        element.faceUrl = []
        element.faceUrl.push({ url: "/httpImage/" + element.personPicUrl })
        this.personList.push((element as any))
      });
        this.personList.push(element as any)
      })
      this.total = rsp.data.total
    }
  }
  async queryPersonListByPhoto() {
    const rsp: any = await getPersonListByPhoto({
    });
    const rsp: any = await getPersonListByPhoto({})
    if (rsp && rsp.success) {
      this.personList.splice(0, this.personList.length)
      rsp.data.datalist.forEach(element => {
        this.personList.push((element as any))
      });
      rsp.data.datalist.forEach((element) => {
        this.personList.push(element as any)
      })
    }
  }
  async searchPhotoFromBase() {
    var bases = new Array()
    console.log("tableId", this.tableId)
    bases.push(this.tableId)
    const rsp: any = await searchFromBase({
      databases: bases,
@@ -114,41 +106,43 @@
      threshold: this.threshold,
      picUrl: this.picUrl
    })
    console.log("底库以图搜图返回:", rsp)
    this.personList = [];
    this.personList = []
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
        this.personList.push((element as any))
      });
      console.log("列表:", this.personList)
      rsp.data.totalList.forEach((element) => {
        this.personList.push(element as any)
      })
      this.total = rsp.data.total
    }
  }
  async queryTagList() {
    const rsp: any = await getTagList({});
    const rsp: any = await getTagList({})
    // console.log("tag返回值: ",rsp)
    if (rsp && rsp.success) {
      // 放置黑白名单 0为白名单
      this.blackList.length = 0
      this.whiteList.length = 0
      rsp.data.forEach(i => {
        if (i.status === 0 && i.bwType === "0") { //白名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
      rsp.data.forEach((i) => {
        if (i.status === 0 && i.bwType === "0") {
          //白名单
          if (i.analyServerId === "") {
            //同步库
            i.title = i.title + "(同步库)"
            this.whiteList.push(i)
          } else {
            this.whiteList.push(i)
          }
        }
        if (i.status === 0 && i.bwType === "1") { //黑名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
        if (i.status === 0 && i.bwType === "1") {
          //黑名单
          if (i.analyServerId === "") {
            //同步库
            i.title = i.title + "(同步库)"
            this.blackList.push(i)
          } else {
            this.blackList.push(i)
          }
        }
      });
      })
    }
  }
  async copyTo() {
@@ -167,7 +161,5 @@
    const rsp: any = await move(param)
    return rsp
  }
  mounted() {
  }
}
  mounted() {}
}
src/Pool/PollData.ts
@@ -1,106 +1,97 @@
import { getPollConfig, changeRunType, getCamerasByServer, updateChannelCount } from "@/api/pollConfig";
import {  getSysThresholds } from "@/api/system"
import {
  clusterStatisticRunInfo,
  deviceStatisticRunInfo,
  devicesSysInfo,
  clusterSysInfo
} from "@/api/clusterManage";
import { getPollConfig, changeRunType, getCamerasByServer, updateChannelCount } from "@/api/pollConfig"
import { getSysThresholds } from "@/api/system"
import { clusterStatisticRunInfo, deviceStatisticRunInfo, devicesSysInfo, clusterSysInfo } from "@/api/clusterManage"
export default class PollData {
  public Config: Object = {};
  public SearchName: String = "";
  public CameraList: Array<object> = [];
  public Enabled: boolean = false;
  public Config: Object = {}
  public SearchName: String = ""
  public CameraList: Array<object> = []
  public Enabled: boolean = false
  //总算力
  public channelTotal: number = 0;
  public channelTotal: number = 0
  public Running: number = 0;
  public Idle: number = 0;
  public Running: number = 0
  public Idle: number = 0
  //实时全部打开
  public RealTimeSum: number = 0;
  public RealTimeSum: number = 0
  //实时算力总数
  public RealTimeValidCount: number = 0;
  public RealTimeValidCount: number = 0
  //实时配置不全
  public RealTimeInvalid: number = 0;
  public RealTimeInvalid: number = 0
  //实时正在处理
  public RealTimeRun: number = 0;
  public RealTimeRun: number = 0
  //实时故障
  public RealTimeNoDeal: number = 0;
  public RealTimeNoDeal: number = 0
  //轮询算力总数
  public PollValidCount: number = 0;
  public PollValidCount: number = 0
  //轮询全部打开
  public PollSum: number = 0;
  public PollSum: number = 0
  //轮询正在执行
  public PollRun: number = 0;
  public PollRun: number = 0
  //轮询配置不全
  public PollInvalid: number = 0;
  public PollInvalid: number = 0
  //轮询故障
  public PollNoDeal: number = 0;
  public PollChannelTotal: number = 0;
  public PollNoDeal: number = 0
  public PollChannelTotal: number = 0
  //数据栈算力总数
  public stackChannelCount: number = 0;
  public stackChannelCount: number = 0
  //数据栈总数
  public stackTotal: number = 0;
  public stackTotal: number = 0
  //数据栈配置不全
  public stackInvalidCount: number = 0;
  public stackInvalidCount: number = 0
  //数据栈正在执行
  public stackRunningCount: number = 0;
  public stackRunningCount: number = 0
  //数据栈故障
  public stackNoDeal: number = 0;
  public stackNoDeal: number = 0
  //本地算力通道数
  public localVideo: number = 0;
  public localVideo: number = 0
  public CpuUsedPercent: number = 0;
  public MemUsedPercent: number = 0;
  public GpuUsedPercent: number = 0;
  public DiskUsePercent: number = 0;
  public barCharts: Array<any> = [];
  public Thresholds: Array<object> = [];
  public CpuUsedPercent: number = 0
  public MemUsedPercent: number = 0
  public GpuUsedPercent: number = 0
  public DiskUsePercent: number = 0
  public barCharts: Array<any> = []
  public Thresholds: Array<object> = []
  //算力配置中滑块数据
  public sliderList: Array<any> = [];
  public sliderList: Array<any> = []
  public init() {
    this.fetchPollConfig();
    this.fetchPollList();
    this.sysThresholds();
    this.statisticTaskInfo();
    this.fetchPollConfig()
    this.fetchPollList()
    this.sysThresholds()
    this.statisticTaskInfo()
  }
  public async fetchPollConfig() {
    const rsp: any = await getPollConfig();
    const rsp: any = await getPollConfig()
    if (rsp && rsp.success) {
      this.Config = rsp.data;
      this.Config = rsp.data
      if (rsp.data.enable) {
        this.Enabled = true;
        this.Enabled = true
      }
    }
  }
  public async fetchPollList() {
    this.CameraList = []
    let rsp: any = await getCamerasByServer({ cameraName: this.SearchName });
    let rsp: any = await getCamerasByServer({ cameraName: this.SearchName })
    if (rsp && rsp.success) {
      if (rsp.data) {
        this.CameraList = rsp.data.sort(function (obj1: any, obj2: any) {
          var val1 = obj1.run_type;
          var val2 = obj2.run_type;
          return (val2 - val1)
        });
        this.CameraList = rsp.data.sort(function(obj1: any, obj2: any) {
          var val1 = obj1.run_type
          var val2 = obj2.run_type
          return val2 - val1
        })
      }
    }
    // 根据rtsp 提取ip地址
    const ipReg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
    const ipReg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
    this.CameraList.forEach((cam: any) => {
      // 国标摄像机不显示ip
      if (cam.type === 1) {
@@ -115,13 +106,13 @@
  }
  public async switchType(id: string, type: number) {
    let rsp: any = await changeRunType({ camera_ids: [id], run_type: type });
    let rsp: any = await changeRunType({ camera_ids: [id], run_type: type })
  }
  public async sysThresholds() {
    let rsp: any = await getSysThresholds()
    if (rsp && rsp.success) {
      this.Thresholds = rsp.data;
      this.Thresholds = rsp.data
    }
  }
  public async statistics() {
@@ -154,42 +145,37 @@
    // this.Idle = RealTimeSum + PollSum - this.Running
    // 计算系统信息
     let res: any
    if(sessionStorage.getItem("clusterId")) {
      res  = await clusterSysInfo({
        clusterId: "",
      });
    let res: any
    if (sessionStorage.getItem("clusterId")) {
      res = await clusterSysInfo({
        clusterId: ""
      })
    } else {
      res = await devicesSysInfo({
        deviceId: [sessionStorage.getItem("devId")]
      })
    }
    else {
      res  = await devicesSysInfo({
        deviceId:[sessionStorage.getItem('devId')],
      });
    }
    if (res && res.success ) {
      this.CpuUsedPercent =res.data.cpu.usedPercent.toFixed(2)
    if (res && res.success) {
      this.CpuUsedPercent = res.data.cpu.usedPercent.toFixed(2)
      this.MemUsedPercent = res.data.mem.usedPercent.toFixed(2)
      this.DiskUsePercent =res.data.disk.usedPercent.toFixed(2)
      this.DiskUsePercent = res.data.disk.usedPercent.toFixed(2)
      this.GpuUsedPercent = res.data.gpu.usedPercent.toFixed(2)
      this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent]
      console.log(this.barCharts);
      this.barCharts = [this.DiskUsePercent, this.CpuUsedPercent, this.GpuUsedPercent, this.MemUsedPercent]
    }
  }
  public async statisticTaskInfo() {
    let res: any
    if(sessionStorage.getItem("clusterId")) {
      res  = await clusterStatisticRunInfo({});
    if (sessionStorage.getItem("clusterId")) {
      res = await clusterStatisticRunInfo({})
    } else {
      res = await deviceStatisticRunInfo({
        deviceId: [sessionStorage.getItem("devId")],
        userId: ""
      })
    }
    else {
      res  = await deviceStatisticRunInfo({
        deviceId:[sessionStorage.getItem('devId')],
        userId:''
      });
    }
    if (res && res.success) {
      // console.log(res,'统计实时、轮询数量')
      this.RealTimeSum = res.data.realTotal
      this.RealTimeRun = res.data.realRunningCount
      this.RealTimeValidCount = res.data.realValidCount
@@ -218,21 +204,20 @@
      let totalCount = res.data.channelTotal
      let realCount = res.data.realValidCount
      let pollCount = res.data.pollChannelCount
      this.sliderList = [0,realCount,realCount + pollCount]
      this.sliderList = [0, realCount, realCount + pollCount]
      // if(realCount + pollCount == totalCount){
      //   this.sliderList = [0,realCount,realCount + pollCount]
      // }else{
      //   this.sliderList = [0,realCount,realCount + pollCount,totalCount]
      // }
    }
  }
  public async updateChannelCount(fileChannelCount,pollChannelCount){
  public async updateChannelCount(fileChannelCount, pollChannelCount) {
    let res: any = await updateChannelCount({
      videoChannelCount: fileChannelCount,
      pollChannelCount: pollChannelCount
    })
    this.statisticTaskInfo()
  }
}
}
src/scripts/httpRequest.ts
@@ -12,9 +12,6 @@
/* //POST传参序列化(添加请求拦截器) */
Axios.interceptors.request.use(
  (config) => {
    console.log(9898)
    console.log(config)
    if ((config.method === "post" && sessionStorage.getItem("clusterId")) || sessionStorage.getItem("devId")) {
      if (!config.data) {
        config.data = {}
@@ -49,8 +46,7 @@
    return config
  },
  (error) => {
    console.log("请求错误")
    console.log(error)
    console.log("请求错误", error)
    /*  Message({
      showClose: true,
@@ -91,7 +87,6 @@
    var disposition = res.headers["content-disposition"]
    if (disposition) {
      var fileName = disposition.substring(disposition.indexOf("=") + 1)
      console.log(res)
      return {
        fileName: fileName,
@@ -104,8 +99,7 @@
    /* //return res.data ? res.data : {}; */
  },
  (error) => {
    console.log("响应错误")
    console.log(error)
    console.log("响应错误", error)
    let errJson: any = {
      success: false
    }
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: "请先选择一个声音!",
        });
        return false;
          message: "请先选择一个声音!"
        })
        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>
</style>
src/views/hashrate/CameraManage/CameraRules/index.vue
@@ -71,19 +71,10 @@
        <div class="draw-box" v-else>
          <div class="title">查看区域</div>
          <div class="img-box">
            <span class="camera-tip" v-show="swipercanvasData.length == 0"
              >暂无区域,请至少选择2个摄像机</span
            >
            <span class="camera-tip" v-show="swipercanvasData.length == 0">暂无区域,请至少选择2个摄像机</span>
            <!-- swiper 展示 -->
            <swiper
              ref="swiper"
              :options="swiperOption"
              class="swiper-box-container2"
            >
              <swiper-slide
                v-for="(data, index) in swipercanvasData"
                :key="index"
              >
            <swiper ref="swiper" :options="swiperOption" class="swiper-box-container2">
              <swiper-slide v-for="(data, index) in swipercanvasData" :key="index">
                <!--  <b
                  class="video-title"
                  style="font-size: 14px; margin-top: -10px"
@@ -112,10 +103,7 @@
                <i class="iconfont">&#xe618;</i>
              </div>
            </div>
            <div
              class="swiper-next-border"
              v-show="swipercanvasData.length > 1"
            >
            <div class="swiper-next-border" v-show="swipercanvasData.length > 1">
              <div class="icon-btn" slot="button-next">
                <i class="iconfont">&#xe623;</i>
              </div>
@@ -129,39 +117,20 @@
    <div class="SeparateRules" @click="selectMultiple(false)">
      <div class="title">独立场景</div>
      <div class="control">
        <el-tooltip
          class="item"
          effect="dark"
          content="算法事件"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="算法事件" placement="top">
          <i class="iconfont" @click="openSdkBox($event)">&#xe650;</i>
        </el-tooltip>
        <el-tooltip
          class="item"
          effect="dark"
          content="数据流传"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="数据流传" placement="top">
          <i class="iconfont">&#xe64e;</i>
        </el-tooltip>
        <el-tooltip
          class="item"
          effect="dark"
          content="模板助手"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="模板助手" placement="top">
          <i class="iconfont">&#xe64f;</i>
        </el-tooltip>
      </div>
      <div class="content">
        <!-- 摄像机 -->
        <CameraBox
          :camera="Camera"
          id="separate_camera"
          @addSeparateRule="addSeparateRule"
        ></CameraBox>
        <CameraBox :camera="Camera" id="separate_camera" @addSeparateRule="addSeparateRule"></CameraBox>
        <!-- 场景区域 -->
        <div class="RuleArea" v-if="show">
@@ -192,28 +161,13 @@
    <div class="linkageRule" @click="selectMultiple(true)">
      <div class="title">联动场景</div>
      <div class="control">
        <el-tooltip
          class="item"
          effect="dark"
          content="算法事件"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="算法事件" placement="top">
          <i class="iconfont" @click="showSdkBox = true">&#xe650;</i>
        </el-tooltip>
        <el-tooltip
          class="item"
          effect="dark"
          content="数据流传"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="数据流传" placement="top">
          <i class="iconfont">&#xe64e;</i>
        </el-tooltip>
        <el-tooltip
          class="item"
          effect="dark"
          content="模板助手"
          placement="top"
        >
        <el-tooltip class="item" effect="dark" content="模板助手" placement="top">
          <i class="iconfont">&#xe64f;</i>
        </el-tooltip>
      </div>
@@ -222,9 +176,7 @@
          <!-- 摄像机 -->
          <LinkageCameraBox
            :cameras="item.cameraIds"
            @addLinkageRule="
              addLinkageRule(item.cameraIds, item.camera_polygons)
            "
            @addLinkageRule="addLinkageRule(item.cameraIds, item.camera_polygons)"
          ></LinkageCameraBox>
          <div class="Anchor" :id="'linkage_camera' + index"></div>
@@ -244,22 +196,13 @@
        </div>
      </template>
      <div
        class="empty"
        v-if="linkageRule.length <= 0 && !TreeDataPool.multiple"
      >
      <div class="empty" v-if="linkageRule.length <= 0 && !TreeDataPool.multiple">
        <img src="/images/hashrate/l_empty.png" alt="" />
        <div class="des">暂无联动场景</div>
      </div>
      <div
        class="newCameraArea"
        v-if="linkageRule.length <= 0 && TreeDataPool.multiple"
      >
        <LinkageCameraBox
          :cameras="CarmerasId"
          @addLinkageRule="addLinkageRule(CarmerasId)"
        ></LinkageCameraBox>
      <div class="newCameraArea" v-if="linkageRule.length <= 0 && TreeDataPool.multiple">
        <LinkageCameraBox :cameras="CarmerasId" @addLinkageRule="addLinkageRule(CarmerasId)"></LinkageCameraBox>
        <div class="empty">
          <img src="/images/hashrate/l_empty.png" alt="" />
@@ -285,9 +228,7 @@
      @getNewSdk="getNewSdk"
      @getEditSdk="getEditSdk"
      :editSdk="editSdkObj.sdk"
      :linkEditCamera="
        ruleType === 'linkage' && editSdkObj ? editSdkObj.camera_polygons : null
      "
      :linkEditCamera="ruleType === 'linkage' && editSdkObj ? editSdkObj.camera_polygons : null"
      :Cameras="ruleType === 'linkage' ? addData.cameras : [Camera]"
    ></SdkSettingBox>
@@ -297,29 +238,29 @@
</template>
<script>
import { jsPlumb } from "jsplumb";
import { jsPlumb } from "jsplumb"
import { savePolygon } from "@/api/polygon";
import { savePolygon } from "@/api/polygon"
import { pasteRules } from "@/api/task";
import { getCameraSceneRule } from "@/api/scene";
import { pasteRules } from "@/api/task"
import { getCameraSceneRule } from "@/api/scene"
import { saveCameraScene, getLinkSceneRule } from "@/api/scene";
import { saveCameraScene, getLinkSceneRule } from "@/api/scene"
import { changeRunType } from "@/api/pollConfig";
import { findAllFileByStackId } from "@/api/localVedio";
import VideoRuleData from "@/Pool/VideoRuleData";
import { changeRunType } from "@/api/pollConfig"
import { findAllFileByStackId } from "@/api/localVedio"
import VideoRuleData from "@/Pool/VideoRuleData"
import polygonCanvas from "@/components/canvas";
import Sysinfo from "@/components/subComponents/SystemInfo";
import SlideScene from "./components/scene/SlideScene";
import HashrateCard from "@/views/hashrate/CameraManage/CameraRules/components/HashrateCard";
import CameraBox from "@/views/hashrate/CameraManage/CameraRules/components/CameraBox";
import LinkageCameraBox from "@/views/hashrate/CameraManage/CameraRules/components/LinkageCameraBox";
import RuleItem from "@/views/hashrate/CameraManage/CameraRules/components/RuleItem";
import AddRuleBox from "@/views/hashrate/CameraManage/CameraRules/components/AddRuleBox";
import SdkBox from "@/views/hashrate/CameraManage/CameraRules/components/SdkBox";
import SdkSettingBox from "@/views/hashrate/CameraManage/CameraRules/components/SdkSettingBox";
import polygonCanvas from "@/components/canvas"
import Sysinfo from "@/components/subComponents/SystemInfo"
import SlideScene from "./components/scene/SlideScene"
import HashrateCard from "@/views/hashrate/CameraManage/CameraRules/components/HashrateCard"
import CameraBox from "@/views/hashrate/CameraManage/CameraRules/components/CameraBox"
import LinkageCameraBox from "@/views/hashrate/CameraManage/CameraRules/components/LinkageCameraBox"
import RuleItem from "@/views/hashrate/CameraManage/CameraRules/components/RuleItem"
import AddRuleBox from "@/views/hashrate/CameraManage/CameraRules/components/AddRuleBox"
import SdkBox from "@/views/hashrate/CameraManage/CameraRules/components/SdkBox"
import SdkSettingBox from "@/views/hashrate/CameraManage/CameraRules/components/SdkSettingBox"
export default {
  components: {
@@ -332,31 +273,29 @@
    AddRuleBox,
    SdkBox,
    SdkSettingBox,
    LinkageCameraBox,
    LinkageCameraBox
  },
  directives: {
    focus: {
      inserted: function (el) {
        el.querySelector("input").focus();
      },
    },
      inserted: function(el) {
        el.querySelector("input").focus()
      }
    }
  },
  computed: {
    cameraType() {
      return this.TreeDataPool.treeActiveName === "camera"
        ? "camera"
        : "dataStack";
      return this.TreeDataPool.treeActiveName === "camera" ? "camera" : "dataStack"
    },
    selectedCameraIds() {
      return this.TreeDataPool.selectedNodes;
      return this.TreeDataPool.selectedNodes
    },
    CarmerasId() {
      let arr = [];
      let arr = []
      this.Carmeras.forEach((item) => {
        arr.push(item.cameraId);
      });
      return arr;
    },
        arr.push(item.cameraId)
      })
      return arr
    }
  },
  data() {
    return {
@@ -370,12 +309,12 @@
        grabCursor: true,
        pagination: {
          el: ".swiper-pagination",
          type: "fraction",
          type: "fraction"
        },
        navigation: {
          nextEl: ".swiper-local-next",
          prevEl: ".swiper-local-prev",
        },
          prevEl: ".swiper-local-prev"
        }
      },
      plumbIns: null,
      plumbIns2: null,
@@ -392,12 +331,12 @@
        grabCursor: true,
        pagination: {
          el: ".swiper-pagination",
          type: "fraction",
          type: "fraction"
        },
        navigation: {
          nextEl: ".swiper-pre-border",
          prevEl: ".swiper-next-border",
        },
          prevEl: ".swiper-next-border"
        }
      },
      showNewLinkage: false,
      newLinkageIds: [],
@@ -426,281 +365,276 @@
      stackId: "",
      swiperIndex: 0,
      stackFilesPage: 1,
      stackFilesSize: 5,
    };
      stackFilesSize: 5
    }
  },
  created() {
    document.querySelector("html").style["min-width"] = "1920px";
    document.querySelector("html").style["min-width"] = "1920px"
    // 初始化连线变量
    this.plumbIns = jsPlumb.getInstance();
    this.plumbIns = jsPlumb.getInstance()
  },
  mounted() {
    // this.PollData.statistics();
    this.TaskMange.findAllSdk();
    this.TaskMange.findAllSdk()
  },
  destroyed() {
    document.querySelector("html").style["min-width"] = "1280px";
    document.querySelector("html").style["min-width"] = "1280px"
  },
  watch: {
    "Camera.cameraId": {
      handler(n, o) {
        if (n) {
          if (this.TreeDataPool.treeActiveName == "dataStack") {
            this.stackFilesPage = 1;
            this.stackFilesSize = 5;
            this.stackId = n;
            this.stackFilesPage = 1
            this.stackFilesSize = 5
            this.stackId = n
            if (this.stackId) {
              this.swipercanvasData = [];
              this.getStackFiles();
              this.swipercanvasData = []
              this.getStackFiles()
            }
          }
        }
      },
      }
    },
    Carmeras: {
      handler(newVal, oldVal) {
        this.setSwiperData();
        this.setSwiperData()
      },
      deep: true,
    },
      deep: true
    }
  },
  methods: {
    prevClick() {
      if (this.swiperIndex == 0) {
        if (this.stackFilesPage > 1) {
          this.stackFilesPage--;
          this.getStackFiles(true);
          this.stackFilesPage--
          this.getStackFiles(true)
        } else {
          this.$message({
            type: "info",
            message: "当前已是第一页",
          });
            message: "当前已是第一页"
          })
        }
      }
    },
    nextClick() {
      if (this.swiperIndex == this.swipercanvasData.length - 1) {
        this.stackFilesPage++;
        this.getStackFiles(true);
        this.stackFilesPage++
        this.getStackFiles(true)
      }
    },
    getStackFiles(onClick = false) {
      this.getStackFileLoading = true;
      let _this = this;
      this.getStackFileLoading = true
      let _this = this
      findAllFileByStackId({
        name: "",
        stackId: this.stackId,
        page: this.stackFilesPage,
        size: this.stackFilesSize,
        type: 0,
        type: 0
      })
        .then((res) => {
          if (res && res.success) {
            if (res.data.dataList.length > 0) {
              this.swipercanvasData = [];
              this.swipercanvasData = []
              this.swipercanvasData = res.data.dataList.map((item) => {
                return {
                  name: item.name,
                  stackId: item.stack_id,
                  baseImg:
                    item.type == 2
                      ? `/files/${item.path.substr(
                          item.path.lastIndexOf("/") + 1
                        )}`
                      : item.snapshot_url,
                    item.type == 2 ? `/files/${item.path.substr(item.path.lastIndexOf("/") + 1)}` : item.snapshot_url,
                  type: item.type,
                  id: item.id,
                  loading: false,
                };
              });
              this.swiperIndex = 0;
              this.$refs.swiper.swiper.activeIndex = 0;
                  loading: false
                }
              })
              this.swiperIndex = 0
              this.$refs.swiper.swiper.activeIndex = 0
            } else {
              if (onClick) {
                this.$message({
                  type: "warning",
                  message: "已无更多数据!",
                });
                  message: "已无更多数据!"
                })
              }
            }
          } else {
            this.$message({
              type: "error",
              message: "数据请求失败,请稍后重试!",
            });
              message: "数据请求失败,请稍后重试!"
            })
          }
          this.getStackFileLoading = false;
          this.getStackFileLoading = false
        })
        .catch((e) => {
          this.getStackFileLoading = false;
        });
          this.getStackFileLoading = false
        })
    },
    drawBaseImg() {
      if (Array.isArray(this.$refs.canvas)) {
        if (this.$refs.canvas.length > 0) {
          this.$refs.canvas[0].showModal();
          this.$refs.canvas[0].showModal()
        }
      } else {
        this.$refs.canvas.showModal();
        this.$refs.canvas.showModal()
      }
    },
    getCanvasData(data) {
      let polyon = { ...data };
      polyon.camera_id = this.Camera.cameraId;
      let polyon = { ...data }
      polyon.camera_id = this.Camera.cameraId
      savePolygon(polyon).then((rsp) => {
        this.Camera.getPolygon();
        this.Camera.getPolygon()
        //this.Camera.getCameraTask();
      });
      })
    },
    setSwiperData() {
      let swipers = [];
      let carmeras = this.Carmeras;
      let swipers = []
      let carmeras = this.Carmeras
      for (let i = 0; i < carmeras.length; i++) {
        swipers = swipers.concat({
          camera: {
            cameraId: carmeras[i].cameraId,
            cameraName: carmeras[i].cameraName,
            type: carmeras[i].type,
            rtsp: carmeras[i].rtsp,
            rtsp: carmeras[i].rtsp
          },
          baseImg: carmeras[i].baseImg ? carmeras[i].baseImg : undefined,
          canvasData: carmeras[i].canvasData,
          loading: carmeras[i].loading,
        });
          loading: carmeras[i].loading
        })
      }
      this.swipercanvasData = swipers;
      this.swipercanvasData = swipers
    },
    refresh(url) {
      console.log(url);
      this.Camera.baseImg = url;
      this.Camera.baseImg = url
    },
    refresh2(url, id) {
      this.swipercanvasData.forEach((data) => {
        if (data.cameraId == id) {
          data.baseImg = url;
          data.baseImg = url
        }
      });
      })
    },
    // 初始化摄像机信息,父组件调用
    async initCameraData(id) {
      if (!id) {
        return;
        return
      }
      this.plumbIns.deleteEveryConnection();
      this.plumbIns.deleteEveryConnection()
      this.connectArr.forEach((item) => {
        item.deleteEveryConnection();
      });
        item.deleteEveryConnection()
      })
      //获取独立场景
      let newCamera = new VideoRuleData();
      let newCamera = new VideoRuleData()
      if (id && id !== "") {
        this.loading = false;
        newCamera.cameraId = id;
        await newCamera.update();
        this.loading = false
        newCamera.cameraId = id
        await newCamera.update()
      }
      this.Camera = newCamera;
      this.SeparateRules = this.Camera.rules;
      this.Camera = newCamera
      this.SeparateRules = this.Camera.rules
      this.$nextTick(() => {
        this.connectLine();
      });
        this.connectLine()
      })
      this.showSysInfo = true;
      this.showSysInfo = true
      // 判断正在执行实时或者轮询任务
      this.PollData.CameraList.forEach((element) => {
        if (element.id === newCamera.cameraId) {
          this.runType = element.run_type;
          this.runType = element.run_type
        }
      });
      })
    },
    // 获取混合场景
    showRules(id) {
      if (!id) {
        return;
        return
      }
      if (typeof id === "string") {
        id = [id];
        id = [id]
      }
      let rules = [];
      let rules = []
      getLinkSceneRule({ cameraIds: id })
        .then((rsp) => {
          if (rsp && rsp.success) {
            rules = rsp.data.rules;
            rules = rsp.data.rules
            this.linkageRule = rules;
            this.linkageRule = rules
            this.$nextTick(() => {
              this.connectLine2();
            });
              this.connectLine2()
            })
          }
        })
        .catch(() => {});
        .catch(() => {})
    },
    saveSceneRule(groupRule) {
      const payload = { ...groupRule };
      payload.cameraIds = [this.Camera.cameraId];
      let _this = this;
      const payload = { ...groupRule }
      payload.cameraIds = [this.Camera.cameraId]
      let _this = this
      saveCameraScene(payload).then((rsp) => {
        if (rsp && rsp.success) {
          this.Camera.update();
          this.Camera.update()
          this.$notify({
            type: "success",
            message: "策略保存成功!",
          });
            message: "策略保存成功!"
          })
          //刷新左侧树
          _this.$root.$children[0].$children[0].querySearchAsync("camera");
          _this.$root.$children[0].$children[0].querySearchAsync("camera")
        }
      });
      })
    },
    delScenRule() {
      this.Camera.update();
      this.Camera.update()
    },
    changeLoading(params) {
      this.loading = params;
      this.loading = params
    },
    //是否进行视频分析处理
    pollEnable(row) {
      let val = 0;
      let val = 0
      if (row) {
        if (this.PollData.RealTimeSum < this.PollData.channelTotal) {
          this.Camera.dealWay = true;
          val = 1;
          this.Camera.dealWay = true
          val = 1
        } else {
          this.Camera.dealWay = false;
          val = 0;
          this.Camera.dealWay = false
          val = 0
        }
      } else {
        this.Camera.dealWay = false;
        val = -1;
        this.Camera.dealWay = false
        val = -1
      }
      if (this.Camera.cameraId && this.Camera.cameraId !== undefined) {
        changeRunType({
          camera_ids: [this.Camera.cameraId],
          run_type: val,
          run_type: val
        }).then((rsp) => {
          if (rsp && rsp.success) {
            this.$notify({
              type: "success",
              message: "配置成功",
            });
              message: "配置成功"
            })
          } else {
            this.$notify({
              type: "error",
              message: "配置失败",
            });
              message: "配置失败"
            })
          }
          this.TreeDataPool.fetchTreeData();
        });
          this.TreeDataPool.fetchTreeData()
        })
      }
      this.PollData.statisticTaskInfo();
      this.PollData.statisticTaskInfo()
    },
    //实时、轮询切换
    changePoll(row) {
@@ -708,98 +642,98 @@
      if (this.Camera.cameraId && this.Camera.cameraId !== undefined) {
        if (this.PollData.RealTimeSum < this.PollData.channelTotal) {
          if (row.value) {
            this.Camera.dealWay = true;
            this.Camera.dealWay = true
          } else {
            this.Camera.dealWay = false;
            this.Camera.dealWay = false
          }
          changeRunType({
            camera_ids: [this.Camera.cameraId],
            run_type: this.Camera.dealWay ? 1 : 0,
            run_type: this.Camera.dealWay ? 1 : 0
          }).then((rsp) => {
            if (rsp && rsp.success) {
              this.$notify({
                type: "success",
                message: "配置成功",
              });
                message: "配置成功"
              })
            } else {
              this.$notify({
                type: "error",
                message: "配置失败",
              });
                message: "配置失败"
              })
            }
          });
          })
        } else {
          if (this.Camera.dealWay) {
            this.Camera.dealWay = false;
            this.Camera.dealWay = false
            changeRunType({
              camera_ids: [this.Camera.cameraId],
              run_type: this.Camera.dealWay ? 1 : 0,
              run_type: this.Camera.dealWay ? 1 : 0
            }).then((rsp) => {
              if (rsp && rsp.success) {
                this.$notify({
                  type: "success",
                  message: "配置成功",
                });
                  message: "配置成功"
                })
              } else {
                this.$notify({
                  type: "error",
                  message: "配置失败",
                });
                  message: "配置失败"
                })
              }
            });
            })
          }
        }
        this.TreeDataPool.fetchTreeData();
        this.PollData.statisticTaskInfo();
        this.TreeDataPool.fetchTreeData()
        this.PollData.statisticTaskInfo()
      }
    },
    //复制
    ctrlC() {
      this.TreeDataPool.ctrlCameraId = this.Camera.cameraId;
      this.TreeDataPool.ctrlCameraName = this.Camera.cameraName;
      this.TreeDataPool.ctrlCameraId = this.Camera.cameraId
      this.TreeDataPool.ctrlCameraName = this.Camera.cameraName
      this.$notify({
        type: "success",
        message: "复制算法成功!",
      });
        message: "复制算法成功!"
      })
    },
    ctrlV() {
      if (this.Camera.cameraId === this.TreeDataPool.ctrlCameraId) {
        this.$notify({
          type: "warning",
          message: "不能粘贴本摄像机的算法到本摄像机!",
        });
        return false;
          message: "不能粘贴本摄像机的算法到本摄像机!"
        })
        return false
      }
      pasteRules({
        sourceId: this.TreeDataPool.ctrlCameraId,
        targetIds: [this.Camera.cameraId],
        targetIds: [this.Camera.cameraId]
      })
        .then((res) => {
          if (res && res.success) {
            this.$notify({
              type: "success",
              message: "粘贴算法成功!",
            });
            this.initCameraData(this.Camera.cameraId);
              message: "粘贴算法成功!"
            })
            this.initCameraData(this.Camera.cameraId)
          } else {
            this.$notify({
              type: "error",
              message: "粘贴算法失败!",
            });
              message: "粘贴算法失败!"
            })
          }
        })
        .catch((err) => {
          this.$notify({
            type: "error",
            message: "粘贴算法失败!",
          });
        });
            message: "粘贴算法失败!"
          })
        })
    },
    //连接独立场景连线
    connectLine() {
      //清除之前的连线
      this.plumbIns.deleteEveryConnection();
      this.plumbIns.deleteEveryConnection()
      for (let index = 0; index < this.SeparateRules.length; index++) {
        this.plumbIns.connect({
@@ -814,19 +748,19 @@
          paintStyle: { stroke: "#0065FF", strokeWidth: 2 }, // connector
          endpointStyle: {
            fill: "#fff",
            outlineStroke: "#0065FF",
          }, // endpoint
        });
            outlineStroke: "#0065FF"
          } // endpoint
        })
      }
    },
    connectLine2() {
      this.connectArr.forEach((item) => {
        item.deleteEveryConnection();
      });
        item.deleteEveryConnection()
      })
      for (let index = 0; index < this.linkageRule.length; index++) {
        const plumbIns = jsPlumb.getInstance();
        const plumbIns = jsPlumb.getInstance()
        plumbIns.connect({
          // 对应上述基本概念
@@ -840,149 +774,134 @@
          paintStyle: { stroke: "#0065FF", strokeWidth: 2 }, // connector
          endpointStyle: {
            fill: "#fff",
            outlineStroke: "#0065FF",
          }, // endpoint
        });
            outlineStroke: "#0065FF"
          } // endpoint
        })
        this.connectArr.push(plumbIns);
        this.connectArr.push(plumbIns)
      }
    },
    //添加独立场景
    addSeparateRule() {
      this.ruleType = "separate";
      this.showAddBox = true;
      this.ruleType = "separate"
      this.showAddBox = true
    },
    addLinkageRule(ids, camera_polygons) {
      console.log(7979);
      console.log(camera_polygons);
      if (ids.length < 2) {
        this.$message({
          message: "请至少选择两台摄像机",
          type: "warning",
        });
        return;
          type: "warning"
        })
        return
      }
      this.newLinkageIds = ids;
      this.ruleType = "linkage";
      this.showAddBox = true;
      this.newLinkPlg = camera_polygons;
      this.newLinkageIds = ids
      this.ruleType = "linkage"
      this.showAddBox = true
      this.newLinkPlg = camera_polygons
    },
    //回填新的独立场景
    getNewRule(newRule) {
      //新增场景
      if (newRule.action === "add") {
        newRule.data.rules = [];
        newRule.data.cameraIds = [this.Camera.cameraId];
        newRule.data.enable = true;
        newRule.data.rules = []
        newRule.data.cameraIds = [this.Camera.cameraId]
        newRule.data.enable = true
        //独立场景
        if (this.ruleType == "separate") {
          this.SeparateRules.push(newRule.data);
          this.SeparateRules.push(newRule.data)
          this.$nextTick(() => {
            this.connectLine();
          });
            this.connectLine()
          })
        } else {
          //联动场景
          if (this.newLinkPlg) {
            newRule.data.camera_polygons = this.newLinkPlg;
            newRule.data.camera_polygons = this.newLinkPlg
          }
          newRule.data.cameraIds = this.newLinkageIds;
          this.linkageRule.push(newRule.data);
          newRule.data.cameraIds = this.newLinkageIds
          this.linkageRule.push(newRule.data)
          this.$nextTick(() => {
            this.connectLine2();
          });
            this.connectLine2()
          })
        }
        this.showAddBox = false;
        this.showAddBox = false
        //编辑场景
      } else if (newRule.action === "edit") {
        //独立场景
        if (this.ruleType == "separate") {
          this.SeparateRules[newRule.data.index].alarm_level =
            newRule.data.alarm_level;
          this.SeparateRules[newRule.data.index].scene_name =
            newRule.data.scene_name;
          this.SeparateRules[newRule.data.index].desc = newRule.data.desc;
          this.SeparateRules[newRule.data.index].template_id =
            newRule.data.template_id;
          this.SeparateRules[newRule.data.index].time_rule_id =
            newRule.data.time_rule_id;
          this.SeparateRules[newRule.data.index].voiceId = newRule.data.voiceId;
          this.SeparateRules[newRule.data.index].alarm_level = newRule.data.alarm_level
          this.SeparateRules[newRule.data.index].scene_name = newRule.data.scene_name
          this.SeparateRules[newRule.data.index].desc = newRule.data.desc
          this.SeparateRules[newRule.data.index].template_id = newRule.data.template_id
          this.SeparateRules[newRule.data.index].time_rule_id = newRule.data.time_rule_id
          this.SeparateRules[newRule.data.index].voiceId = newRule.data.voiceId
        } else {
          //联动场景
          console.log(this.linkageRule[newRule.data.index]);
          this.linkageRule[newRule.data.index].alarm_level =
            newRule.data.alarm_level;
          this.linkageRule[newRule.data.index].scene_name =
            newRule.data.scene_name;
          this.linkageRule[newRule.data.index].desc = newRule.data.desc;
          this.linkageRule[newRule.data.index].template_id =
            newRule.data.template_id;
          this.linkageRule[newRule.data.index].time_rule_id =
            newRule.data.time_rule_id;
          this.linkageRule[newRule.data.index].voiceId = newRule.data.voiceId;
          this.linkageRule[newRule.data.index].alarm_level = newRule.data.alarm_level
          this.linkageRule[newRule.data.index].scene_name = newRule.data.scene_name
          this.linkageRule[newRule.data.index].desc = newRule.data.desc
          this.linkageRule[newRule.data.index].template_id = newRule.data.template_id
          this.linkageRule[newRule.data.index].time_rule_id = newRule.data.time_rule_id
          this.linkageRule[newRule.data.index].voiceId = newRule.data.voiceId
        }
        this.showAddBox = false;
        this.$forceUpdate();
        this.showAddBox = false
        this.$forceUpdate()
      }
      this.editData = {};
      this.editData = {}
    },
    //修改独立场景
    editRules(item, index, type) {
      this.ruleType == type;
      this.ruleType = type
      this.editData = {
        type,
        rule: item,
        index,
      };
      this.showAddBox = true;
        index
      }
      this.showAddBox = true
    },
    //添加算法
    addSdk(type, index) {
      this.editSdkObj = {};
      this.ruleType = type;
      this.editSdkObj = {}
      this.ruleType = type
      this.addData = {
        type,
        index,
      };
        index
      }
      if (this.addData.type === "linkage") {
        this.addData.cameras = [];
        if (
          this.linkageRule[index].camera_polygons &&
          this.linkageRule[index].camera_polygons.length > 0
        ) {
        this.addData.cameras = []
        if (this.linkageRule[index].camera_polygons && this.linkageRule[index].camera_polygons.length > 0) {
          this.linkageRule[index].camera_polygons.forEach((camera) => {
            this.addData.cameras.push({
              polygonData: camera.polygon,
              cameraName: camera.camera_name,
              cameraId: camera.camera_id,
            });
          });
              cameraId: camera.camera_id
            })
          })
        } else {
          this.linkageRule[index].camera_polygons = [];
          this.linkageRule[index].camera_polygons = []
          this.Carmeras.forEach((camera) => {
            this.addData.cameras.push({
              polygonData: camera.polygonData,
              cameraName: camera.cameraName,
              cameraId: camera.cameraId,
            });
              cameraId: camera.cameraId
            })
            this.linkageRule[index].camera_polygons.push({
              polygon: camera.polygonData,
              camera_name: camera.cameraName,
              camera_id: camera.cameraId,
            });
          });
              camera_id: camera.cameraId
            })
          })
        }
      }
      this.showSdkBox = false;
      this.showSdkSettingBox = true;
      this.showSdkBox = false
      this.showSdkSettingBox = true
    },
    //添加算法回调
@@ -990,139 +909,134 @@
      //独立场景
      if (this.addData.type === "separate") {
        if (this.SeparateRules[this.addData.index].rules.length > 0) {
          newRule.rule_with_pre = "&&";
          newRule.is_save_anyhow = true;
          newRule.rule_with_pre = "&&"
          newRule.is_save_anyhow = true
        }
        this.SeparateRules[this.addData.index].rules.push(newRule);
        this.SeparateRules[this.addData.index].rules.push(newRule)
      }
      //联动场景
      else {
        if (this.linkageRule[this.addData.index].rules.length > 0) {
          newRule.rule_with_pre = "&&";
          newRule.is_save_anyhow = true;
          newRule.rule_with_pre = "&&"
          newRule.is_save_anyhow = true
        }
        this.linkageRule[this.addData.index].rules.push(newRule);
        this.linkageRule[this.addData.index].rules.push(newRule)
      }
      this.addData = {};
      this.showSdkSettingBox = false;
      this.TaskMange.findAllSdk({ installed: true });
      this.addData = {}
      this.showSdkSettingBox = false
      this.TaskMange.findAllSdk({ installed: true })
      this.show = false;
      this.show = false
      this.$nextTick(() => {
        this.show = true;
      });
        this.show = true
      })
    },
    //取消修改
    async backToOrigin(type, index, ids) {
      if (type === "separate") {
        const rsp = await getCameraSceneRule({
          cameraId: this.Camera.cameraId,
        });
          cameraId: this.Camera.cameraId
        })
        if (rsp && rsp.success) {
          let rules = rsp.data.rules ? rsp.data.rules : [];
          let rules = rsp.data.rules ? rsp.data.rules : []
          rules.forEach((item) => {
            item.cameraIds = rsp.data.cameraInfo.id;
          });
            item.cameraIds = rsp.data.cameraInfo.id
          })
          if (rules[index]) {
            this.SeparateRules[index] = rules[index];
            this.SeparateRules[index] = rules[index]
          } else {
            this.SeparateRules.splice(index, 1);
            this.SeparateRules.splice(index, 1)
          }
        }
        this.$forceUpdate();
        this.connectLine();
        this.$forceUpdate()
        this.connectLine()
      } else {
        getLinkSceneRule({ cameraIds: ids }).then((rsp) => {
          if (rsp && rsp.success) {
            let rules = rsp.data.rules ? rsp.data.rules : [];
            let rules = rsp.data.rules ? rsp.data.rules : []
            if (rules[index]) {
              this.linkageRule[index] = rules[index];
              this.linkageRule[index] = rules[index]
            } else {
              this.linkageRule.splice(index, 1);
              this.linkageRule.splice(index, 1)
            }
            this.$forceUpdate();
            this.connectLine2();
            this.$forceUpdate()
            this.connectLine2()
          }
          console.log("失败");
        });
          console.log("失败")
        })
      }
    },
    // 编辑算法
    editSdk(sdkIndex, type, ruleIndex) {
      this.addData = {};
      this.ruleType = type;
      this.addData = {}
      this.ruleType = type
      if (type === "separate") {
        this.editSdkObj = {
          ruleIndex,
          sdkIndex,
          type,
          sdk: this.SeparateRules[ruleIndex].rules[sdkIndex],
        };
          sdk: this.SeparateRules[ruleIndex].rules[sdkIndex]
        }
      } else {
        this.editSdkObj = {
          ruleIndex,
          sdkIndex,
          type,
          camera_polygons: this.linkageRule[ruleIndex].camera_polygons,
          sdk: this.linkageRule[ruleIndex].rules[sdkIndex],
        };
          sdk: this.linkageRule[ruleIndex].rules[sdkIndex]
        }
      }
      this.showSdkBox = false;
      this.showSdkSettingBox = true;
      this.showSdkBox = false
      this.showSdkSettingBox = true
    },
    deletRule(type, index) {
      if (type === "separate") {
        this.SeparateRules.splice(index, 1);
        this.SeparateRules.splice(index, 1)
      } else {
        this.linkageRule.splice(index, 1);
        this.linkageRule.splice(index, 1)
      }
    },
    getEditSdk(newRule) {
      console.log(newRule);
      if (this.editSdkObj.type === "separate") {
        this.SeparateRules[this.editSdkObj.ruleIndex].rules[
          this.editSdkObj.sdkIndex
        ] = newRule;
        this.SeparateRules[this.editSdkObj.ruleIndex].rules[this.editSdkObj.sdkIndex] = newRule
      } else {
        this.linkageRule[this.editSdkObj.ruleIndex].rules[
          this.editSdkObj.sdkIndex
        ] = newRule;
        this.linkageRule[this.editSdkObj.ruleIndex].rules[this.editSdkObj.sdkIndex] = newRule
      }
      this.editSdkObj = {};
      this.showSdkSettingBox = false;
      this.editSdkObj = {}
      this.showSdkSettingBox = false
    },
    closeAddBox() {
      this.showAddBox = false;
      this.editData = {};
      this.showAddBox = false
      this.editData = {}
    },
    closeSettingBox() {
      this.showSdkSettingBox = false;
      this.editSdkObj = {};
      this.showSdkSettingBox = false
      this.editSdkObj = {}
    },
    openSdkBox(e) {
      e.stopPropagation();
      this.showSdkBox = true;
      e.stopPropagation()
      this.showSdkBox = true
    },
    selectMultiple(val) {
      if (!val) {
        this.Carmeras = [];
        this.Carmeras = []
      }
      this.TreeDataPool.multiple = val;
    },
  },
};
      this.TreeDataPool.multiple = val
    }
  }
}
</script>
<style lang="scss" scoped>