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
Nov 17, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 回显
parent
edd403c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
ItemCard.jsx
src/components/CheckGroup/ItemCard.jsx
+14
-4
No files found.
src/components/CheckGroup/ItemCard.jsx
View file @
cf20c7b5
...
@@ -35,7 +35,7 @@ const ListCardItem = props => {
...
@@ -35,7 +35,7 @@ const ListCardItem = props => {
// id
// id
const
id
=
getId
(
rest
);
const
id
=
getId
(
rest
);
// 当前checkbox为分组时有用,是否部分选中
// 当前checkbox为分组时有用,是否部分选中
const
[
indeterminate
,
setIndeterminate
]
=
useState
(
fals
e
);
const
[
indeterminate
,
setIndeterminate
]
=
useState
(
tru
e
);
// 用来收集子节点的值
// 用来收集子节点的值
const
[
childValues
,
setChildValues
]
=
useState
({});
const
[
childValues
,
setChildValues
]
=
useState
({});
...
@@ -72,14 +72,24 @@ const ListCardItem = props => {
...
@@ -72,14 +72,24 @@ const ListCardItem = props => {
// 勾选事件处理
// 勾选事件处理
const
handleChecked
=
e
=>
{
const
handleChecked
=
e
=>
{
const
{
checked
:
v
}
=
e
.
target
;
const
{
checked
:
v
}
=
e
.
target
;
setChecked
(
v
);
if
(
isGroup
)
{
setIndeterminate
(
false
);
if
(
indeterminate
)
{
setChecked
(
true
);
}
else
{
setChecked
(
v
);
}
setIndeterminate
(
false
);
}
else
{
setChecked
(
v
);
}
// setIndeterminate(false);
if
(
!
isCurrentGroup
)
{
if
(
!
isCurrentGroup
)
{
getValueCallback
(
v
?
[
id
]
:
[],
itemid
);
getValueCallback
(
v
?
[
id
]
:
[],
itemid
);
}
}
};
};
const
handleChildValueCallback
=
(
arr
,
childIndex
)
=>
{
const
handleChildValueCallback
=
(
arr
,
childIndex
)
=>
{
const
isInitFlag
=
!!
childValues
[
childIndex
];
// 进这里的都是分组,组长统计并处理自己的状态: 全选,部分选,零选
// 进这里的都是分组,组长统计并处理自己的状态: 全选,部分选,零选
// 拿到所有勾选的子节点
// 拿到所有勾选的子节点
childValues
[
childIndex
]
=
arr
;
childValues
[
childIndex
]
=
arr
;
...
@@ -99,7 +109,7 @@ const ListCardItem = props => {
...
@@ -99,7 +109,7 @@ const ListCardItem = props => {
'some'
,
'some'
,
);
);
setIndeterminate
(
!
isAllchecked
&&
isSomeChecked
);
setIndeterminate
(
!
isAllchecked
&&
isSomeChecked
);
setChecked
(
is
Allc
hecked
);
setChecked
(
is
SomeC
hecked
);
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line no-unused-expressions
getValueCallback
&&
getValueCallback
([...
childValArr
,
id
],
itemid
);
getValueCallback
&&
getValueCallback
([...
childValArr
,
id
],
itemid
);
};
};
...
...
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