推送/操作日志下载改location.href;移动组关闭自动select;所在组改单选
This commit is contained in:
@@ -104,22 +104,26 @@ async function open(row: any, groups: any[], curGroupId?: number | null, onSucce
|
||||
}
|
||||
|
||||
// 3) 已绑定角色 -> appRoles 回填(相互独立)
|
||||
// 所在组(只读)默认选中「当前组」:优先用进入编辑时的左侧树/列表组(curGroupId),否则取用户所属组的第一个
|
||||
const defaultGroupId = (curGroupId != null && userGroupIdsArr.value.includes(curGroupId))
|
||||
? curGroupId
|
||||
: (userGroupIdsArr.value[0] ?? null);
|
||||
try {
|
||||
const userRolesResp = await Apis.GroupAuthz.userRoles({ params: { userId: row.id } });
|
||||
const userRoleIds: number[] = (Array.isArray(userRolesResp) ? userRolesResp : [])
|
||||
.map((r: any) => r.id)
|
||||
.filter((x: any): x is number => x != null);
|
||||
userRolesLoaded.value = true;
|
||||
detailData.value = buildInitForm(row, userRoleIds, userGroupIdsArr.value);
|
||||
detailData.value = buildInitForm(row, userRoleIds, defaultGroupId);
|
||||
} catch (e: any) {
|
||||
// 已绑定角色加载失败:仍回填其它字段,但标记未加载成功(提交时不回写,避免误清空)
|
||||
detailData.value = buildInitForm(row, [], userGroupIdsArr.value);
|
||||
detailData.value = buildInitForm(row, [], defaultGroupId);
|
||||
Message.error('加载用户已绑定角色失败:' + (e?.message || '未知错误'));
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 把行数据映射成表单回填数据 ---------- */
|
||||
function buildInitForm(row: any, userRoleIds: number[], userGroupIds: number[] = []) {
|
||||
function buildInitForm(row: any, userRoleIds: number[], defaultGroupId: number | null = null) {
|
||||
const roles: number[] = Array.isArray(row.roles) ? row.roles : [];
|
||||
// 用户身份(业务身份)= 1..7;角色属性已移除(超管手动入库、管理员走勾选)
|
||||
const userType = roles.filter(r => r >= 1 && r <= 7);
|
||||
@@ -135,7 +139,7 @@ function buildInitForm(row: any, userRoleIds: number[], userGroupIds: number[] =
|
||||
gender: row.gender ?? 0,
|
||||
userType,
|
||||
appRoles: userRoleIds || [],
|
||||
userGroupIds: userGroupIds || [],
|
||||
userGroupId: defaultGroupId ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user