115 lines
3.7 KiB
TypeScript
115 lines
3.7 KiB
TypeScript
/** 角色与权限配置。后端会对每个请求再次执行同一角色边界校验。 */
|
|
|
|
export type RoleKey = 'admin' | 'manager' | 'sales' | 'service' | 'viewer'
|
|
|
|
export type Permission =
|
|
| 'customer:view'
|
|
| 'customer:edit'
|
|
| 'customer:delete'
|
|
| 'customer:export'
|
|
| 'customer:assign'
|
|
| 'message:send'
|
|
| 'conversation:view-all'
|
|
| 'opportunity:manage'
|
|
| 'task:manage'
|
|
| 'risk:handle'
|
|
| 'analytics:view'
|
|
| 'channel:manage'
|
|
| 'knowledge:manage'
|
|
| 'team:manage'
|
|
| 'billing:manage'
|
|
| 'settings:manage'
|
|
|
|
export const ROLE_META: Record<RoleKey, { label: string; description: string; color: string }> = {
|
|
admin: { label: '企业管理员', description: '管理企业、成员、权限、渠道、套餐与系统设置', color: 'bg-violet-100 text-violet-700' },
|
|
manager: { label: '业务主管', description: '查看全部客户、团队数据、经营看板与客户分配', color: 'bg-blue-100 text-blue-700' },
|
|
sales: { label: '外贸业务员', description: '查看分配给自己的客户、消息与跟进任务', color: 'bg-teal-100 text-teal-700' },
|
|
service: { label: '客服人员', description: '处理跨渠道消息、翻译、AI回复与售后咨询', color: 'bg-amber-100 text-amber-700' },
|
|
viewer: { label: '只读成员', description: '仅可查看被授权的数据,不能编辑或发送消息', color: 'bg-gray-100 text-gray-600' },
|
|
}
|
|
|
|
const ALL: Permission[] = [
|
|
'customer:view',
|
|
'customer:edit',
|
|
'customer:delete',
|
|
'customer:export',
|
|
'customer:assign',
|
|
'message:send',
|
|
'conversation:view-all',
|
|
'opportunity:manage',
|
|
'task:manage',
|
|
'risk:handle',
|
|
'analytics:view',
|
|
'channel:manage',
|
|
'knowledge:manage',
|
|
'team:manage',
|
|
'billing:manage',
|
|
'settings:manage',
|
|
]
|
|
|
|
export const ROLE_PERMISSIONS: Record<RoleKey, Permission[]> = {
|
|
admin: ALL,
|
|
manager: [
|
|
'customer:view',
|
|
'customer:edit',
|
|
'customer:export',
|
|
'customer:assign',
|
|
'message:send',
|
|
'conversation:view-all',
|
|
'opportunity:manage',
|
|
'task:manage',
|
|
'risk:handle',
|
|
'analytics:view',
|
|
'channel:manage',
|
|
'knowledge:manage',
|
|
],
|
|
sales: ['customer:view', 'customer:edit', 'message:send', 'opportunity:manage', 'task:manage', 'risk:handle'],
|
|
service: ['customer:view', 'message:send', 'task:manage', 'risk:handle', 'knowledge:manage'],
|
|
viewer: ['customer:view', 'analytics:view'],
|
|
}
|
|
|
|
/** 权限点说明(用于权限矩阵展示) */
|
|
export const PERMISSION_GROUPS: { module: string; items: { key: Permission; label: string }[] }[] = [
|
|
{
|
|
module: '客户管理',
|
|
items: [
|
|
{ key: 'customer:view', label: '查看客户' },
|
|
{ key: 'customer:edit', label: '编辑客户' },
|
|
{ key: 'customer:delete', label: '删除客户' },
|
|
{ key: 'customer:export', label: '导出客户' },
|
|
{ key: 'customer:assign', label: '分配客户' },
|
|
],
|
|
},
|
|
{
|
|
module: '消息会话',
|
|
items: [
|
|
{ key: 'message:send', label: '发送消息' },
|
|
{ key: 'conversation:view-all', label: '查看全部会话' },
|
|
],
|
|
},
|
|
{
|
|
module: '商机与任务',
|
|
items: [
|
|
{ key: 'opportunity:manage', label: '管理商机' },
|
|
{ key: 'task:manage', label: '管理任务' },
|
|
],
|
|
},
|
|
{
|
|
module: '风险与数据',
|
|
items: [
|
|
{ key: 'risk:handle', label: '处理风险' },
|
|
{ key: 'analytics:view', label: '查看团队数据' },
|
|
],
|
|
},
|
|
{
|
|
module: '系统管理',
|
|
items: [
|
|
{ key: 'channel:manage', label: '管理渠道' },
|
|
{ key: 'knowledge:manage', label: '管理知识库' },
|
|
{ key: 'team:manage', label: '管理成员' },
|
|
{ key: 'billing:manage', label: '管理账单' },
|
|
{ key: 'settings:manage', label: '管理系统设置' },
|
|
],
|
|
},
|
|
]
|