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 | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 1e15998..f26629b 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -287,10 +287,11 @@ import { UserForm, UserQuery, UserVO } from '@/api/system/user/types'; import { DeptVO } from '@/api/system/dept/types'; import { RoleVO } from '@/api/system/role/types'; -import { PostVO } from '@/api/system/post/types'; +import { PostQuery, PostVO } from '@/api/system/post/types'; import { treeselect } from '@/api/system/dept'; import { globalHeaders } from '@/utils/request'; import { to } from 'await-to-js'; +import { optionselect } from '@/api/system/post'; const router = useRouter(); const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -592,6 +593,9 @@ roleOptions.value = data.roles; form.value.password = initPassword.value.toString(); }; + +/** 鏄惁宸茬粡鏇存敼杩囧矖浣� */ +const updatedPost = ref(true); /** 淇敼鎸夐挳鎿嶄綔 */ const handleUpdate = async (row?: UserForm) => { reset(); @@ -606,6 +610,8 @@ form.value.postIds = data.postIds; form.value.roleIds = data.roleIds; form.value.password = ''; + /** 缂栬緫 榛樿鏈慨鏀硅繃宀椾綅 */ + updatedPost.value = false; }; /** 鎻愪氦鎸夐挳 */ @@ -645,6 +651,23 @@ initPassword.value = response.data; }); }); + +// 鐩戞祴閮ㄩ棬鍙樺寲鍔犺浇宀椾綅 +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; + } +); </script> <style lang="scss" scoped></style> -- Gitblit v1.9.3