From c63ec96dab5fc7c2cd26f05a42e4fc2dc15ad9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=9E=97=E9=93=96?= Date: Sat, 1 Aug 2026 09:11:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=86=E5=88=AB=E6=97=A0=E9=82=AA?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=B4=A6=E5=8F=B7=E5=88=A0=E9=99=A4=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PerformanceSurveyDashboardNavigation.test.tsx | 2 +- app/performance-survey/[[...path]]/page.tsx | 3 ++- .../performance-survey-service-policy.test.ts | 15 +++++++++++++-- lib/performance-survey-service.ts | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/performance-survey/PerformanceSurveyDashboardNavigation.test.tsx b/app/performance-survey/PerformanceSurveyDashboardNavigation.test.tsx index c6d2677..3a7aafe 100644 --- a/app/performance-survey/PerformanceSurveyDashboardNavigation.test.tsx +++ b/app/performance-survey/PerformanceSurveyDashboardNavigation.test.tsx @@ -535,7 +535,7 @@ describe('考核调研顶层导航保护', () => { }) test('公共看板仅按后端权限在分数下显示删除按钮并彻底删除单项调研', async () => { - mockSearchParams = new URLSearchParams('tab=public&workspace=pending') + mockSearchParams = new URLSearchParams('tab=public&workspace=pending&month=2026-07') let dashboardRequestCount = 0 const deleteRequests: Array<{ url: string; init?: RequestInit }> = [] global.fetch = jest.fn(async (input, init) => { diff --git a/app/performance-survey/[[...path]]/page.tsx b/app/performance-survey/[[...path]]/page.tsx index fec2822..6ec4b2d 100644 --- a/app/performance-survey/[[...path]]/page.tsx +++ b/app/performance-survey/[[...path]]/page.tsx @@ -1105,7 +1105,8 @@ function PerformanceDashboardBoard({ canCreateSurvey?: boolean }) { const router = useRouter() - const [month, setMonth] = useState(getCurrentMonthValue()) + const searchParams = useSearchParams() + const [month, setMonth] = useState(searchParams.get('month') || getCurrentMonthValue()) const [department, setDepartment] = useState('') const [employee, setEmployee] = useState(null) const [positionGroupCode, setPositionGroupCode] = useState('') diff --git a/lib/__tests__/performance-survey-service-policy.test.ts b/lib/__tests__/performance-survey-service-policy.test.ts index 44439e3..34424c7 100644 --- a/lib/__tests__/performance-survey-service-policy.test.ts +++ b/lib/__tests__/performance-survey-service-policy.test.ts @@ -457,7 +457,7 @@ describe('performance survey service policies', () => { expect(result.permissions.canDeletePublicDashboardAssessment).toBe(false) }) - test('只有无邪账号获得公共看板人员移除权限', async () => { + test('只有无邪账号获得公共看板单项调研删除权限', async () => { ;(prisma.user.findUnique as jest.Mock).mockResolvedValue({ ...baseUser, username: 'wuxie', @@ -470,6 +470,17 @@ describe('performance survey service policies', () => { expect(result.permissions.canDeletePublicDashboardAssessment).toBe(true) + ;(prisma.user.findUnique as jest.Mock).mockResolvedValue({ + ...baseUser, + username: '无邪', + }) + + const productionAccountResult = await getPerformanceSurveyDashboard(session, new URLSearchParams({ + view: 'public', + month: '2026-07', + })) + expect(productionAccountResult.permissions.canDeletePublicDashboardAssessment).toBe(true) + ;(prisma.user.findUnique as jest.Mock).mockResolvedValue({ ...baseUser, username: 'qingyun', @@ -491,7 +502,7 @@ describe('performance survey service policies', () => { test('无邪可按人员、月份、岗位和考核项彻底删除调研并释放重复校验', async () => { ;(prisma.user.findUnique as jest.Mock).mockResolvedValue({ ...baseUser, - username: 'wuxie', + username: '无邪', realName: '无邪', }) transactionClient.performanceSurveyTarget.findMany.mockResolvedValue([{ diff --git a/lib/performance-survey-service.ts b/lib/performance-survey-service.ts index f7113d1..b16b4d3 100644 --- a/lib/performance-survey-service.ts +++ b/lib/performance-survey-service.ts @@ -881,7 +881,8 @@ function ensureSystemAdministrator(ctx: UserContext) { } function canDeletePerformanceSurveyPublicDashboardAssessment(ctx: UserContext) { - return ctx.user.username.trim().toLowerCase() === 'wuxie' + const username = ctx.user.username.trim().toLowerCase() + return username === 'wuxie' || username === '无邪' } function ensureCanDeletePerformanceSurveyPublicDashboardAssessment(ctx: UserContext) {