mark
2022-10-25 f20a554bdb24e9dfde9dc6a69d78595944f61d15
src/Pool/VideoRuleData.ts
@@ -1,7 +1,8 @@
import { getCameraInfo } from "@/api/camera";
import { getAllPolygon } from "@/api/polygon";
import { getDirDetails, findAllFileByStackId } from "@/api/localVedio";
import { getCameraSceneRule } from '@/api/scene'
import { getCameraSceneRule,getLinkSceneRule } from '@/api/scene'
export default class VideoRuleData {
  public selectTask: Array<object>;
@@ -11,6 +12,8 @@
  public canvasData: object;
  public baseImg: string;
  public cameraName: string;
  public type:number;
  public rtsp:string;
  public camearInfo: object;
  public loading: boolean;
@@ -22,14 +25,18 @@
  public resolutionOption: Array<any>;
  public selectResolution: string;
  public hasCtrlC: boolean;
  public allSceneRule:Array<any>;
  constructor(id: string) {
    this.loading = false;
    this.baseImg = "";
    this.cameraId = id ? id : "";
    this.cameraName = "";
    this.rtsp = "";
    this.type = 0;
    this.selectTask = [];
    this.polygonData = [];
    this.allSceneRule = []
    this.canvasData = {
      line: [],
      arrow: [],
@@ -63,12 +70,14 @@
    ]
    this.selectResolution = '1002'
    this.hasCtrlC = false
  }
  public async update() {
    await this.getInfo();
    await this.getSceneRule();
    await this.getPolygon();
    await this.getLinkRule()
  }
  public async getInfo() {
@@ -78,9 +87,14 @@
        const rsp: any = await getCameraInfo(this.cameraId);
        if (rsp.success) {
          this.cameraName = rsp.data.name ? rsp.data.name : "";
          this.rtsp = rsp.data.rtsp ? rsp.data.rtsp : "";
          this.type = rsp.data.type ? rsp.data.type : 0;
          this.baseImg =   rsp.data.snapshot_url
        }
      } catch {
        this.cameraName = "";
        this.type = 0
        this.rtsp = ''
      }
    } else {
      const rsp: any = await findAllFileByStackId({ stackId: this.cameraId });
@@ -110,7 +124,7 @@
      // 只对摄像机数据底图进行处理
      if (this.cameraId.indexOf("stack") < 0) {
        this.baseImg = rsp.data.snapshot_url ? rsp.data.snapshot_url : "";
        this.baseImg =  rsp.data.snapshot_url ? rsp.data.snapshot_url : "";
        if (!this.baseImg) {
          this.loading = true;
        } else {
@@ -147,4 +161,14 @@
      this.runServerName = rsp.data.cameraInfo.runServerName
    }
  }
  public async getLinkRule() {
    const rsp: any = await getLinkSceneRule({ cameraIds: [this.cameraId] });
    if (rsp && rsp.success) {
     let rules = rsp.data.rules;
      rules = rsp.data.rules;
      this.allSceneRule = this.rules.concat(rules)
    }
  }
}