accountManagementAccess.ts
818 Bytes
/**
* Account Management:公司 / 区域 / 角色 / 门店 的结构类「新增、编辑、门店批量编辑」等,
* 仅平台管理员可操作(与 Yi.Framework.Rbac UserConst 约定一致)。
*/
export function canMutateAccountManagementStructure(params: {
roleCodes?: string[] | null;
permissionCodes?: string[] | null;
userName?: string | null;
}): boolean {
const un = (params.userName ?? "").trim().toLowerCase();
if (un === "admin") return true;
for (const p of params.permissionCodes ?? []) {
const t = (p ?? "").trim();
if (t === "*:*:*" || t === "*") return true;
}
const adminRoles = new Set(["admin", "ccadmin"]);
for (const r of params.roleCodes ?? []) {
const t = (r ?? "").trim().toLowerCase();
if (adminRoles.has(t)) return true;
}
return false;
}