import { getCameraInfo } from "@/api/camera";
|
import { getAllPolygon } from "@/api/polygon";
|
import { getDirDetails, findAllFileByStackId } from "@/api/localVedio";
|
import { getCameraSceneRule } from '@/api/scene'
|
|
export default class VideoRuleData {
|
public selectTask: Array<object>;
|
public rules: Array<object>;
|
public polygonData: Array<object>;
|
public cameraId: string = "";
|
public canvasData: object;
|
public baseImg: string;
|
public cameraName: string;
|
public camearInfo: object;
|
|
public loading: boolean;
|
|
public analytics: boolean;
|
public dealWay: boolean;
|
public runServerName: string;
|
|
public resolutionOption: Array<any>;
|
public selectResolution: string;
|
public hasCtrlC: boolean;
|
|
constructor(id: string) {
|
this.loading = false;
|
this.baseImg = "";
|
this.cameraId = id ? id : "";
|
this.cameraName = "";
|
this.selectTask = [];
|
this.polygonData = [];
|
this.canvasData = {
|
line: [],
|
arrow: [],
|
polygon: [],
|
rect: []
|
};
|
|
this.camearInfo = {};
|
this.analytics = false;
|
this.dealWay = false;
|
this.runServerName = "";
|
this.rules = [];
|
|
if (id && id !== "") {
|
this.update();
|
}
|
|
this.resolutionOption = [
|
{
|
value: '1001',
|
label: '1280*720'
|
},
|
{
|
value: '1002',
|
label: '1920*1080'
|
},
|
{
|
value: '1003',
|
label: '2560*1440'
|
}
|
]
|
this.selectResolution = '1002'
|
this.hasCtrlC = false
|
}
|
|
public async update() {
|
await this.getInfo();
|
await this.getSceneRule();
|
|
await this.getPolygon();
|
}
|
|
public async getInfo() {
|
// 判断选中的是摄像机还是数据栈
|
if (this.cameraId.indexOf("stack") === -1) {
|
try {
|
const rsp: any = await getCameraInfo(this.cameraId);
|
if (rsp.success) {
|
this.cameraName = rsp.data.name ? rsp.data.name : "";
|
}
|
} catch {
|
this.cameraName = "";
|
}
|
} else {
|
const rsp: any = await findAllFileByStackId({ stackId: this.cameraId });
|
if (rsp.success && rsp.data.dataList.length) {
|
let snapshots = rsp.data.dataList.map(obj => {
|
return obj.snapshot_url;
|
})
|
|
this.baseImg = snapshots[0];
|
// console.log(snapshots)
|
}
|
}
|
|
}
|
|
public async getPolygon() {
|
this.polygonData = [];
|
|
const rsp: any = await getAllPolygon({ cameraId: this.cameraId });
|
if (rsp && rsp.success) {
|
this.canvasData = {
|
line: rsp.data.line,
|
arrow: rsp.data.arrow,
|
polygon: rsp.data.polygon,
|
rect: rsp.data.rect
|
};
|
|
// 只对摄像机数据底图进行处理
|
if (this.cameraId.indexOf("stack") < 0) {
|
this.baseImg = rsp.data.snapshot_url ? rsp.data.snapshot_url : "";
|
if (!this.baseImg) {
|
this.loading = true;
|
} else {
|
this.loading = false;
|
}
|
}
|
|
const newObj = item => {
|
return {
|
id: item.id,
|
name: item.name,
|
defence_state: item.defence_state
|
};
|
};
|
|
let line = rsp.data.line.map(newObj);
|
let polygon = rsp.data.polygon.map(newObj);
|
let rect = rsp.data.rect.map(newObj);
|
|
if (line.length !== 0 || polygon.length !== 0 || rect.length !== 0) {
|
this.polygonData = [...polygon, ...line, ...rect];
|
}
|
}
|
}
|
|
public async getSceneRule() {
|
const rsp: any = await getCameraSceneRule({ cameraId: this.cameraId });
|
if (rsp && rsp.success) {
|
let rspData = rsp.data.taskList ? rsp.data.taskList : []
|
this.rules = rsp.data.rules ? rsp.data.rules : []
|
this.camearInfo = rsp.data.cameraInfo ? rsp.data.cameraInfo : {};
|
this.analytics = rsp.data.cameraInfo.run_type !== -1 ? true : false
|
this.dealWay = rsp.data.cameraInfo.run_type === 1 ? true : false
|
this.runServerName = rsp.data.cameraInfo.runServerName
|
}
|
|
|
}
|
}
|