推送/操作日志下载改location.href;移动组关闭自动select;所在组改单选

This commit is contained in:
chenxing
2026-08-18 00:04:08 +08:00
parent 58a606764b
commit 8fd5a21fcc
7 changed files with 37 additions and 33 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
</div>
<div class="move-row move-label">移动至:</div>
<GroupTreeSearchPanel v-if="visible" v-model:curTreeNode="selectedNode" :treeApi="moveTreeApi"
:defaultSearchVisible="true" :showCloseButton="false" @on-change="onPickTarget" />
:autoSelect="false" :defaultSearchVisible="true" :showCloseButton="false" @on-change="onPickTarget" />
<div v-if="targetName" class="move-target">已选择目标:{{ targetName }}</div>
</div>
<template #footer>
@@ -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,
};
}
+3 -3
View File
@@ -57,11 +57,11 @@
</Col>
</Row>
<!-- 第 5 行:所在组(只读)(仅编辑展示,默认选中当前组;提交时不带 groupId,不改变所在组) -->
<!-- 第 5 行:所在组(只读)(仅编辑展示,普通单选、默认选中当前组;提交时不带 groupId,不改变所在组) -->
<Row v-if="isEdit">
<Col span="24">
<FormItem label="所在组(只读):">
<Select v-model="form.userGroupIds" multiple transfer
<Select v-model="form.userGroupId" transfer clearable
placeholder="默认选中当前组(提交不改变所在组)">
<Option v-for="g in userGroups" :key="g.id" :value="g.id" :label="g.name" />
</Select>
@@ -144,7 +144,7 @@ const defaultForm = (): Record<string, any> => ({
gender: 0,
userType: [] as number[],
appRoles: [] as number[],
userGroupIds: [] as number[],
userGroupId: null as number | null,
});
const form = reactive(defaultForm());