From 437bc936fd8910cc470dfe48f5ec72335bc9d037 Mon Sep 17 00:00:00 2001 From: dap Date: Mon, 6 May 2024 13:23:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=83=A8=E9=97=A8=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=92=8C=E5=B2=97=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/index.vue | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index f26629b..c1bdcf9 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -158,6 +158,7 @@ value-key="id" placeholder="请选择归属部门" check-strictly + @change="handleDeptChange" /> @@ -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); - postOptions.value = response.data; - /** 判断是否修改过岗位 防止第一次编辑时有岗位信息也被设置为空 */ - if (updatedPost.value) { - /** 变化后需要重新选择岗位 */ - form.value.postIds = []; - return; - } - /** 执行一次后默认设为已经修改过 */ - updatedPost.value = true; - } -); +async function handleDeptChange(value: number | string) { + const response = await optionselect(value); + postOptions.value = response.data; + form.value.postIds = []; +}