| | |
| | | import { getCameraTask, initTaskData, monitorRealTimeTaskData } from "@/api/task"; |
| | | 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 = []; |
| | | 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 = []; |
| | | this.tasks = [] |
| | | this.taskCard = [] |
| | | this.cameras = [] |
| | | this.activeIndex = 0 |
| | | this.separateRulesTasks = [] |
| | | } |
| | | |
| | | public async fetchTasks() { |
| | | console.log("fetchTasks") |
| | | // 根据选中摄像机,查找任务,去重 |
| | | const rsp: any = await getCameraTask({ |
| | | cameraIds: this.cameras |
| | | }); |
| | | cameraId: this.cameras[0] |
| | | }) |
| | | if (rsp && rsp.success) { |
| | | //let taskIds = [] |
| | | let taskNames = []; |
| | | this.tasks = []; |
| | | let taskNames = [] |
| | | this.tasks = [] |
| | | |
| | | // rsp.data.forEach((d: any) => { |
| | | // if (d.tasks) { |
| | |
| | | // }) |
| | | // } |
| | | // }) |
| | | rsp.data.forEach((d: any) => { |
| | | if (taskNames.indexOf(d.name) < 0) { |
| | | taskNames.push(d.name); |
| | | 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.name == d.name); |
| | | repeatOne.id += `,${d.id}`; |
| | | repeatOne.isDelete = repeatOne.isDelete && d.isDelete; |
| | | 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); |
| | | console.log(this.tasks) |
| | | |
| | | // 初始化第一任务的信息 |
| | | this.initTaskList() |
| | |
| | | // console.log(this.tasks, this.activeIndex, '初始化获取人数抓拍') |
| | | this.taskCard.splice(0, this.taskCard.length) |
| | | if (!this.tasks[this.activeIndex]) { |
| | | return; |
| | | return |
| | | } |
| | | |
| | | const rsp: any = await initTaskData({ |
| | | //tasks: [this.tasks[this.activeIndex].taskId], |
| | | tasks: this.tasks[this.activeIndex].id.split(','), |
| | | tasks: this.tasks[this.activeIndex].id.split(","), |
| | | treeNodes: this.cameras |
| | | }); |
| | | }) |
| | | |
| | | if (rsp && rsp.success && rsp.data.datalist) { |
| | | rsp.data.datalist.forEach(element => { |
| | | 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; |
| | | return |
| | | } |
| | | |
| | | const rsp: any = await monitorRealTimeTaskData({ |
| | | //tasks: [this.tasks[this.activeIndex].id], |
| | | tasks: this.tasks[this.activeIndex].id.split(','), |
| | | 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 => { |
| | | rsp.data.datalist.reverse().forEach((element) => { |
| | | let rt = this.taskCard.filter((c: any) => { |
| | | return c.activeObject.id === element.activeObject.id |
| | | }) |
| | |
| | | // }); |
| | | this.taskCard.unshift(element) |
| | | } |
| | | }); |
| | | }) |
| | | this.taskCard.splice(20, this.taskCard.length - 20) |
| | | } |
| | | } |