Commit cf20c7b5 authored by 张烨's avatar 张烨

fix: 回显

parent edd403c8
......@@ -35,7 +35,7 @@ const ListCardItem = props => {
// id
const id = getId(rest);
// 当前checkbox为分组时有用,是否部分选中
const [indeterminate, setIndeterminate] = useState(false);
const [indeterminate, setIndeterminate] = useState(true);
// 用来收集子节点的值
const [childValues, setChildValues] = useState({});
......@@ -72,14 +72,24 @@ const ListCardItem = props => {
// 勾选事件处理
const handleChecked = e => {
const { checked: v } = e.target;
setChecked(v);
setIndeterminate(false);
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(isAllchecked);
setChecked(isSomeChecked);
// eslint-disable-next-line no-unused-expressions
getValueCallback && getValueCallback([...childValArr, id], itemid);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment