| | |
| | | import { |
| | | getLocalCameraTree, |
| | | getGB28181CameraTree, |
| | | getClusterTree, |
| | | addAreaTreeData, |
| | | delAreaTreeData, |
| | | updateAreaTreeData, |
| | |
| | | export default class TreeDataPool { |
| | | public openeds: Array<boolean>; |
| | | public treeData: Array<object>; |
| | | public clusterData: Array<object>; |
| | | public gb28181Data: Array<object>; |
| | | public treeDataPure: Array<object>; |
| | | public gb28181DataPure: Array<object>; |
| | | public clusterDataPure: Array<object>; |
| | | public videoArr: Array<string | undefined | object>; |
| | | public searchCamType: number; |
| | | public searchInput: string; |
| | |
| | | this.openeds = [true, true, false]; |
| | | this.treeData = []; |
| | | this.gb28181Data = []; |
| | | this.clusterData = []; |
| | | this.treeDataPure = []; |
| | | this.gb28181DataPure = []; |
| | | this.clusterDataPure = []; |
| | | this.videoArr = [""]; |
| | | this.searchCamType = 0; |
| | | this.searchInput = ""; |
| | |
| | | this.selectedNodes = [this.selectedNode.id]; |
| | | return; |
| | | } |
| | | |
| | | let _selected = this.selectedNodes; |
| | | function nodeFilter(node: any) { |
| | | if (node.type === "4" && node.selected) { |
| | |
| | | } |
| | | if (this.selectedNode.cameraType === 1) { |
| | | this.gb28181Data.forEach((n: any) => { |
| | | nodeFilter(n); |
| | | }); |
| | | } |
| | | if (this.selectedNode.cameraType === -1) { |
| | | this.clusterData.forEach((n: any) => { |
| | | nodeFilter(n); |
| | | }); |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | sortTreeData(node) { |
| | | if (!node) { |
| | | return |
| | | } |
| | | node.sort(function (obj1: any, obj2: any) { |
| | | var val1 = obj1.name; |
| | | var val2 = obj2.name; |
| | | if (val1 < val2) { |
| | | return -1; |
| | | } else if (val1 > val2) { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }); |
| | | |
| | | node.forEach(n => { |
| | | if (n.children && n.children.length > 0) { |
| | | this.sortTreeData(n.children) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | async fetchLocalTree() { |
| | | const rsp: any = await getLocalCameraTree({ |
| | | searchType: this.searchCamType, |
| | |
| | | if (rsp && rsp.success) { |
| | | this.treeData = rsp.data ? rsp.data : [] |
| | | if (this.treeData && this.treeData.length > 0) { |
| | | this.treeData.sort(function (obj1: any, obj2: any) { |
| | | var val1 = obj1.id; |
| | | var val2 = obj2.id; |
| | | if (val1 < val2) { |
| | | return -1; |
| | | } else if (val1 > val2) { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }); |
| | | this.sortTreeData(this.treeData) |
| | | } |
| | | |
| | | // 设置禁止拖拽摄像机到摄像机节点 |
| | | this.setDropDisable(this.treeData) |
| | | this.treeDataPure = JSON.parse(JSON.stringify(this.treeData)); |
| | | this.isFold(this.treeData) |
| | | } |
| | | } |
| | | |
| | | async fetchClusterTree (){ |
| | | const rsp: any = await getClusterTree({ |
| | | searchType: this.searchCamType, |
| | | cameraName: this.searchInput |
| | | }); |
| | | if(rsp && rsp.success){ |
| | | console.log(rsp.data); |
| | | this.clusterData = rsp.data ? rsp.data : [] |
| | | if(this.clusterData && this.clusterData.length > 0){ |
| | | this.sortTreeData(this.clusterData) |
| | | } |
| | | this.clusterDataPure = JSON.parse(JSON.stringify(this.clusterData)); |
| | | this.isFold(this.clusterData) |
| | | } |
| | | } |
| | | |
| | |
| | | if (rsp && rsp.success) { |
| | | this.gb28181Data = rsp.data ? rsp.data : [] |
| | | if (this.gb28181Data && this.gb28181Data.length > 0) { |
| | | this.gb28181Data.sort(function (obj1: any, obj2: any) { |
| | | var val1 = obj1.id; |
| | | var val2 = obj2.id; |
| | | if (val1 < val2) { |
| | | return -1; |
| | | } else if (val1 > val2) { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }); |
| | | this.sortTreeData(this.gb28181Data) |
| | | } |
| | | |
| | | this.gb28181DataPure = JSON.parse(JSON.stringify(this.gb28181Data)); |
| | |
| | | if (this.openeds[1]) { |
| | | this.fetchGbTree() |
| | | } |
| | | |
| | | this.findAllFile({}) |
| | | } |
| | | |