From 1e1e5f612f252d66b0d0386cf52873bb1f3f7d7b Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期五, 01 九月 2023 16:10:37 +0800
Subject: [PATCH] 系统维护+系统监控器+调试工具的app 增加

---
 src/Pool/TreeData.ts |  113 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 76 insertions(+), 37 deletions(-)

diff --git a/src/Pool/TreeData.ts b/src/Pool/TreeData.ts
index 4d5c6a5..c9983a8 100644
--- a/src/Pool/TreeData.ts
+++ b/src/Pool/TreeData.ts
@@ -5,9 +5,11 @@
   addAreaTreeData,
   delAreaTreeData,
   updateAreaTreeData,
+  getGb28181Pool,
   refreshGB28181Tree,
-  updateCameraArea
-} from '@/api/area'
+  updateCameraArea,
+  getCameraBaseImage
+} from "@/api/area"
 
 export default class TreeDataPool {
   public openeds: Array<boolean>
@@ -28,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
@@ -57,6 +59,11 @@
   // 鎬绘憚鍍忔満涓暟
   public gb28181ChildNodeCount: number
 
+  // 鍥芥爣鎽勫儚鏈烘睜鐨勫簳鍥�
+  public cameraNameForBaseImage: string
+  public gb28181CameraBaseImage: string
+  public baseImageLoading: boolean
+
   constructor() {
     this.openeds = [true, true, false]
     this.activeTreeData = []
@@ -66,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
@@ -78,19 +85,23 @@
     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
     this.gb28181ChildNodeCount = 0
+
+    this.cameraNameForBaseImage = ""
+    this.gb28181CameraBaseImage = ""
+    this.baseImageLoading = false
   }
 
   setVideoArr(index: number, value: object, vue: any): void {
@@ -106,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) {
@@ -117,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)
@@ -149,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) {
@@ -221,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++) {
@@ -257,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))
     }
   }
@@ -269,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) {
@@ -288,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
         }
       }
@@ -303,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) {
@@ -315,12 +329,16 @@
       }
     })
 
-    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
+        }
       }
     })
   }
@@ -331,7 +349,7 @@
       cameraName: this.searchInput
       //isPlatform: 1
     }
-    if (this.searchFrom == 'cluster') {
+    if (this.searchFrom == "cluster") {
       params.isPlatform = 1
     }
     const rsp: any = await getLocalCameraTree(params)
@@ -429,20 +447,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 = []
@@ -452,8 +470,12 @@
     return arry.length
   }
 
-  async fetchVideosvrCameras() {
-    const rsp: any = await refreshGB28181Tree()
+  async fetchVideosvrCameras(update: Boolean) {
+    let fn = getGb28181Pool
+    if (update) {
+      fn = refreshGB28181Tree
+    }
+    const rsp: any = await fn()
 
     if (rsp && rsp.success) {
       this.selectedNode = {}
@@ -466,15 +488,14 @@
       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
     }
   }
 
   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
@@ -489,7 +510,7 @@
 
   countCheckedNodes(nodes: Array<any>) {
     let count = 0
-    nodes.forEach(n => {
+    nodes.forEach((n) => {
       if (n.type == "camera") {
         count++
       }
@@ -503,4 +524,22 @@
 
     return newTree
   }
+
+  async showBaseImage(node: any) {
+    this.baseImageLoading = true
+    this.gb28181CameraBaseImage = ""
+    this.cameraNameForBaseImage = node.name
+
+    try {
+      const rsp: any = await getCameraBaseImage({ id: node.id })
+
+      if (rsp && rsp.data) {
+        this.gb28181CameraBaseImage = rsp.data
+      }
+    } catch (error) {
+      console.log(error)
+    }
+
+    this.baseImageLoading = false
+  }
 }

--
Gitblit v1.8.0