fix: 用户管理 更新用户时打开drawer需要加载该部门下的岗位信息

This commit is contained in:
dap 2024-10-25 08:21:26 +08:00
parent 938ccd85f8
commit fb79029765
2 changed files with 22 additions and 16 deletions

View File

@ -20,6 +20,7 @@
- 岗位管理 部门参数错误
- 角色管理 菜单分配 节点独立下的回显及提交问题
- 租户管理 套餐管理 回显时候`已选中节点`数量为0
- 用户管理 更新用户时打开drawer需要加载该部门下的岗位信息
**OTHERS**

View File

@ -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);