zhangzengfei
2022-08-19 3e4904fda5c78cfd8b40fa925fd2970b01850224
src/Pool/TreeData.ts
@@ -166,27 +166,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 +208,7 @@
    return camera
  }
  getCameraInfoById(id) {
  getCameraInfoById(id: string) {
    let camera = null
    function nodeFilter(node: any) {
@@ -278,6 +268,14 @@
    this.isFold(this.treeData)
    this.isFold(this.gb28181Data)
    this.selectedNodes = []
    this.selectedNode = {}
  }
  reset() {
    this.treeData = []
    this.gb28181Data = []
    this.selectedNodes = []
    this.selectedNode = {}
  }
@@ -368,7 +366,6 @@
    if (this.searchFrom == "cluster") {
      params.isPlatform = 1
    }
    const rsp: any = await getLocalCameraTree(params)
    if (rsp && rsp.success) {
@@ -382,6 +379,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)
      }
    }
  }
@@ -421,10 +437,10 @@
  async fetchTreeData() {
    this.cameraParents = {}
    if (this.openeds[0]) {
      this.fetchLocalTree()
      await this.fetchLocalTree()
    }
    if (this.openeds[1]) {
      this.fetchGbTree()
      await this.fetchGbTree()
    }
  }
@@ -531,6 +547,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) => {