zhangzengfei
2021-12-14 ff9b976bde73fe1d31e9b84cf1fa6b91e1b79dbc
修复ztree显示空目录功能
1个文件已修改
76 ■■■■■ 已修改文件
src/Pool/TreeData.ts 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Pool/TreeData.ts
@@ -9,7 +9,7 @@
  refreshGB28181Tree,
  updateCameraArea,
  getCameraBaseImage
} from '@/api/area'
} from "@/api/area"
export default class TreeDataPool {
  public openeds: Array<boolean>
@@ -30,7 +30,7 @@
  public readonly: boolean
  public gbReadonly: boolean
  public multiple: boolean
  public searchFrom: string = ''
  public searchFrom: string = ""
  public showTreeBox: boolean
  public selectedNodes: Array<string>
  public selectedNode: any
@@ -73,11 +73,11 @@
    this.treeDataPure = []
    this.gb28181DataPure = []
    this.clusterDataPure = []
    this.videoArr = ['']
    this.videoArr = [""]
    this.searchCamType = 0
    this.searchInput = ''
    this.activeVideoIndex = ''
    this.activeVideoId = ''
    this.searchInput = ""
    this.activeVideoIndex = ""
    this.activeVideoId = ""
    this.activeForceChoose = false
    this.showTreeBox = true
    this.readonly = true
@@ -85,15 +85,15 @@
    this.multiple = false
    this.selectedNodes = []
    this.selectedNode = {}
    this.treeType = ''
    this.treeType = ""
    this.foldNodeList = {}
    this.treeActiveName = 'camera'
    this.treeActiveName = "camera"
    this.searchLocalType = 0
    //1:暂停状态;2:等待状态;3:置灰
    this.btnStaus = '3'
    this.ctrlCameraId = ''
    this.ctrlCameraName = ''
    this.btnStaus = "3"
    this.ctrlCameraId = ""
    this.ctrlCameraName = ""
    this.zTree = false
    this.checkedTreeNode = []
    this.gb28181CheckedCount = 0
@@ -117,7 +117,7 @@
    }
    let _selected = this.selectedNodes
    function nodeFilter(node: any) {
      if (node.type === '4' && node.selected) {
      if (node.type === "4" && node.selected) {
        _selected.push(node.id)
      }
      if (node.children) {
@@ -128,11 +128,11 @@
    }
    if (this.selectedNode.cameraType === 0) {
      //摄像机树
      if (this.treeActiveName == 'camera') {
      if (this.treeActiveName == "camera") {
        this.treeData.forEach((n: any) => {
          nodeFilter(n)
        })
      } else if (this.treeActiveName == 'cluster') {
      } else if (this.treeActiveName == "cluster") {
        //集群树
        this.clusterData.forEach((n: any) => {
          nodeFilter(n)
@@ -160,7 +160,7 @@
    }
    function nodeFilter(node: any) {
      if (node.type === '4' && (node.selected || node.checked)) {
      if (node.type === "4" && (node.selected || node.checked)) {
        _this.selectedNodes.push(node.id)
      }
      if (node.children) {
@@ -232,7 +232,7 @@
  }
  getParent(id: string, isGB: boolean): string {
    let parent = '0'
    let parent = "0"
    function nodeFilter(node: Array<any>): any {
      for (let i = 0; i < node.length; i++) {
@@ -268,10 +268,10 @@
  }
  cleanTree(tree) {
    if (tree === 'localTree') {
    if (tree === "localTree") {
      this.treeData = JSON.parse(JSON.stringify(this.treeDataPure))
    }
    if (tree === 'gb28182Tree') {
    if (tree === "gb28182Tree") {
      this.gb28181Data = JSON.parse(JSON.stringify(this.gb28181DataPure))
    }
  }
@@ -280,7 +280,7 @@
    if (!node) {
      return
    }
    node.forEach(n => {
    node.forEach((n) => {
      // vue-js-tree 默认展开,控制部分折叠. z-tree 默认折叠, 控制部分展开
      if (this.foldNodeList[n.id]) {
        if (this.zTree) {
@@ -299,11 +299,11 @@
    if (!node) {
      return
    }
    node.forEach(n => {
    node.forEach((n) => {
      if (n.children && n.children.length > 0) {
        this.setDropDisable(n.children)
      } else {
        if (n.type === '4') {
        if (n.type === "4") {
          n.dropDisabled = true
        }
      }
@@ -314,7 +314,10 @@
    if (!node) {
      return
    }
    node.sort(function (obj1: any, obj2: any) {
    node.sort(function(obj1: any, obj2: any) {
      if (obj1.type == "menu") {
        return -1
      }
      var val1 = obj1.name
      var val2 = obj2.name
      if (val1 < val2) {
@@ -326,12 +329,17 @@
      }
    })
    node.forEach(n => {
    node.forEach((n) => {
      if (n.children && n.children.length > 0) {
        if (this.zTree) {
          n.open = true
        }
        this.sortTreeData(n.children)
      } else {
        if (n.type == "menu" && this.zTree) {
          n.isParent = true
          console.log(n)
        }
      }
    })
  }
@@ -342,7 +350,7 @@
      cameraName: this.searchInput
      //isPlatform: 1
    }
    if (this.searchFrom == 'cluster') {
    if (this.searchFrom == "cluster") {
      params.isPlatform = 1
    }
    const rsp: any = await getLocalCameraTree(params)
@@ -440,20 +448,20 @@
  getAllChildrenNodes(treeNode, arr) {
    for (var i = 0; i < treeNode.length; i++) {
      var sonList = treeNode[i].children;
      var sonList = treeNode[i].children
      if (!sonList) {
        if (treeNode[i].type == "camera") {
          arr.push(treeNode[i]);
          arr.push(treeNode[i])
          if (treeNode[i].checked) {
            this.gb28181CheckedCount += 1;
            this.gb28181CheckedCount += 1
          }
        }
      } else {
        this.getAllChildrenNodes(sonList, arr);
        this.getAllChildrenNodes(sonList, arr)
      }
    }
    return arr;
    return arr
  }
  countChildrenNodes(treeNode) {
    let arry = []
@@ -481,15 +489,15 @@
      this.setDropDisable(this.treeData)
      this.isFold(this.treeData)
      this.activeTreeData = this.treeData
      this.gb28181CheckedCount = 0;
      this.gb28181CheckedCount = 0
      this.gb28181ChildNodeCount = this.countChildrenNodes(this.treeData)
      this.activeTreeData = this.treeData
      console.log(this.activeTreeData)
    }
  }
  removeNoCheckedNode(nodes: Array<any>) {
    for (let i = 0; i < nodes.length;) {
    for (let i = 0; i < nodes.length; ) {
      if (!nodes[i].checked) {
        nodes.splice(i, 1)
        continue
@@ -504,7 +512,7 @@
  countCheckedNodes(nodes: Array<any>) {
    let count = 0
    nodes.forEach(n => {
    nodes.forEach((n) => {
      if (n.type == "camera") {
        count++
      }