|
|
|
|
@ -345,23 +345,21 @@ const buildTreeFromApi = (orgs: ApiTreeOrg[]): DeviceTreeNode[] => {
|
|
|
|
|
return Array.isArray(orgTree) ? orgTree.map(toOrgNode) : []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hasOrgClassInSubtree = (node: DeviceTreeNode, targetOrgClass: string): boolean => {
|
|
|
|
|
const hasEquipmentInSubtree = (node: DeviceTreeNode): boolean => {
|
|
|
|
|
const children = Array.isArray(node?.children) ? node.children : []
|
|
|
|
|
for (const child of children) {
|
|
|
|
|
if (child?.orgClass === targetOrgClass) return true
|
|
|
|
|
if (hasOrgClassInSubtree(child, targetOrgClass)) return true
|
|
|
|
|
if (child?.tag === 'equipment') return true
|
|
|
|
|
if (hasEquipmentInSubtree(child)) return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const buildDefaultExpandedKeys = (nodes: DeviceTreeNode[], stopOrgClass: string): string[] => {
|
|
|
|
|
const buildDefaultExpandedKeys = (nodes: DeviceTreeNode[]): string[] => {
|
|
|
|
|
const keys: string[] = []
|
|
|
|
|
const walk = (list: DeviceTreeNode[]) => {
|
|
|
|
|
for (const node of list) {
|
|
|
|
|
if (node?.type === 'device' && node?.orgClass && node.orgClass !== stopOrgClass) {
|
|
|
|
|
if (hasOrgClassInSubtree(node, stopOrgClass)) {
|
|
|
|
|
keys.push(node.id)
|
|
|
|
|
}
|
|
|
|
|
if (node?.type === 'device' && node?.tag !== 'equipment' && hasEquipmentInSubtree(node)) {
|
|
|
|
|
keys.push(node.id)
|
|
|
|
|
}
|
|
|
|
|
const children = Array.isArray(node?.children) ? node.children : []
|
|
|
|
|
if (children.length) walk(children)
|
|
|
|
|
@ -388,7 +386,7 @@ const loadTree = async () => {
|
|
|
|
|
filterNoDeviceLine: 1
|
|
|
|
|
})
|
|
|
|
|
treeData.value = buildTreeFromApi(extractApiOrgs(res))
|
|
|
|
|
defaultExpandedKeys.value = buildDefaultExpandedKeys(treeData.value, 'pipeline')
|
|
|
|
|
defaultExpandedKeys.value = buildDefaultExpandedKeys(treeData.value)
|
|
|
|
|
await nextTick()
|
|
|
|
|
treeRef.value?.setExpandedKeys?.(defaultExpandedKeys.value)
|
|
|
|
|
if (keyword.value) {
|
|
|
|
|
|