PayrollManagementSystem/backend/app/services/permission_catalog.py
liuwenxin 1e53792ad6 feat(T+): 完成数据贯通与自动接入闭环
打通 T+ 快照、业务、发货、回款和核算准备链路,保留来源差异并提供待补状态。
新增业务自动接入任务、跨平台读取服务托管、权限复核、来源关联和前端核对页面。
补充迁移、隔离集成测试、浏览器模拟验收及角色授权边界修复。
2026-11-05 18:47:13 +08:00

81 lines
5.0 KiB
Python

"""权限目录随代码发布;菜单、按钮和 API 共用同一操作码。"""
MODULES = (
("dashboard", "工作台", "首页", ("view",)),
("system:users", "系统管理", "用户管理", ("view", "create", "update", "delete", "status", "password")),
("system:roles", "系统管理", "角色管理", ("view", "create", "update", "delete", "status")),
("system:business_roles", "系统管理", "计提岗位", ("view", "create", "update", "delete", "status")),
("system:params", "系统管理", "计提参数", ("view", "update", "withdraw", "export", "preview")),
("system:settings", "系统管理", "公司信息", ("view", "update")),
("system:logs", "系统管理", "日志查询", ("view",)),
("system:monitor", "系统管理", "系统监控", ("view", "export")),
("base:personnel", "基础资料", "人员管理", ("view", "create", "update", "delete", "status", "regions", "plans")),
("base:products", "基础资料", "产品管理", ("view", "create", "update", "delete", "status")),
("base:customers", "基础资料", "客户管理", ("view", "create", "update", "delete", "rating", "ownership")),
("business:businesses", "业务数据", "业务管理", ("view", "create", "update", "delete", "status", "ownership")),
("business:shipments", "业务数据", "发货管理", ("view", "create", "update", "delete")),
("business:receipts", "业务数据", "回款管理", ("view", "create", "update", "delete", "confirm")),
("business:ratings", "业务数据", "评级标准", ("view", "create", "update", "delete")),
("tplus", "T+ 对接", "采集与导入", ("view", "collect", "retry", "preview", "import", "facts", "export")),
("payroll", "绩效工资", "正式核算与分配", ("view", "prepare", "calculate", "allocation")),
("settlements", "绩效工资", "月度工资", ("view", "generate", "submit")),
("adjustments", "绩效工资", "工资调整", ("view", "create")),
("approvals", "绩效工资", "审核记录", ("view", "finance", "leader")),
("reports:business", "报表统计", "业务统计", ("view", "export")),
("reports:personal", "报表统计", "个人明细", ("view", "export")),
("reports:department", "报表统计", "部门汇总", ("view", "export")),
("reports:payments", "报表统计", "回款统计", ("view", "export")),
)
ACTION_NAMES = {
"confirm": "人工确认回款",
"view": "查看", "create": "新增", "update": "编辑", "delete": "删除",
"status": "变更状态", "password": "重置密码", "regions": "维护区域", "plans": "维护计划",
"rating": "客户评级", "ownership": "变更归属", "export": "导出", "preview": "预览",
"withdraw": "撤回参数", "collect": "创建采集", "retry": "重试采集", "import": "执行导入",
"facts": "维护补充资料", "prepare": "准备核算资料", "calculate": "核算与重算",
"allocation": "修改工资分配", "generate": "生成工资", "submit": "提交审核",
"finance": "财务复核", "leader": "领导审核",
}
CATALOG = {
f"{module}:{action}": {
"code": f"{module}:{action}", "module": module, "group": group,
"module_name": name, "name": ACTION_NAMES[action], "action": action,
"view_code": f"{module}:view", "admin_only": module in (
"system:users", "system:roles", "system:authorization", "system:monitor"
),
"maker_required": False,
}
for module, group, name, actions in MODULES for action in actions
}
MAKER_ROLE = "payroll_maker"
PAYROLL_WRITE_PERMISSIONS = frozenset(
code for code, item in CATALOG.items()
if item["module"] in ("payroll", "settlements", "adjustments") and item["action"] != "view"
)
MAKER_PERMISSIONS = {
code for code, item in CATALOG.items()
if code in PAYROLL_WRITE_PERMISSIONS or item["module"] in (
"base:personnel", "base:products", "base:customers", "business:businesses",
"business:shipments", "business:receipts", "business:ratings", "tplus",
) or (item["action"] == "view" and item["group"] in ("绩效工资", "报表统计"))
}
USER_PERMISSIONS = {
code for code, item in CATALOG.items()
if item["action"] == "view" and item["group"] in ("基础资料", "业务数据")
}
ROLE_DEFAULTS = {
"admin": set(CATALOG), "user": USER_PERMISSIONS,
"marketing_ops": USER_PERMISSIONS,
"finance": USER_PERMISSIONS | {
code for code, item in CATALOG.items()
if (item["action"] == "view" and item["group"] in ("绩效工资", "报表统计", "工作台"))
or (item["group"] == "报表统计" and item["action"] == "export")
} | {"approvals:finance", "system:params:view", "system:params:preview"},
"leader": USER_PERMISSIONS | {
code for code, item in CATALOG.items()
if (item["action"] == "view" and item["group"] in ("绩效工资", "报表统计", "工作台"))
or (item["group"] == "报表统计" and item["action"] == "export")
} | {"approvals:leader", "system:params:view", "system:params:preview"},
MAKER_ROLE: MAKER_PERMISSIONS,
}