import { initCaptureData,initCaptureDataTwo, monitorRealTimeCaptureData } from "@/api/task";
|
|
export default class VideoCapture {
|
public cards: Array<object> = [];
|
public cameras: Array<string> = [];
|
public firstCardId: string;
|
public cardChanged: boolean = false;
|
constructor() {
|
this.cards = [];
|
this.firstCardId = "";
|
this.cameras = [];
|
}
|
|
public async initCards() {
|
// const rsp: any = await initCaptureData({
|
// treeNodes: this.cameras
|
// });
|
const rsp: any = await initCaptureDataTwo({
|
treeNodes: this.cameras
|
});
|
|
if (rsp && rsp.success && rsp.data.list.datalist) {
|
this.cards = [];
|
|
this.cards.splice(0, this.cards.length)
|
rsp.data.list.datalist.forEach(element => {
|
this.cards.push(element)
|
// var obj = {
|
// activeObject: (element as any),
|
// list: []
|
// }
|
// obj.list.push((element as any))
|
// this.cards.push(obj)
|
|
// this.cards.push({
|
// list: [element]
|
// });
|
});
|
}
|
}
|
|
public async monitorCapture() {
|
const rsp: any = await monitorRealTimeCaptureData({
|
// treeNodes: this.cameras
|
});
|
|
if (rsp && rsp.success) {
|
if (rsp.data.datalist && rsp.data.datalist.length > 0) {
|
rsp.data.datalist.reverse().forEach(element => {
|
let rt = this.cards.filter((c: any) => {
|
return c.activeObject.id === element.activeObject.id
|
})
|
if (rt.length < 1) {
|
// this.cards.unshift({
|
// list: [element],
|
// activeObject: element
|
// });
|
this.cards.unshift(element)
|
}
|
});
|
this.cards.splice(20, this.cards.length - 20)
|
|
if (this.cards.length) {
|
if (this.firstCardId != "" && this.cards[0]["activeObject"].id != this.firstCardId) {
|
this.cardChanged = true
|
} else {
|
this.cardChanged = false
|
}
|
|
this.firstCardId = this.cards[0]["activeObject"].id
|
console.log(this.firstCardId )
|
}
|
}
|
}
|
|
}
|
}
|