refactor: 部门选择和岗位逻辑

This commit is contained in:
dap 2024-05-06 13:23:27 +08:00
parent 0b8f48fb61
commit 437bc936fd

View File

@ -158,6 +158,7 @@
value-key="id" value-key="id"
placeholder="请选择归属部门" placeholder="请选择归属部门"
check-strictly check-strictly
@change="handleDeptChange"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -594,8 +595,6 @@ const handleAdd = async () => {
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();
@ -610,8 +609,6 @@ 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;
}; };
/** 提交按钮 */ /** 提交按钮 */
@ -652,22 +649,11 @@ onMounted(() => {
}); });
}); });
// async function handleDeptChange(value: number | string) {
watch( const response = await optionselect(value);
() => form.value.deptId, postOptions.value = response.data;
async () => { form.value.postIds = [];
const response = await optionselect(form.value.deptId); }
postOptions.value = response.data;
/** 判断是否修改过岗位 防止第一次编辑时有岗位信息也被设置为空 */
if (updatedPost.value) {
/** 变化后需要重新选择岗位 */
form.value.postIds = [];
return;
}
/** 执行一次后默认设为已经修改过 */
updatedPost.value = true;
}
);
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>