diff --git a/software/web/src/pages/devices/OrganizationTree.tsx b/software/web/src/pages/devices/OrganizationTree.tsx index 2d1b3d0..f3d5e96 100644 --- a/software/web/src/pages/devices/OrganizationTree.tsx +++ b/software/web/src/pages/devices/OrganizationTree.tsx @@ -13,7 +13,6 @@ import { } from '@arco-design/web-react'; import { IconFolder, - IconDesktop, IconRefresh, } from '@arco-design/web-react/icon'; import { @@ -36,19 +35,19 @@ export interface TreeInternalNode { _id: number; } -/** 构建 Arco Tree 数据 */ +/** 构建 Arco Tree 数据(只到项目节点,不显示柜子) */ export function buildTreeData(nodes: TreeNode[], parentKey?: string): TreeInternalNode[] { const result: TreeInternalNode[] = []; for (const n of nodes) { const key = parentKey ? `${parentKey}-${n.id}` : `${n.id}`; - const children = n.children ? buildTreeData(n.children, key) : undefined; - const nodeType: NodeType = n.children !== undefined - ? (parentKey ? 'project' : 'organization') - : 'cabinet'; + const nodeType: NodeType = parentKey ? 'project' : 'organization'; + // 只显示组织和项目,不显示柜子 + const hasChildren = n.children && n.children.some(c => c.children !== undefined); + const children = hasChildren ? buildTreeData(n.children!, key) : undefined; result.push({ key, - title: n.abstract_id ? `${n.abstract_id} ${n.name || ''}` : n.name, - isLeaf: !children || children.length === 0, + title: n.name, + isLeaf: !hasChildren, children, _type: nodeType, _id: n.id, @@ -124,12 +123,9 @@ export default function OrganizationTree({ const injectTitleRender = useCallback( (nodes: TreeInternalNode[]): unknown[] => nodes.map((n) => { - const icon = n._type === 'cabinet' - ? - : ; return { ...n, - title: renderNodeTitle(n._type, n._id, n.title, icon), + title: renderNodeTitle(n._type, n._id, n.title, ), children: n.children ? injectTitleRender(n.children) : undefined, }; }),