zhangzengfei
2022-12-07 0dbf19e9f92f5cb1d5ca9a06fd268d3b16e466e3
src/Pool/TreeData.ts
@@ -72,6 +72,8 @@
  // 记录摄像机所属的父节点名称
  public cameraParents: object
  // 记录所有的子节点
  public childNodes: Array<object>
  constructor() {
    this.openeds = [true, true, false]
@@ -115,6 +117,7 @@
    this.clusterId = ""
    this.devId = ""
    this.cameraParents = {}
    this.childNodes = []
  }
  setVideoArr(index: number, value: object, vue: any): void {
@@ -166,27 +169,17 @@
  }
  updateZTreeCheckNodes(checkedNodes) {
    let _this = this
    _this.selectedNodes = []
    if (!_this.multiple) {
      _this.selectedNodes = [checkedNodes.id]
    this.selectedNodes = []
    if (!this.multiple) {
      this.selectedNodes = [checkedNodes.id]
      return
    }
    function nodeFilter(node: any) {
    checkedNodes.forEach((node) => {
      if (node.type === "4" && (node.selected || node.checked)) {
        sessionStorage.setItem("cameraDevId", node.devId)
        _this.selectedNodes.push(node.id)
        this.selectedNodes.push(node.id)
      }
      if (node.children) {
        node.children.forEach((n: any) => {
          nodeFilter(n)
        })
      }
    }
    checkedNodes.forEach((n: any) => {
      nodeFilter(n)
    })
  }
@@ -218,7 +211,7 @@
    return camera
  }
  getCameraInfoById(id) {
  getCameraInfoById(id: string) {
    let camera = null
    function nodeFilter(node: any) {
@@ -278,6 +271,14 @@
    this.isFold(this.treeData)
    this.isFold(this.gb28181Data)
    this.selectedNodes = []
    this.selectedNode = {}
  }
  reset() {
    this.treeData = []
    this.gb28181Data = []
    this.selectedNodes = []
    this.selectedNode = {}
  }
@@ -352,6 +353,7 @@
      } else {
        if (n.type != "MENU") {
          this.cameraParents[n.id] = parentName
          this.childNodes.push(n)
        }
      }
    })
@@ -368,7 +370,6 @@
    if (this.searchFrom == "cluster") {
      params.isPlatform = 1
    }
    const rsp: any = await getLocalCameraTree(params)
    if (rsp && rsp.success) {
@@ -382,6 +383,25 @@
      this.setDropDisable(this.treeData)
      this.treeDataPure = JSON.parse(JSON.stringify(this.treeData))
      this.isFold(this.treeData)
      // 清理没有权限管理的摄像机, 后端修复后删除
      let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
      // 管理员权限
      if (userInfo.username == "Administrator") {
        return
      }
      let checkedCameras = userInfo.email
      // basic 为子账户默认的空字段,表示可管理的摄像机目录为空
      if (checkedCameras == "basic") {
        this.treeData = []
      } else {
        let cameraIds = checkedCameras.split(",")
        console.log("cameraIds", cameraIds)
        this.removeNoAuthorizedNode(this.treeData, cameraIds)
      }
    }
  }
@@ -420,11 +440,13 @@
  async fetchTreeData() {
    this.cameraParents = {}
    this.childNodes = []
    if (this.openeds[0]) {
      this.fetchLocalTree()
      await this.fetchLocalTree()
    }
    if (this.openeds[1]) {
      this.fetchGbTree()
      await this.fetchGbTree()
    }
  }
@@ -531,6 +553,28 @@
    }
  }
  removeNoAuthorizedNode(nodes: Array<any>, authList: Array<any>) {
    for (let i = 0; i < nodes.length; ) {
      if (nodes[i].children && nodes[i].children.length) {
        this.removeNoAuthorizedNode(nodes[i].children, authList)
      }
      if (nodes[i].type === "4") {
        if (authList.indexOf(nodes[i].id) < 0) {
          nodes.splice(i, 1)
          continue
        }
      } else {
        if (!nodes[i].children || !nodes[i].children.length) {
          nodes.splice(i, 1)
          continue
        }
      }
      i++
    }
  }
  countCheckedNodes(nodes: Array<any>) {
    let count = 0
    nodes.forEach((n) => {