update permission and product

This commit is contained in:
Timi
2026-09-04 23:07:59 +08:00
parent 1df5748f54
commit fc9e6a5023
48 changed files with 1670 additions and 2475 deletions
+23 -4
View File
@@ -15,7 +15,7 @@
>
<t-cell
:title="item.name"
:note="item.code"
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
arrow
hover
@click="router.push(`/management/permissions/roles/${item.id}`)"
@@ -53,6 +53,7 @@ const permissionStore = usePermissionSettingsStore();
const userStore = useUserStore();
const isRefreshing = ref(false);
const deletableRoleIdSet = ref(new Set<string>());
const directRoleIdSet = ref(new Set<string>());
// ---------- 顶部导航 ----------
@@ -93,6 +94,15 @@ function canDeleteRole(role: Role): boolean {
return role.builtin !== true && role.protectedRole !== true && deletableRoleIdSet.value.has(role.id);
}
function getRoleScopeLabel(role: Role): string {
const direct = directRoleIdSet.value.has(role.id);
const manageable = deletableRoleIdSet.value.has(role.id);
if (direct && manageable) {
return "直属且可管理";
}
return direct ? "直属角色" : "可管理角色";
}
// ---------- 页面数据 ----------
async function refresh(): Promise<void> {
@@ -155,10 +165,19 @@ async function refreshAuthorizationScope(): Promise<void> {
}
try {
const roleList = await permissionStore.loadManageableRoles();
displayRoleList.value = roleList;
deletableRoleIdSet.value = new Set(roleList.map(item => item.id).filter((id): id is string => Boolean(id)));
const [manageableRoleList, currentRoleList] = await Promise.all([
permissionStore.loadManageableRoles(),
permissionStore.loadCurrentRoleDetails()
]);
const roleMap = new Map<string, Role>();
for (const role of [...currentRoleList, ...manageableRoleList]) {
roleMap.set(role.id, role);
}
displayRoleList.value = Array.from(roleMap.values());
directRoleIdSet.value = new Set(currentRoleList.map(item => item.id).filter((id): id is string => Boolean(id)));
deletableRoleIdSet.value = new Set(manageableRoleList.map(item => item.id).filter((id): id is string => Boolean(id)));
} catch {
directRoleIdSet.value = new Set<string>();
deletableRoleIdSet.value = new Set<string>();
}
}