From d9d1b39d1ce2d53738166a9f7a1d0ee7fa7a5905 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Sat, 12 Sep 2026 14:24:58 +0800 Subject: [PATCH] fix(installation-demo): route customer service through node permissions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除安装演示权限里硬编码的客服强制只读分享口径:原 isCustomerServiceUser (CUSTOMER_SERVICE 角色或部门路径含客服中心)直接返回 canEdit=false 且排在 节点权限 overrides 之前,导致正式站给客服配置的编辑权限永远无效,客服只能 查看和分享、无法新建编辑截取。 删除后客服与普通员工一致走节点权限配置:客服主体 customerService (部门路径含客服中心),正式站已配置的编辑权限即刻生效,可新建图纸、 维护编号、截取、分享与下载。 --- ...llation-demo-workbench-permissions.test.ts | 24 ++++++++++++----- ...installation-demo-workbench-permissions.ts | 26 +++---------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/furniture-3d-system/src/lib/installation-demo-workbench-permissions.test.ts b/furniture-3d-system/src/lib/installation-demo-workbench-permissions.test.ts index a7ff799a..6f9c3e98 100644 --- a/furniture-3d-system/src/lib/installation-demo-workbench-permissions.test.ts +++ b/furniture-3d-system/src/lib/installation-demo-workbench-permissions.test.ts @@ -26,17 +26,27 @@ describe('installation demo workbench permissions', () => { }) }) - it('lets customer service view and share the workbench without edit access', () => { + 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({ - role: 'USER', - businessRoles: ['CUSTOMER_SERVICE'], - departmentPaths: ['江苏简尚品牌管理有限公司 > 客服中心'], + getInstallationDemoWorkbenchAccess(user, { + 'installationDemoWorkbench:customerService:edit': true, }), ).toMatchObject({ - mode: 'share', + mode: 'full', canView: true, - canEdit: false, + canEdit: true, canShare: true, }) }) diff --git a/furniture-3d-system/src/lib/installation-demo-workbench-permissions.ts b/furniture-3d-system/src/lib/installation-demo-workbench-permissions.ts index 2e66cfc6..d0471817 100644 --- a/furniture-3d-system/src/lib/installation-demo-workbench-permissions.ts +++ b/furniture-3d-system/src/lib/installation-demo-workbench-permissions.ts @@ -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(