update 优化用户选择器

This commit is contained in:
LiuHao 2024-01-31 15:31:33 +08:00
parent 6f2298c88a
commit d6c6b77672

View File

@ -96,7 +96,7 @@
</el-row>
<template #footer>
<el-button @click="userDialog.closeDialog">取消</el-button>
<el-button @click="close">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
</template>
</el-dialog>
@ -152,6 +152,18 @@ const queryParams = ref<UserQuery>({
roleId: ''
});
const defaultSelectUserIds = computed(() => computedIds(prop.data));
/** 根据名称筛选部门树 */
watchEffect(
() => {
deptTreeRef.value?.filter(deptName.value);
},
{
flush: 'post' // watchEffectDOMDOM
}
);
const confirm = () => {
emit('update:modelValue', selectUserList.value);
emit('confirmCallBack', selectUserList.value);
@ -166,23 +178,11 @@ const computedIds = (data) => {
} else if (typeof data === 'number') {
return [data];
} else {
console.warn('The data type of data should be array or string or number, but I received other');
console.warn('<UserSelect> The data type of data should be array or string or number, but I received other');
return [];
}
};
const defaultSelectUserIds = computed(() => computedIds(prop.data));
/** 根据名称筛选部门树 */
watchEffect(
() => {
deptTreeRef.value?.filter(deptName.value);
},
{
flush: 'post' // watchEffectDOMDOM
}
);
/** 通过条件过滤节点 */
const filterNode = (value: string, data: any) => {
if (!value) return true;
@ -277,6 +277,13 @@ const initSelectUser = async () => {
selectUserList.value = data;
}
};
const close = () => {
userDialog.closeDialog();
tableRef.value.clearCheckboxReserve();
tableRef.value.clearCheckboxRow();
resetQuery();
selectUserList.value = [];
};
onMounted(() => {
initSelectUser();