From 0b8f48fb610c8a2e3f9fb633241fcf46a78da69d Mon Sep 17 00:00:00 2001
From: dap <15891557205@163.com>
Date: 星期二, 30 四月 2024 22:46:10 +0800
Subject: [PATCH] fix: 更新时有岗位会被赋值为空的bug

---
 src/views/system/user/index.vue |   15 +++++++++++++--
 1 files 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 @@
   roleOptions.value = data.roles;
   form.value.password = initPassword.value.toString();
 };
+
+/** 鏄惁宸茬粡鏇存敼杩囧矖浣� */
+const updatedPost = ref(true);
 /** 淇敼鎸夐挳鎿嶄綔 */
 const handleUpdate = async (row?: UserForm) => {
   reset();
@@ -607,6 +610,8 @@
   form.value.postIds = data.postIds;
   form.value.roleIds = data.roleIds;
   form.value.password = '';
+  /** 缂栬緫 榛樿鏈慨鏀硅繃宀椾綅 */
+  updatedPost.value = false;
 };
 
 /** 鎻愪氦鎸夐挳 */
@@ -653,8 +658,14 @@
   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;
   }
 );
 </script>

--
Gitblit v1.9.3