Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
90910c18
Commit
90910c18
authored
Nov 08, 2022
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加loading状态
parent
030f2599
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
5 deletions
+3
-5
index.jsx
src/components/CustomTree/index.jsx
+3
-5
No files found.
src/components/CustomTree/index.jsx
View file @
90910c18
...
@@ -9,6 +9,7 @@ const CustomTree = forwardRef(props => {
...
@@ -9,6 +9,7 @@ const CustomTree = forwardRef(props => {
const
[
childrenList
,
setChildrenList
]
=
useState
([]);
const
[
childrenList
,
setChildrenList
]
=
useState
([]);
const
[
initValue
,
setInitValue
]
=
useState
([]);
const
[
initValue
,
setInitValue
]
=
useState
([]);
// 初始化数据状态
const
initChildrenStatus
=
arr
=>
const
initChildrenStatus
=
arr
=>
arr
.
map
(
item
=>
{
arr
.
map
(
item
=>
{
const
obj
=
initValue
.
find
(
val
=>
val
.
key
===
item
.
key
)
||
{};
const
obj
=
initValue
.
find
(
val
=>
val
.
key
===
item
.
key
)
||
{};
...
@@ -155,6 +156,8 @@ const CustomTree = forwardRef(props => {
...
@@ -155,6 +156,8 @@ const CustomTree = forwardRef(props => {
// 异步获取数据
// 异步获取数据
const
getSyncLoadChildrens
=
async
(
arr
,
ckey
,
parentChecked
)
=>
{
const
getSyncLoadChildrens
=
async
(
arr
,
ckey
,
parentChecked
)
=>
{
ChangeVal
(
arr
,
ckey
,
true
,
'
isLoading
'
);
setTreeData
(
arr
);
const
res
=
await
props
.
loadData
({
key
:
ckey
});
const
res
=
await
props
.
loadData
({
key
:
ckey
});
if
(
res
&&
res
.
length
)
{
if
(
res
&&
res
.
length
)
{
appendTreeData
(
arr
,
ckey
,
filterData
(
res
,
parentChecked
),
parentChecked
);
appendTreeData
(
arr
,
ckey
,
filterData
(
res
,
parentChecked
),
parentChecked
);
...
@@ -165,8 +168,6 @@ const CustomTree = forwardRef(props => {
...
@@ -165,8 +168,6 @@ const CustomTree = forwardRef(props => {
const
onVisibleChildren
=
async
(
ckey
,
visible
,
children
,
parentChecked
)
=>
{
const
onVisibleChildren
=
async
(
ckey
,
visible
,
children
,
parentChecked
)
=>
{
const
arr
=
[...
treeData
];
const
arr
=
[...
treeData
];
if
(
children
&&
!
children
.
length
&&
typeof
props
.
loadData
===
'
function
'
)
{
if
(
children
&&
!
children
.
length
&&
typeof
props
.
loadData
===
'
function
'
)
{
ChangeVal
(
arr
,
ckey
,
true
,
'
isLoading
'
);
setTreeData
(
arr
);
await
getSyncLoadChildrens
(
arr
,
ckey
,
parentChecked
);
await
getSyncLoadChildrens
(
arr
,
ckey
,
parentChecked
);
}
}
updateVisible
(
arr
,
ckey
,
visible
);
updateVisible
(
arr
,
ckey
,
visible
);
...
@@ -188,9 +189,6 @@ const CustomTree = forwardRef(props => {
...
@@ -188,9 +189,6 @@ const CustomTree = forwardRef(props => {
node
.
checked
=
false
;
node
.
checked
=
false
;
}
else
{
}
else
{
node
.
checked
=
node
.
children
.
every
(
item
=>
item
.
checked
);
node
.
checked
=
node
.
children
.
every
(
item
=>
item
.
checked
);
// if (node.checked) {
// node.value = [];
// }
}
}
key
=
pkey
;
key
=
pkey
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment