From 0b8f48fb610c8a2e3f9fb633241fcf46a78da69d Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Tue, 30 Apr 2024 22:46:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=97=B6=E6=9C=89?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E4=BC=9A=E8=A2=AB=E8=B5=8B=E5=80=BC=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/index.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 148e8af..f26629b 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -593,6 +593,9 @@ const handleAdd = async () => { roleOptions.value = data.roles; form.value.password = initPassword.value.toString(); }; + +/** 是否已经更改过岗位 */ +const updatedPost = ref(true); /** 修改按钮操作 */ const handleUpdate = async (row?: UserForm) => { reset(); @@ -607,6 +610,8 @@ const handleUpdate = async (row?: UserForm) => { form.value.postIds = data.postIds; form.value.roleIds = data.roleIds; form.value.password = ''; + /** 编辑 默认未修改过岗位 */ + updatedPost.value = false; }; /** 提交按钮 */ @@ -653,8 +658,14 @@ watch( async () => { const response = await optionselect(form.value.deptId); postOptions.value = response.data; - /** 变化后需要重新选择岗位 */ - form.value.postIds = []; + /** 判断是否修改过岗位 防止第一次编辑时有岗位信息也被设置为空 */ + if (updatedPost.value) { + /** 变化后需要重新选择岗位 */ + form.value.postIds = []; + return; + } + /** 执行一次后默认设为已经修改过 */ + updatedPost.value = true; } );