fix(c0): 接线业务 RBAC 与补齐服务机构设置菜单

- APIS 登记 agency/staff/svc-org 业务接口资源(code=权限码)
- syncTenantResources 为业务租户预置 5 个业务角色并授权
- MENUS 补齐 svc-config-loc(属地与目录)与 svc-config-docking(对接档位)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
liuyun 2026-10-14 13:47:55 +08:00
parent 945fe5daa3
commit aa95586a55

View File

@ -27,9 +27,11 @@ export const MENUS = [
{ code: 'document', name: '文书档案', parent: 'ltc', path: '/ltc/document', component: 'ltc/document/index', icon: 'mdi:file-document', sort: 5 }, { code: 'document', name: '文书档案', parent: 'ltc', path: '/ltc/document', component: 'ltc/document/index', icon: 'mdi:file-document', sort: 5 },
{ code: 'svc-config', name: '服务机构设置', parent: 'ltc', path: '/ltc/config', component: 'Layout', icon: 'mdi:cog', sort: 6 }, { code: 'svc-config', name: '服务机构设置', parent: 'ltc', path: '/ltc/config', component: 'Layout', icon: 'mdi:cog', sort: 6 },
{ code: 'svc-config-info', name: '机构信息', parent: 'svc-config', path: '/ltc/config/info', component: 'ltc/config/info/index', icon: 'mdi:office-building', sort: 1 }, { code: 'svc-config-info', name: '机构信息', parent: 'svc-config', path: '/ltc/config/info', component: 'ltc/config/info/index', icon: 'mdi:office-building', sort: 1 },
{ code: 'svc-config-catalog', name: '服务项目与配价', parent: 'svc-config', path: '/ltc/config/catalog', component: 'ltc/config/catalog/index', icon: 'mdi:format-list-bulleted', sort: 2 }, { code: 'svc-config-loc', name: '属地与目录', parent: 'svc-config', path: '/ltc/config/loc', component: 'ltc/config/loc/index', icon: 'mdi:map-marker', sort: 2 },
{ code: 'svc-config-photo', name: '拍照分档配置', parent: 'svc-config', path: '/ltc/config/photo', component: 'ltc/config/photo/index', icon: 'mdi:camera', sort: 3 }, { code: 'svc-config-catalog', name: '服务项目与配价', parent: 'svc-config', path: '/ltc/config/catalog', component: 'ltc/config/catalog/index', icon: 'mdi:format-list-bulleted', sort: 3 },
{ code: 'svc-config-qc', name: '质控提醒配置', parent: 'svc-config', path: '/ltc/config/qc', component: 'ltc/config/qc/index', icon: 'mdi:bell-alert', sort: 4 }, { code: 'svc-config-photo', name: '拍照分档配置', parent: 'svc-config', path: '/ltc/config/photo', component: 'ltc/config/photo/index', icon: 'mdi:camera', sort: 4 },
{ code: 'svc-config-qc', name: '质控提醒配置', parent: 'svc-config', path: '/ltc/config/qc', component: 'ltc/config/qc/index', icon: 'mdi:bell-alert', sort: 5 },
{ code: 'svc-config-docking', name: '对接档位', parent: 'svc-config', path: '/ltc/config/docking', component: 'ltc/config/docking/index', icon: 'mdi:swap-horizontal', sort: 6 },
]; ];
/** 接口资源(每个受控接口一个,code = 权限码)。 */ /** 接口资源(每个受控接口一个,code = 权限码)。 */
@ -77,6 +79,18 @@ export const APIS: { code: string; name: string; method: string; path: string; p
{ code: Permissions.notice.create, name: '创建通知', method: 'POST', path: '/api/v1/notices', parent: 'notice' }, { code: Permissions.notice.create, name: '创建通知', method: 'POST', path: '/api/v1/notices', parent: 'notice' },
{ code: Permissions.notice.update, name: '更新通知', method: 'PATCH', path: '/api/v1/notices/:id', parent: 'notice' }, { code: Permissions.notice.update, name: '更新通知', method: 'PATCH', path: '/api/v1/notices/:id', parent: 'notice' },
{ code: Permissions.notice.delete, name: '删除通知', method: 'DELETE', path: '/api/v1/notices/:id', parent: 'notice' }, { code: Permissions.notice.delete, name: '删除通知', method: 'DELETE', path: '/api/v1/notices/:id', parent: 'notice' },
// 服务机构端业务(C0)
{ code: Permissions.agency.view, name: '查看机构信息', method: 'GET', path: '/api/v1/agency', parent: 'svc-config-info' },
{ code: Permissions.agency.update, name: '更新机构信息', method: 'PATCH', path: '/api/v1/agency', parent: 'svc-config-info' },
{ code: Permissions.staff.list, name: '人员列表', method: 'GET', path: '/api/v1/staff', parent: 'svc-config' },
{ code: Permissions.staff.create, name: '创建人员', method: 'POST', path: '/api/v1/staff', parent: 'svc-config' },
{ code: Permissions.staff.update, name: '更新人员', method: 'PATCH', path: '/api/v1/staff/:id', parent: 'svc-config' },
{ code: Permissions.staff.delete, name: '删除人员', method: 'DELETE', path: '/api/v1/staff/:id', parent: 'svc-config' },
{ code: Permissions.staff.groupAssign, name: '人员分组', method: 'POST', path: '/api/v1/staff/:id/group', parent: 'svc-config' },
{ code: Permissions.svcOrg.list, name: '属地目录列表', method: 'GET', path: '/api/v1/svc/local/list', parent: 'svc-config-loc' },
{ code: Permissions.svcOrg.list, name: '机构项目列表', method: 'GET', path: '/api/v1/svc/org/list', parent: 'svc-config-catalog' },
{ code: Permissions.svcOrg.config, name: '机构项目配置', method: 'POST', path: '/api/v1/svc/org/config', parent: 'svc-config-catalog' },
{ code: Permissions.svcOrg.newNational, name: '国家新增项', method: 'GET', path: '/api/v1/svc/org/new-national', parent: 'svc-config-loc' },
]; ];
/** 按钮资源(纯前端按钮,无独立受控接口)。 */ /** 按钮资源(纯前端按钮,无独立受控接口)。 */
@ -87,6 +101,40 @@ export const BUTTONS = [
{ code: 'login-log:export', name: '登录日志导出', parent: 'login-log' }, { code: 'login-log:export', name: '登录日志导出', parent: 'login-log' },
]; ];
/** 业务租户预置角色(C0:nurse/leader/qc/admin/director)及初始授权。 */
export const BUSINESS_ROLES: { code: string; name: string; permissions: string[] }[] = [
{ code: 'director', name: '院长', permissions: [Permissions.agency.view] },
{
code: 'admin',
name: '机构管理员',
permissions: [
Permissions.agency.view,
Permissions.agency.update,
Permissions.staff.list,
Permissions.staff.create,
Permissions.staff.update,
Permissions.staff.delete,
Permissions.staff.groupAssign,
Permissions.svcOrg.list,
Permissions.svcOrg.config,
Permissions.svcOrg.newNational,
],
},
{
code: 'qc',
name: '质控员',
permissions: [
Permissions.agency.view,
Permissions.staff.list,
Permissions.svcOrg.list,
Permissions.svcOrg.config,
Permissions.svcOrg.newNational,
],
},
{ code: 'leader', name: '组长', permissions: [Permissions.staff.list, Permissions.svcOrg.list] },
{ code: 'nurse', name: '护理员', permissions: [] },
];
/** 内置枚举字典(值对齐 enums.ts,仅展示层 label/颜色/排序可改)。 */ /** 内置枚举字典(值对齐 enums.ts,仅展示层 label/颜色/排序可改)。 */
export const DICTS: { code: string; name: string; items: { label: string; value: string; colorType: string; sort: number }[] }[] = [ export const DICTS: { code: string; name: string; items: { label: string; value: string; colorType: string; sort: number }[] }[] = [
{ code: 'common_status', name: '通用状态', items: [ { code: 'common_status', name: '通用状态', items: [
@ -194,6 +242,24 @@ export async function syncTenantResources(opts: SyncTenantResourcesOptions): Pro
create: { tenantCode, roleCode: adminRoleCode, resourceCode: code }, create: { tenantCode, roleCode: adminRoleCode, resourceCode: code },
}); });
} }
// 业务租户预置业务角色(nurse/leader/qc/admin/director)并授权(幂等)
if (!includePlatformPerms) {
for (const r of BUSINESS_ROLES) {
await prisma.role.upsert({
where: { tenantCode_code: { tenantCode, code: r.code } },
update: {},
create: { tenantCode, code: r.code, name: r.name, dataScope: 'all', status: 'enabled' },
});
for (const code of r.permissions) {
await prisma.roleResource.upsert({
where: { tenantCode_roleCode_resourceCode: { tenantCode, roleCode: r.code, resourceCode: code } },
update: {},
create: { tenantCode, roleCode: r.code, resourceCode: code },
});
}
}
}
} }
/** 初始化一个租户:根组织、顶层角色、管理员、全量资源、内置字典、授权(幂等)。 */ /** 初始化一个租户:根组织、顶层角色、管理员、全量资源、内置字典、授权(幂等)。 */