import { getCameraTask, initTaskData, monitorRealTimeTaskData } from "@/api/task"
|
|
export default class VideoTaskData {
|
public tasks: Array<any> = []
|
public taskCard: Array<object> = []
|
public cameras: Array<string> = []
|
public activeIndex: number
|
public separateRulesTasks: object = []
|
|
constructor() {
|
this.tasks = []
|
this.taskCard = []
|
this.cameras = []
|
this.activeIndex = 0
|
this.separateRulesTasks = []
|
}
|
|
public async fetchTasks() {
|
console.log("fetchTasks")
|
// 根据选中摄像机,查找任务,去重
|
const rsp: any = await getCameraTask({
|
cameraId: this.cameras[0]
|
})
|
if (rsp && rsp.success) {
|
//let taskIds = []
|
let taskNames = []
|
this.tasks = []
|
|
// rsp.data.forEach((d: any) => {
|
// if (d.tasks) {
|
// d.tasks.forEach((t: any) => {
|
// if (taskIds.indexOf(t.taskid) < 0) {
|
// taskIds.push(t.taskid)
|
// if (t.taskname == "人脸测温") {
|
// this.tasks.unshift({
|
// taskName: t.taskname,
|
// taskId: t.taskid
|
// })
|
// } else {
|
// this.tasks.push({
|
// taskName: t.taskname,
|
// taskId: t.taskid
|
// })
|
// }
|
// }
|
// })
|
// }
|
// })
|
rsp.data.rules.forEach((d: any) => {
|
if (taskNames.indexOf(d.scene_name) < 0) {
|
taskNames.push(d.scene_name)
|
this.tasks.push(d)
|
} else {
|
let repeatOne = this.tasks.find((one: any) => one.scene_name == d.scene_name)
|
repeatOne.id += `,${d.id}`
|
repeatOne.isDelete = repeatOne.isDelete && d.isDelete
|
}
|
})
|
|
this.tasks = this.tasks.filter((d: any) => !d.isDelete)
|
console.log(this.tasks)
|
|
// 初始化第一任务的信息
|
this.initTaskList()
|
}
|
}
|
|
public async initTaskList() {
|
// console.log(this.tasks, this.activeIndex, '初始化获取人数抓拍')
|
this.taskCard.splice(0, this.taskCard.length)
|
if (!this.tasks[this.activeIndex]) {
|
return
|
}
|
|
const rsp: any = await initTaskData({
|
//tasks: [this.tasks[this.activeIndex].taskId],
|
tasks: this.tasks[this.activeIndex].id.split(","),
|
treeNodes: this.cameras
|
})
|
|
if (rsp && rsp.success && rsp.data.datalist) {
|
rsp.data.datalist.forEach((element) => {
|
// this.taskCard.push({
|
// list: [element],
|
// activeObject: element
|
// });
|
this.taskCard.push(element)
|
})
|
}
|
}
|
|
public async monitorTaskData() {
|
if (!this.tasks[this.activeIndex]) {
|
return
|
}
|
|
const rsp: any = await monitorRealTimeTaskData({
|
//tasks: [this.tasks[this.activeIndex].id],
|
tasks: this.tasks[this.activeIndex].id.split(","),
|
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.taskCard.filter((c: any) => {
|
return c.activeObject.id === element.activeObject.id
|
})
|
if (rt.length < 1) {
|
// this.taskCard.unshift({
|
// list: [element],
|
// activeObject: element
|
// });
|
this.taskCard.unshift(element)
|
}
|
})
|
this.taskCard.splice(20, this.taskCard.length - 20)
|
}
|
}
|
}
|
}
|