Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cd55c53a
authored
Jan 16, 2026
by
Jaxon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(treeData): 重构 normalizeTree 函数,优化参数处理和返回结构
1 parent
e37adb1c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
13 deletions
src/common/treeData.js
src/common/treeData.js
View file @
cd55c53
...
@@ -21,31 +21,44 @@
...
@@ -21,31 +21,44 @@
export
function
normalizeTree
(
export
function
normalizeTree
(
data
,
data
,
{
{
labelKeys
=
[
"label"
,
"name"
,
"title"
,
"deptName"
,
"itemName"
],
labelKeys
,
valueKeys
=
[
"value"
,
"id"
,
"deptId"
,
"defineType"
],
valueKeys
,
childrenKeys
=
[
"children"
,
"nodes"
,
"childrenList"
,
"itemList"
],
childrenKeys
,
outputKeys
,
}
=
{
labelKeys
:
[
"label"
,
"name"
,
"title"
,
"defineName"
,
"itemName"
],
valueKeys
:
[
"value"
,
"id"
,
"deptId"
,
"itemId"
],
childrenKeys
:
[
"children"
,
"nodes"
,
"childrenList"
,
"itemList"
],
outputKeys
:
{
label
:
"label"
,
value
:
"value"
,
children
:
"children"
,
},
},
},
)
{
)
{
if
(
!
Array
.
isArray
(
data
))
if
(
!
Array
.
isArray
(
data
))
return
[];
return
[];
console
.
log
(
"data"
,
data
);
return
data
.
map
((
item
)
=>
{
return
data
.
map
((
item
)
=>
{
const
label
=
labelKeys
.
find
(
k
=>
item
[
k
]
!=
null
);
const
label
=
labelKeys
.
find
(
k
=>
item
[
k
]
!=
null
);
const
value
=
valueKeys
.
find
(
k
=>
item
[
k
]
!=
null
);
const
value
=
valueKeys
.
find
(
k
=>
item
[
k
]
!=
null
);
const
childrenKey
=
childrenKeys
.
find
(
k
=>
Array
.
isArray
(
item
[
k
]));
const
childrenKey
=
childrenKeys
.
find
(
k
=>
Array
.
isArray
(
item
[
k
]));
return
{
const
next
=
{
...
item
};
label
:
label
?
item
[
label
]
:
""
,
if
(
!
(
outputKeys
.
label
in
next
))
value
:
value
?
item
[
value
]
:
""
,
next
[
outputKeys
.
label
]
=
label
?
item
[
label
]
:
""
;
children
:
childrenKey
if
(
!
(
outputKeys
.
value
in
next
))
?
normalizeTree
(
item
[
childrenKey
],
{
next
[
outputKeys
.
value
]
=
value
?
item
[
value
]
:
""
;
if
(
childrenKey
)
{
next
[
outputKeys
.
children
]
=
normalizeTree
(
item
[
childrenKey
],
{
labelKeys
,
labelKeys
,
valueKeys
,
valueKeys
,
childrenKeys
,
childrenKeys
,
})
outputKeys
,
:
undefined
,
});
...(
childrenKey
?
undefined
:
{
leaf
:
false
}),
}
else
if
(
!
(
"leaf"
in
next
))
{
};
next
.
leaf
=
false
;
}
return
next
;
});
});
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment