视频树数据
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
@node-click="handleNodeClick">
|
||||
<template v-slot="{ node, data }">
|
||||
<!-- <img src="@/assets/images/livePreview/icon-monitor.png" alt=""> -->
|
||||
<span :class="(!data.sourceType && treeType === 'UAV') ? 'offline': ''">{{ node.label }}</span>
|
||||
<span :class="(data.sourceType!=='2' && treeType === 'UAV') ? 'offline': ''">{{ node.label }}</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
@@ -29,34 +29,11 @@ const refresh = (type) => {
|
||||
if(type === 'CCTV') {
|
||||
const params = {}
|
||||
findVideoLevelList(params).then(res => {
|
||||
if (res.success) {
|
||||
const data = res.result.records
|
||||
const groupedData = {}
|
||||
data.forEach(item => {
|
||||
const belong = item.videoBelong
|
||||
if (!groupedData[belong]) {
|
||||
groupedData[belong] = []
|
||||
}
|
||||
groupedData[belong].push(item)
|
||||
})
|
||||
// 转换为树形结构
|
||||
const result = Object.keys(groupedData).map(belong => {
|
||||
const children = groupedData[belong]
|
||||
if (children.length === 1) {
|
||||
// 只有一个子元素,直接返回该子元素
|
||||
return children[0]
|
||||
}
|
||||
// 有多个子元素,返回分组节点
|
||||
return {
|
||||
videoName: belong,
|
||||
longitude: children[0].longitude,
|
||||
latitude: children[0].latitude,
|
||||
children: children
|
||||
}
|
||||
|
||||
})
|
||||
tableData.value = result
|
||||
}
|
||||
const arr = []
|
||||
Object.keys(res.data).forEach(i => {
|
||||
arr.push({ videoName: i, children: res.data[i] })
|
||||
})
|
||||
tableData.value = arr
|
||||
})
|
||||
}else if(type === 'UAV') {
|
||||
const params = {
|
||||
@@ -97,10 +74,10 @@ const refresh = (type) => {
|
||||
|
||||
}
|
||||
const handleNodeClick = (data, node) => {
|
||||
if(!data.sourceType) {
|
||||
return false
|
||||
}
|
||||
if(!data.children || data.children.length === 0) {
|
||||
if(treeType.value === 'UAV' && !data.sourceType) {
|
||||
return false
|
||||
}
|
||||
emit('handle', node.data)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user