ZZJ
2022-07-18 65752fcffafa02c5f646d0a6207c85bf81284b73
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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)
      }
    }
 
  }
}