update 优化userSelect 选中未确定,再次打开还保留选中的问题
This commit is contained in:
parent
71bf715ea6
commit
f36e2c713d
@ -61,7 +61,7 @@
|
||||
:data="userList"
|
||||
:loading="loading"
|
||||
:row-config="{ keyField: 'userId', isHover: true }"
|
||||
:checkbox-config="{ reserve: true, trigger: 'row', highlight: true, checkRowKeys: defaultSelectUserIds, showHeader: prop.multiple }"
|
||||
:checkbox-config="{ reserve: true, trigger: 'row', highlight: true, showHeader: prop.multiple }"
|
||||
@checkbox-all="handleCheckboxAll"
|
||||
@checkbox-change="handleCheckboxChange"
|
||||
>
|
||||
@ -207,7 +207,7 @@ const getList = async () => {
|
||||
const pageList = async () => {
|
||||
await getList();
|
||||
const users = userList.value.filter((item) => {
|
||||
return defaultSelectUserIds.value.includes(item.userId);
|
||||
return selectUserList.value.some((user) => user.userId === item.userId);
|
||||
});
|
||||
await tableRef.value.setCheckboxRow(users, true);
|
||||
};
|
||||
@ -275,18 +275,33 @@ const initSelectUser = async () => {
|
||||
if (defaultSelectUserIds.value.length > 0) {
|
||||
const { data } = await api.optionSelect(defaultSelectUserIds.value);
|
||||
selectUserList.value = data;
|
||||
await nextTick(() => {
|
||||
const users = userList.value.filter((item) => {
|
||||
return defaultSelectUserIds.value.includes(String(item.userId));
|
||||
});
|
||||
tableRef.value.setCheckboxRow(users, true);
|
||||
});
|
||||
}
|
||||
};
|
||||
const close = () => {
|
||||
userDialog.closeDialog();
|
||||
};
|
||||
|
||||
watch(
|
||||
() => userDialog.visible.value,
|
||||
(newValue: boolean) => {
|
||||
if (newValue) {
|
||||
initSelectUser();
|
||||
} else {
|
||||
tableRef.value.clearCheckboxReserve();
|
||||
tableRef.value.clearCheckboxRow();
|
||||
resetQuery();
|
||||
selectUserList.value = [];
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
initSelectUser();
|
||||
getTreeSelect(); // 初始化部门数据
|
||||
getList(); // 初始化列表数据
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user