From 8821d887a6acdd8882f339a50ad1893c1eed09eb Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 21 十二月 2021 16:57:02 +0800
Subject: [PATCH] 恢复国标池刷底图图标
---
src/Pool/TreeData.ts | 316 ++++++++++++++++++++++++++-------------------------
1 files changed, 161 insertions(+), 155 deletions(-)
diff --git a/src/Pool/TreeData.ts b/src/Pool/TreeData.ts
index 6984c74..c9983a8 100644
--- a/src/Pool/TreeData.ts
+++ b/src/Pool/TreeData.ts
@@ -5,13 +5,16 @@
addAreaTreeData,
delAreaTreeData,
updateAreaTreeData,
+ getGb28181Pool,
refreshGB28181Tree,
- updateCameraArea
-} from '@/api/area'
-import { findAllFile, show, changeEnable } from '@/api/localVedio'
+ updateCameraArea,
+ getCameraBaseImage
+} from "@/api/area"
export default class TreeDataPool {
public openeds: Array<boolean>
+ public activeTreeData: Array<object>
+
public treeData: Array<object>
public clusterData: Array<object>
public gb28181Data: Array<object>
@@ -27,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
@@ -37,20 +40,6 @@
public foldNodeList: object
//璁板綍宸︿晶tab锛歛ctiveName
public treeActiveName: string
- //鏈湴瑙嗛锛氳棰戝垎鏋愬鐞�
- public vedioAnaliyseSwitch: boolean
- //鏈湴瑙嗛鍒楄〃
- public localVedioList: Array<any>
- //鏈湴瑙嗛褰撳墠椤�
- public localCurrentPage: number
- //鏈湴瑙嗛姣忛〉鏌ヨ20鏉�
- public localPageSize: number
- //鏈湴瑙嗛鎬绘潯鏁�
- public localTotal: number
- //鍕鹃�夌殑鏈湴瑙嗛
- public checkedLocalVedio: Array<any>
- //褰撳墠閫変腑鐨勬湰鍦拌棰�
- public clickLocalVideo: object
//鎺у埗寮�濮嬨�佹殏鍋滄寜閽樉绀虹姸鎬�
public btnStaus: string
//鏈湴瑙嗛绫诲瀷
@@ -60,21 +49,35 @@
//璁板綍澶嶅埗鐨勬憚鍍忔満name
public ctrlCameraName: string
+ // 鏄惁浣跨敤ztree
public zTree: boolean
+
+ public checkedTreeNode: Array<object>
+
+ // 閫変腑鐨勬憚鍍忔満涓暟
+ public gb28181CheckedCount: number
+ // 鎬绘憚鍍忔満涓暟
+ public gb28181ChildNodeCount: number
+
+ // 鍥芥爣鎽勫儚鏈烘睜鐨勫簳鍥�
+ public cameraNameForBaseImage: string
+ public gb28181CameraBaseImage: string
+ public baseImageLoading: boolean
constructor() {
this.openeds = [true, true, false]
+ this.activeTreeData = []
this.treeData = []
this.gb28181Data = []
this.clusterData = []
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
@@ -82,22 +85,23 @@
this.multiple = false
this.selectedNodes = []
this.selectedNode = {}
- this.treeType = ''
+ this.treeType = ""
this.foldNodeList = {}
- this.vedioAnaliyseSwitch = false
- this.treeActiveName = 'camera'
+ this.treeActiveName = "camera"
this.searchLocalType = 0
- this.localVedioList = []
- this.checkedLocalVedio = []
- this.clickLocalVideo = {}
+
//1:鏆傚仠鐘舵�侊紱2锛氱瓑寰呯姸鎬�;3:缃伆
- this.btnStaus = '3'
- this.localCurrentPage = 1
- this.localPageSize = 20
- this.localTotal = 0
- 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 {
@@ -113,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) {
@@ -124,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)
@@ -156,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) {
@@ -228,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++) {
@@ -261,15 +265,13 @@
this.isFold(this.gb28181Data)
this.selectedNodes = []
this.selectedNode = {}
-
- this.cleanLocalVedio()
}
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))
}
}
@@ -278,11 +280,11 @@
if (!node) {
return
}
- node.forEach(n => {
+ node.forEach((n) => {
// vue-js-tree 榛樿灞曞紑,鎺у埗閮ㄥ垎鎶樺彔. z-tree 榛樿鎶樺彔, 鎺у埗閮ㄥ垎灞曞紑
if (this.foldNodeList[n.id]) {
if (this.zTree) {
- n.open = true
+ n.open = false
} else {
n.opened = false
}
@@ -297,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
}
}
@@ -312,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) {
@@ -324,9 +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
+ }
}
})
}
@@ -337,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)
@@ -394,8 +406,6 @@
if (this.openeds[1]) {
this.fetchGbTree()
}
-
- this.findAllFile({})
}
async add(name: string, parent: string) {
@@ -431,109 +441,105 @@
// this.fetchGbTree()
}
- async findAllFile(params: any) {
- ; (params.fileName = this.searchInput), (params.type = this.searchLocalType)
- params.page = this.localCurrentPage
- params.size = this.localPageSize
- let res: any = await findAllFile(params)
- if (res && res.success) {
- let list = res.data.dataList.map(i => {
- let obj: any = {}
- Object.assign(obj, i)
- if (i.ruleType == 0) {
- obj.iconStatus2 = '0'
- } else {
- obj.iconStatus2 = '1'
- }
- if (!i.snapshot_url) {
- // obj.snapshot_url = require('@/assets/nobody.png')
- obj.snapshot_url = ''
- } else {
- obj.snapshot_url = '/httpImage/' + obj.snapshot_url
- }
- if (i.is_running) {
- obj.iconStatus1 = '1'
- } else if (i.progress == 100) {
- obj.iconStatus1 = '2'
- } else if (i.status == 1 && i.progress == 0 && i.hasRule) {
- obj.iconStatus1 = '3'
- } else if (!i.hasRule && i.progress == 0) {
- obj.iconStatus1 = '4'
- }
- obj.checkStatus = false
- obj.clickStatus = false
- obj.showCheckBox = false
- return obj
- })
- this.localVedioList = list
- this.localTotal = res.data.total
- // console.log(this.localVedioList,this.searchInput,'鏈湴瑙嗛鍒楄〃')
- }
- }
-
- async show() {
- let res: any = await show()
- if (res && res.success) {
- this.vedioAnaliyseSwitch = res.data.videoEnable
- }
- }
-
- async changeEnable() {
- let res: any = await changeEnable({
- enable: this.vedioAnaliyseSwitch
- })
- }
-
- getCheckedFiles() {
- this.checkedLocalVedio = this.localVedioList.filter(i => {
- return i.checkStatus
- })
- this.clickLocalVideo = this.localVedioList.filter(i => {
- return i.clickStatus
- })[0]
-
- if (this.checkedLocalVedio.length === 0) {
- this.btnStaus = '3'
- return false
- }
- this.checkedLocalVedio.every((i, index) => {
- let t = ''
- if (i.status == 0 && i.hasRule) {
- t = '1'
- } else if (i.status == 1 && i.hasRule && !i.is_running) {
- t = '2'
- } else {
- t = '3'
- }
- if (index == 0) {
- this.btnStaus = t
- } else {
- if (this.btnStaus !== t) {
- this.btnStaus = '3'
- return false
- }
- }
- })
- }
-
- filterLocalVideoWell() {
- if (this.localVedioList.length !== 0) {
- this.localVedioList = this.localVedioList.filter(i => {
- return i.progress == 100
- })
- }
- }
-
- cleanLocalVedio() {
- this.localVedioList.map(i => {
- i.checkStatus = false
- i.clickStatus = false
- })
- this.checkedLocalVedio = []
- this.btnStaus = '3'
- }
-
- async dropNode(cameraId, areaId) {
+ async dropNode(cameraId: string, areaId: string) {
await updateCameraArea({ cameraId: cameraId, areaId: areaId })
}
+
+ getAllChildrenNodes(treeNode, arr) {
+ for (var i = 0; i < treeNode.length; i++) {
+ var sonList = treeNode[i].children
+ if (!sonList) {
+ if (treeNode[i].type == "camera") {
+ arr.push(treeNode[i])
+
+ if (treeNode[i].checked) {
+ this.gb28181CheckedCount += 1
+ }
+ }
+ } else {
+ this.getAllChildrenNodes(sonList, arr)
+ }
+ }
+ return arr
+ }
+ countChildrenNodes(treeNode) {
+ let arry = []
+
+ this.getAllChildrenNodes(treeNode, arry)
+
+ return arry.length
+ }
+
+ async fetchVideosvrCameras(update: Boolean) {
+ let fn = getGb28181Pool
+ if (update) {
+ fn = refreshGB28181Tree
+ }
+ const rsp: any = await fn()
+
+ if (rsp && rsp.success) {
+ this.selectedNode = {}
+ this.treeData = rsp.data ? rsp.data : []
+ if (this.treeData && this.treeData.length > 0) {
+ this.sortTreeData(this.treeData)
+ }
+
+ // 璁剧疆绂佹鎷栨嫿鎽勫儚鏈哄埌鎽勫儚鏈鸿妭鐐�
+ this.setDropDisable(this.treeData)
+ this.isFold(this.treeData)
+
+ this.gb28181CheckedCount = 0
+ this.gb28181ChildNodeCount = this.countChildrenNodes(this.treeData)
+ this.activeTreeData = this.treeData
+ }
+ }
+
+ removeNoCheckedNode(nodes: Array<any>) {
+ for (let i = 0; i < nodes.length; ) {
+ if (!nodes[i].checked) {
+ nodes.splice(i, 1)
+ continue
+ }
+
+ if (nodes[i].children && nodes[i].children.length) {
+ this.removeNoCheckedNode(nodes[i].children)
+ }
+ i++
+ }
+ }
+
+ countCheckedNodes(nodes: Array<any>) {
+ let count = 0
+ nodes.forEach((n) => {
+ if (n.type == "camera") {
+ count++
+ }
+ })
+ this.gb28181CheckedCount = count
+ }
+
+ newTreeByChecked(nodes: Array<object>) {
+ let newTree = JSON.parse(JSON.stringify(nodes))
+ this.removeNoCheckedNode(newTree)
+
+ 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