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