fix: 更新时有岗位会被赋值为空的bug

This commit is contained in:
dap 2024-04-30 22:46:10 +08:00
parent 5d641e5de4
commit 0b8f48fb61

View File

@ -593,6 +593,9 @@ const handleAdd = async () => {
roleOptions.value = data.roles; roleOptions.value = data.roles;
form.value.password = initPassword.value.toString(); form.value.password = initPassword.value.toString();
}; };
/** 是否已经更改过岗位 */
const updatedPost = ref(true);
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: UserForm) => { const handleUpdate = async (row?: UserForm) => {
reset(); reset();
@ -607,6 +610,8 @@ const handleUpdate = async (row?: UserForm) => {
form.value.postIds = data.postIds; form.value.postIds = data.postIds;
form.value.roleIds = data.roleIds; form.value.roleIds = data.roleIds;
form.value.password = ''; form.value.password = '';
/** 编辑 默认未修改过岗位 */
updatedPost.value = false;
}; };
/** 提交按钮 */ /** 提交按钮 */
@ -653,8 +658,14 @@ watch(
async () => { async () => {
const response = await optionselect(form.value.deptId); const response = await optionselect(form.value.deptId);
postOptions.value = response.data; postOptions.value = response.data;
/** 判断是否修改过岗位 防止第一次编辑时有岗位信息也被设置为空 */
if (updatedPost.value) {
/** 变化后需要重新选择岗位 */ /** 变化后需要重新选择岗位 */
form.value.postIds = []; form.value.postIds = [];
return;
}
/** 执行一次后默认设为已经修改过 */
updatedPost.value = true;
} }
); );
</script> </script>