Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
ReactWeb5
CivManage
Commits
cf20c7b5
Commit
cf20c7b5
authored
4 years ago
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 回显
parent
edd403c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
ItemCard.jsx
src/components/CheckGroup/ItemCard.jsx
+12
-2
No files found.
src/components/CheckGroup/ItemCard.jsx
View file @
cf20c7b5
...
...
@@ -35,7 +35,7 @@ const ListCardItem = props => {
// id
const
id
=
getId
(
rest
);
// 当前checkbox为分组时有用,是否部分选中
const
[
indeterminate
,
setIndeterminate
]
=
useState
(
fals
e
);
const
[
indeterminate
,
setIndeterminate
]
=
useState
(
tru
e
);
// 用来收集子节点的值
const
[
childValues
,
setChildValues
]
=
useState
({});
...
...
@@ -72,14 +72,24 @@ const ListCardItem = props => {
// 勾选事件处理
const
handleChecked
=
e
=>
{
const
{
checked
:
v
}
=
e
.
target
;
if
(
isGroup
)
{
if
(
indeterminate
)
{
setChecked
(
true
);
}
else
{
setChecked
(
v
);
}
setIndeterminate
(
false
);
}
else
{
setChecked
(
v
);
}
// setIndeterminate(false);
if
(
!
isCurrentGroup
)
{
getValueCallback
(
v
?
[
id
]
:
[],
itemid
);
}
};
const
handleChildValueCallback
=
(
arr
,
childIndex
)
=>
{
const
isInitFlag
=
!!
childValues
[
childIndex
];
// 进这里的都是分组,组长统计并处理自己的状态: 全选,部分选,零选
// 拿到所有勾选的子节点
childValues
[
childIndex
]
=
arr
;
...
...
@@ -99,7 +109,7 @@ const ListCardItem = props => {
'some'
,
);
setIndeterminate
(
!
isAllchecked
&&
isSomeChecked
);
setChecked
(
is
Allc
hecked
);
setChecked
(
is
SomeC
hecked
);
// eslint-disable-next-line no-unused-expressions
getValueCallback
&&
getValueCallback
([...
childValArr
,
id
],
itemid
);
};
...
...
This diff is collapsed.
Click to expand it.
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