From 1be7480472a92855a6e7f89b27016ad445fc4ec2 Mon Sep 17 00:00:00 2001 From: 12451 <12451@example.com> Date: Thu, 2 Jul 2026 19:18:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=E6=A0=91=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=88=B0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=8A=82=E7=82=B9=EF=BC=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9F=9C?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/devices/OrganizationTree.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) 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, }; }),