import { initCaptureData, monitorRealTimeCaptureData } from "@/api/task";
|
|
export default class VideoCapture {
|
public cards: Array<object> = [];
|
public cameras: Array<string> = [];
|
constructor() {
|
this.cards = [];
|
this.cameras = [];
|
}
|
|
public async initCards() {
|
const rsp: any = await initCaptureData({
|
treeNodes: this.cameras
|
});
|
|
if (rsp && rsp.success && rsp.data.datalist) {
|
this.cards = [];
|
|
this.cards.splice(0, this.cards.length)
|
rsp.data.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)
|
}
|
}
|
|
}
|
}
|