From fb79029765187b0109639f6228079533134f8d5d Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Fri, 25 Oct 2024 08:21:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E6=97=B6=E6=89=93=E5=BC=80?= =?UTF-8?q?drawer=E9=9C=80=E8=A6=81=E5=8A=A0=E8=BD=BD=E8=AF=A5=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E4=B8=8B=E7=9A=84=E5=B2=97=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/views/system/user/user-drawer.vue | 37 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad1a62a..04092531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - 岗位管理 部门参数错误 - 角色管理 菜单分配 节点独立下的回显及提交问题 - 租户管理 套餐管理 回显时候`已选中节点`数量为0 +- 用户管理 更新用户时打开drawer需要加载该部门下的岗位信息 **OTHERS** diff --git a/apps/web-antd/src/views/system/user/user-drawer.vue b/apps/web-antd/src/views/system/user/user-drawer.vue index 9a490cb5..0b37459a 100644 --- a/apps/web-antd/src/views/system/user/user-drawer.vue +++ b/apps/web-antd/src/views/system/user/user-drawer.vue @@ -60,6 +60,24 @@ function genRoleOptionlabel(role: Role) { ]); } +/** + * 岗位的加载 + */ +async function setupPostOptions(deptId: number | string) { + const postListResp = await postOptionSelect(deptId); + const options = postListResp.map((item) => ({ + label: item.postName, + value: item.postId, + })); + const placeholder = options.length > 0 ? '请选择' : '该部门下暂无岗位'; + formApi.updateSchema([ + { + componentProps: { options, placeholder }, + fieldName: 'postIds', + }, + ]); +} + /** * 初始化部门选择 */ @@ -80,22 +98,7 @@ async function setupDeptSelect() { getPopupContainer, async onSelect(deptId: number | string) { /** 根据部门ID加载岗位 */ - const postListResp = await postOptionSelect(deptId); - const options = postListResp.map((item) => ({ - label: item.postName, - value: item.postId, - })); - const placeholder = - options.length > 0 ? '请选择' : '该部门下暂无岗位'; - /** - * TODO: 可以考虑加上post编码 - */ - formApi.updateSchema([ - { - componentProps: { options, placeholder }, - fieldName: 'postIds', - }, - ]); + await setupPostOptions(deptId); /** 变化后需要重新选择岗位 */ formModel.postIds = []; }, @@ -185,6 +188,8 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({ // 添加角色和岗位 formApi.setFieldValue('postIds', postIds), formApi.setFieldValue('roleIds', roleIds), + // 更新时不会触发onSelect 需要手动调用 + setupPostOptions(user.deptId), ]); } drawerApi.drawerLoading(false);