fix(installation-demo): route customer service through node permissions

删除安装演示权限里硬编码的客服强制只读分享口径:原 isCustomerServiceUser
(CUSTOMER_SERVICE 角色或部门路径含客服中心)直接返回 canEdit=false 且排在
节点权限 overrides 之前,导致正式站给客服配置的编辑权限永远无效,客服只能
查看和分享、无法新建编辑截取。

删除后客服与普通员工一致走节点权限配置:客服主体 customerService
(部门路径含客服中心),正式站已配置的编辑权限即刻生效,可新建图纸、
维护编号、截取、分享与下载。
This commit is contained in:
WuYongJie 2026-09-12 14:24:58 +08:00
parent aaa9c74eec
commit d9d1b39d1c
2 changed files with 20 additions and 30 deletions

View File

@ -26,17 +26,27 @@ describe('installation demo workbench permissions', () => {
})
})
it('lets customer service view and share the workbench without edit access', () => {
expect(
getInstallationDemoWorkbenchAccess({
it('routes customer service through node permissions instead of a forced read-only mode', () => {
const user = {
role: 'USER',
businessRoles: ['CUSTOMER_SERVICE'],
departmentPaths: ['江苏简尚品牌管理有限公司 > 客服中心'],
}
// 旧口径已删除:客服不再被硬编码拦成只读分享,与普通员工同样走权限配置。
expect(getInstallationDemoWorkbenchAccess(user)).toMatchObject({
mode: 'hidden',
canView: false,
canEdit: false,
canShare: false,
})
expect(
getInstallationDemoWorkbenchAccess(user, {
'installationDemoWorkbench:customerService:edit': true,
}),
).toMatchObject({
mode: 'share',
mode: 'full',
canView: true,
canEdit: false,
canEdit: true,
canShare: true,
})
})

View File

@ -27,21 +27,6 @@ function isInstallationDemoWorkspaceManager(user: InstallationDemoWorkbenchPermi
return user.role === 'SUPER_ADMIN' || user.role === 'ADMIN' || user.role === 'SUPERVISOR'
}
function normalizeDepartmentPath(value: unknown) {
return typeof value === 'string' ? value.trim().replace(/\s+/g, '') : ''
}
function isCustomerServiceUser(user: InstallationDemoWorkbenchPermissionUser) {
if (user.businessRoles?.includes('CUSTOMER_SERVICE')) return true
return [
user.department?.fullPath,
user.department?.name,
...(user.departmentPaths ?? []),
]
.map(normalizeDepartmentPath)
.some((path) => /客服中心/.test(path))
}
export function getInstallationDemoWorkbenchAccess(
user: InstallationDemoWorkbenchPermissionUser | null | undefined,
overrides?: IntakeNodePermissionOverrideMap,
@ -64,14 +49,9 @@ export function getInstallationDemoWorkbenchAccess(
}
}
if (isCustomerServiceUser(user)) {
return {
mode: 'share',
canView: true,
canEdit: false,
canShare: true,
}
}
// 客服与其他普通员工一样走节点权限配置(正式站已为客服开通编辑权限)。
// 旧的"客服强制只读分享"硬编码口径已删除:它排在 overrides 之前,
// 会拦住正式站给客服配置的编辑权限,导致客服只能看和分享、无法操作。
if (overrides) {
const nodeAccess = resolveIntakeNodePermissionAccess(