hanbaoshan
2020-12-03 c99cad106ef5be9f818e45d385dfdcec29ce19e5
src/Pool/TreeData.ts
@@ -1,6 +1,7 @@
import {
  getLocalCameraTree,
  getGB28181CameraTree,
  getClusterTree,
  addAreaTreeData,
  delAreaTreeData,
  updateAreaTreeData,
@@ -16,9 +17,11 @@
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;
@@ -28,6 +31,7 @@
  public readonly: boolean;
  public gbReadonly: boolean;
  public multiple: boolean;
  public searchFrom: string = '';
  public showTreeBox: boolean;
  public selectedNodes: Array<string>;
  public selectedNode: any;
@@ -64,8 +68,10 @@
    this.openeds = [true, true, false];
    this.treeData = [];
    this.gb28181Data = [];
    this.clusterData = [];
    this.treeDataPure = [];
    this.gb28181DataPure = [];
    this.clusterDataPure = [];
    this.videoArr = [""];
    this.searchCamType = 0;
    this.searchInput = "";
@@ -96,7 +102,6 @@
  }
  setVideoArr(index: number, value: object, vue: any): void {
    debugger
    vue.$set(this.videoArr, index, value);
    this.activeForceChoose = false;
  }
@@ -107,8 +112,8 @@
      this.selectedNodes = [this.selectedNode.id];
      return;
    }
    let _selected = this.selectedNodes;
    console.log(this.selectedNodes)
    function nodeFilter(node: any) {
      if (node.type === "4" && node.selected) {
        _selected.push(node.id);
@@ -120,20 +125,33 @@
      }
    }
    if (this.selectedNode.cameraType === 0) {
      this.treeData.forEach((n: any) => {
        nodeFilter(n);
      });
      //摄像机树
      if(this.treeActiveName == "camera"){
        this.treeData.forEach((n: any) => {
          nodeFilter(n);
        });
      }else if(this.treeActiveName == "cluster"){
        //集群树
        this.clusterData.forEach((n: any) => {
          nodeFilter(n);
        });
      }
    }
    if (this.selectedNode.cameraType === 1) {
      this.gb28181Data.forEach((n: any) => {
        nodeFilter(n);
      });
    }
    // if (this.selectedNode.cameraType === -1) {
    //   this.clusterData.forEach((n: any) => {
    //     nodeFilter(n);
    //   });
    // }
  }
  getCameraInfoByIp(ipaddr) {
    let camera = null;
    function nodeFilter(node: any) {
      if (node.rtsp && node.rtsp.indexOf(ipaddr) != -1) {
        camera = node;
@@ -287,10 +305,15 @@
  }
  async fetchLocalTree() {
    const rsp: any = await getLocalCameraTree({
    let params: any = {
      searchType: this.searchCamType,
      cameraName: this.searchInput
    });
      cameraName: this.searchInput,
      //isPlatform: 1
    };
    if (this.searchFrom == 'cluster') {
      params.isPlatform = 1
    }
    const rsp: any = await getLocalCameraTree(params);
    if (rsp && rsp.success) {
      this.treeData = rsp.data ? rsp.data : []
@@ -302,6 +325,22 @@
      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)
    }
  }
@@ -329,6 +368,7 @@
    if (this.openeds[1]) {
      this.fetchGbTree()
    }
    this.findAllFile({})
  }