统一项目角色与接口权限配置

This commit is contained in:
Cheng Zhou
2026-05-28 10:48:33 +08:00
parent 6d1c98bcae
commit 2c85742040
45 changed files with 2863 additions and 1329 deletions
@@ -6,8 +6,8 @@ const FALLBACK_ROLE_META: Record<string, { label: string; icon: string; desc: st
PM: { label: "PM", icon: "👑", desc: "项目负责人,统筹项目全局,协调进度、资源与关键决策。" },
CRA: { label: "CRA", icon: "📋", desc: "负责各中心临床监查执行,跟进现场质量、数据和问题闭环。" },
PV: { label: "PV", icon: "🔍", desc: "负责药物警戒相关工作,跟踪安全性事件并支持风险评估。" },
MEDICAL_REVIEW: { label: "QA", icon: "🏥", desc: "负责医学审核与稽查,关注质量风险、合规性和医学一致性。" },
IMP: { label: "CTA", icon: "📦", desc: "负责合同、药品及相关项目事务管理,保障执行支持与物资协同。" },
QA: { label: "QA", icon: "🏥", desc: "负责医学审核与稽查,关注质量风险、合规性和医学一致性。" },
CTA: { label: "CTA", icon: "📦", desc: "负责合同、药品及相关项目事务管理,保障执行支持与物资协同。" },
};
const templates = ref<PermissionTemplate[]>([]);
@@ -47,6 +47,24 @@ export const useRoleTemplateMeta = () => {
desc: roleDescription(role),
}));
const roleOrder = computed(() => {
const result: Record<string, number> = {};
templates.value.forEach((template, index) => {
if (template.category && result[template.category] === undefined) {
result[template.category] = index;
}
});
return result;
});
const compareRolesByTemplateOrder = (a: string, b: string) => {
const order = roleOrder.value;
const aOrder = order[a] ?? Number.MAX_SAFE_INTEGER;
const bOrder = order[b] ?? Number.MAX_SAFE_INTEGER;
if (aOrder !== bOrder) return aOrder - bOrder;
return a.localeCompare(b);
};
const loadRoleTemplates = async () => {
if (pendingLoad) return pendingLoad;
loading.value = true;
@@ -69,6 +87,7 @@ export const useRoleTemplateMeta = () => {
roleDescription,
roleIcon,
roleOptionsFor,
compareRolesByTemplateOrder,
loadRoleTemplates,
};
};