From e2470a31bf87898dbbe7a1cfffd3ca5177e97497 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Sat, 13 Aug 2022 00:41:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=83=A8=E9=97=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cool/utils/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cool/utils/index.ts b/src/cool/utils/index.ts index f167925..e6b541a 100644 --- a/src/cool/utils/index.ts +++ b/src/cool/utils/index.ts @@ -244,13 +244,15 @@ export function revDeepTree(list: any[]) { const arr: any[] = []; let id = 0; - function deep(list: any[], parentId: any) { + function deep(list: any[], parentId: number) { list.forEach((e) => { if (!e.id) { e.id = id++; } - e.parentId = parentId; + if (!e.parentId) { + e.parentId = parentId; + } arr.push(e); @@ -260,7 +262,7 @@ export function revDeepTree(list: any[]) { }); } - deep(list || [], null); + deep(list || [], 0); return arr; }