fix(超管权限):超管也放开导入跨部门、课程审批等!
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s

This commit is contained in:
runny committed 2026-11-28 15:16:55 +08:00
1 parent 9d4092bc7f
commit 78e9787793
11 files changed
+489 -85

No files matched your search

+16 -6
View File
@@ -1260,27 +1260,37 @@ export const TRAINEE_LABEL = '学员'
/** 系统默认职称角色(与后端 DefaultRoleDict 一致;字典缺失/损坏时兜底)。
* 角色体系 v2:学员(隐式)/课长/经理/人事/讲师;经理继承课长全部权限并叠加审批决策。
* v2.1 增补超级管理员:不继承任何权限组,仅承载终态数据(已确认需求/已审核课程/
* 已发布计划)的删除权,组织架构「设置角色」可分配。 */
* v2.1 增补超级管理员;v2.2 起超级管理员继承全部权限组(人事/课长/讲师/经理),
* 审批、发布、查看等所有系统操作经权限展开自动放行,并保留终态数据删除权;
* 组织架构「设置角色」可分配。 */
export const DEFAULT_ROLE_DICT: TrainingRoleDef[] = [
{ key: 'hr', label: '人事', short: '人事', system: true },
{ key: 'supervisor', label: '课长', short: '课长', system: true },
{ key: 'lecturer', label: '讲师', short: '讲师', system: true },
{ key: 'exec', label: '经理', short: '经理', system: true, inherits: ['supervisor'] },
{ key: 'super_admin', label: '超级管理员', short: '超管', system: true },
{
key: 'super_admin',
label: '超级管理员',
short: '超管',
system: true,
inherits: ['hr', 'supervisor', 'lecturer', 'exec'],
},
]
/** 存量角色别名:部门文员(clerk)已移除,按课长对待(与后端 LegacyRoleAlias 同构) */
const LEGACY_ROLE_ALIAS: Record<string, string> = { clerk: 'supervisor' }
/** 角色体系升级判定(与后端 NeedsRoleDictUpgrade 同构):
* 经理(exec)未继承课长视为 v1 旧字典;v2 口径但缺 v2.1 增补的超级管理员
* 同样需要读时升级补齐(存量租户免迁移)。 */
* 经理(exec)未继承课长视为 v1 旧字典;v2 口径但缺 v2.1 增补的超级管理员、
* 或 v2.1 口径超级管理员未继承全部权限组,同样需要读时升级补齐(存量租户免迁移)。 */
export function needsRoleDictUpgrade(dict: TrainingRoleDef[]): boolean {
const mgr = dict.find((r) => r.key === 'exec')
if (!mgr) return true
if (!(mgr.inherits || []).includes('supervisor')) return true
return !dict.some((r) => r.key === 'super_admin')
const sa = dict.find((r) => r.key === 'super_admin')
if (!sa) return true
// v2.2:超级管理员须继承全部权限组(缺任一视为旧口径字典)
return !['hr', 'supervisor', 'lecturer', 'exec'].every((p) => (sa.inherits || []).includes(p))
}
/** v1 存量字典升级为 v2 视图(与后端 UpgradeRoleDictV2 同构,幂等):