修复(权限管理):统一 PM 系统导航与权限校验
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<el-icon><Suitcase /></el-icon>
|
||||
<span>{{ TEXT.menu.projectManagement }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="isAdmin" index="/admin/audit-logs">
|
||||
<el-menu-item v-if="canAccessAuditLogs" index="/admin/audit-logs">
|
||||
<el-icon><Document /></el-icon>
|
||||
<span>{{ TEXT.menu.auditLogs }}</span>
|
||||
</el-menu-item>
|
||||
@@ -55,7 +55,7 @@
|
||||
<span>{{ TEXT.menu.permissionManagement }}</span>
|
||||
</template>
|
||||
<el-menu-item index="/admin/permissions/system">系统级权限</el-menu-item>
|
||||
<el-menu-item index="/admin/permissions/project">项目权限配置</el-menu-item>
|
||||
<el-menu-item index="/admin/permissions/project">项目访问控制</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-menu-item-group>
|
||||
|
||||
@@ -414,6 +414,7 @@ import {
|
||||
} from "@element-plus/icons-vue";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import { getProjectRoutePermission, hasProjectPermission, projectRouteLandingPaths } from "../utils/projectRoutePermissions";
|
||||
import { isApiPermissionAllowed } from "../utils/apiPermissionValue";
|
||||
import { forceLogout, LOGOUT_REASON_MANUAL } from "../session/sessionManager";
|
||||
import { checkDesktopUpdateAndPrompt } from "../session/desktopUpdateManager";
|
||||
import {
|
||||
@@ -446,6 +447,12 @@ const isAdmin = computed(() => !!auth.user?.is_admin);
|
||||
const isCollapsed = ref(localStorage.getItem("ctms_sidebar_collapsed") === "1");
|
||||
const projectRole = computed(() => study.currentStudyRole || (study.currentStudy as any)?.role_in_study || "");
|
||||
const canAccessAdminPermissions = computed(() => isAdmin.value || projectRole.value === "PM");
|
||||
const canAccessAuditLogs = computed(() =>
|
||||
isAdmin.value || (
|
||||
projectRole.value === "PM" &&
|
||||
isApiPermissionAllowed(study.currentPermissions?.[projectRole.value]?.["audit_logs:read"])
|
||||
),
|
||||
);
|
||||
const canAccessProjectPath = (path: string) =>
|
||||
hasProjectPermission(study.currentPermissions, projectRole.value, getProjectRoutePermission(path), isAdmin.value);
|
||||
const canAccessAnyProjectPath = (paths: string[]) => paths.some((path) => canAccessProjectPath(path));
|
||||
@@ -844,7 +851,7 @@ const breadcrumbs = computed(() => {
|
||||
const items: any[] = [];
|
||||
|
||||
if (route.path.startsWith("/admin")) {
|
||||
// 顶级管理后台菜单(按权限过滤),供末级面包屑横跳
|
||||
// 顶级系统管理菜单(按权限过滤),供末级面包屑横跳
|
||||
const topItems: { label: string; path: string }[] = [];
|
||||
if (isAdmin.value) topItems.push({ label: TEXT.menu.accountManagement, path: "/admin/users" });
|
||||
topItems.push({ label: TEXT.menu.projectManagement, path: "/admin/projects" });
|
||||
@@ -856,10 +863,10 @@ const breadcrumbs = computed(() => {
|
||||
// 权限管理子页,供「权限管理」父级与末级横跳
|
||||
const permItems = [
|
||||
{ label: "系统级权限", path: "/admin/permissions/system" },
|
||||
{ label: "项目权限配置", path: "/admin/permissions/project" },
|
||||
{ label: "项目访问控制", path: "/admin/permissions/project" },
|
||||
];
|
||||
|
||||
// 首项「管理后台」为分组标签,不可点击
|
||||
// 首项「系统管理」为分组标签,不可点击
|
||||
items.push({ label: TEXT.menu.admin });
|
||||
|
||||
// 第二级:当前所属的顶级模块,带下拉横跳到其它顶级模块
|
||||
@@ -890,7 +897,7 @@ const breadcrumbs = computed(() => {
|
||||
}
|
||||
// 项目详情:项目名由 viewContext 作为末项提供,继续走通用逻辑
|
||||
} else {
|
||||
// 顶级页面:模块名带同级下拉,可在管理后台各模块间横跳
|
||||
// 顶级页面:模块名带同级下拉,可在系统管理各模块间横跳
|
||||
items.push({
|
||||
label: curTop?.label || (route.meta?.title as string),
|
||||
path: route.path,
|
||||
|
||||
Reference in New Issue
Block a user