diff --git a/components/department-dashboard/PerformanceConversionDashboard.test.tsx b/components/department-dashboard/PerformanceConversionDashboard.test.tsx index 993e8548..1fc1cb28 100644 --- a/components/department-dashboard/PerformanceConversionDashboard.test.tsx +++ b/components/department-dashboard/PerformanceConversionDashboard.test.tsx @@ -32,6 +32,7 @@ const workflowItem = { brand: '亿家达' as const, productId: '1041432226288', spu: 'SPU-001', + platform: '天猫', completedAt: '2026-07-12T08:00:00.000Z', monitorStartDate: '2026-07-12', monitorEndDate: '2027-01-12', @@ -134,6 +135,22 @@ describe('PerformanceConversionDashboard filters', () => { expect(detailUrl.searchParams.get('completedFrom')).toBe('2026-07-01') expect(detailUrl.searchParams.get('completedTo')).toBe('2026-07-31') expect(detailUrl.searchParams.get('page')).toBe('3') + expect(screen.getAllByText('平台 天猫')).toHaveLength(2) + expect(screen.queryByText(`实例 ${workflowItem.workflowId}`)).not.toBeInTheDocument() expect(fetchMock).not.toHaveBeenCalledWith(expect.stringContaining('/timeseries'), expect.anything()) }) + + it('shows an explicit placeholder when the workflow platform is missing', async () => { + global.fetch = jest.fn().mockResolvedValue({ + ok: true, + json: async () => ({ + success: true, + data: { ...emptyList, items: [{ ...workflowItem, platform: null }], total: 1 }, + }), + } as Response) + + render() + + expect(await screen.findAllByText('平台 —')).toHaveLength(2) + }) }) diff --git a/components/department-dashboard/PerformanceConversionDashboard.tsx b/components/department-dashboard/PerformanceConversionDashboard.tsx index 3b8c2f6d..62757c21 100644 --- a/components/department-dashboard/PerformanceConversionDashboard.tsx +++ b/components/department-dashboard/PerformanceConversionDashboard.tsx @@ -93,12 +93,12 @@ function WorkflowTable({ items, detailHref }: { 2026 年 4 月 1 日以后已完结美术流程关联的商品 ID 商品 ID审批编号完结时间监控区间状态 - {items.map((item) => {item.productId}{item.spu &&

SPU {item.spu}

}

{item.approvalNumber || '—'}

实例 {item.workflowId}

{formatDate(item.completedAt, true)}{item.monitorStartDate} 至 {item.monitorEndDate}{item.monitoringStatus === 'monitoring' ? '监控中' : '已满 6 个月'})} + {items.map((item) => {item.productId}

{item.spu && SPU {item.spu}}平台 {item.platform || '—'}

{item.approvalNumber || '—'}

{formatDate(item.completedAt, true)}{item.monitorStartDate} 至 {item.monitorEndDate}{item.monitoringStatus === 'monitoring' ? '监控中' : '已满 6 个月'})} ) diff --git a/components/department-dashboard/PerformanceConversionDetail.test.tsx b/components/department-dashboard/PerformanceConversionDetail.test.tsx index 1d9a4177..2db46293 100644 --- a/components/department-dashboard/PerformanceConversionDetail.test.tsx +++ b/components/department-dashboard/PerformanceConversionDetail.test.tsx @@ -17,6 +17,7 @@ const detailData = { brand: '亿家达' as const, productId: '1041432226288', spu: 'SPU-001', + platform: '天猫', completedAt: '2026-07-12T08:00:00.000Z', monitorStartDate: '2026-07-12', monitorEndDate: '2027-01-12', diff --git a/components/department-dashboard/performance-conversion.ts b/components/department-dashboard/performance-conversion.ts index d2adcb24..937712f4 100644 --- a/components/department-dashboard/performance-conversion.ts +++ b/components/department-dashboard/performance-conversion.ts @@ -30,6 +30,7 @@ export type PerformanceConversionWorkflowItem = { brand: PerformanceConversionBrand productId: string spu: string | null + platform: string | null completedAt: string monitorStartDate: string monitorEndDate: string diff --git a/lib/__tests__/performance-conversion-workflow-filter.test.ts b/lib/__tests__/performance-conversion-workflow-filter.test.ts index a6a37c52..276194bf 100644 --- a/lib/__tests__/performance-conversion-workflow-filter.test.ts +++ b/lib/__tests__/performance-conversion-workflow-filter.test.ts @@ -34,6 +34,7 @@ function snapshot( brand: string, sourceFinishedAtRaw: string, productId: string | null, + platform: string | null = '天猫', ) { return { processInstanceId, @@ -45,7 +46,7 @@ function snapshot( processCode: 'art-process', brand, sourceFinishedAtRaw, - formFields: productId ? { productId } : {}, + formFields: productId ? { productId, platform } : {}, syncedAt: new Date('2026-09-17T00:00:00.000Z'), } } @@ -71,6 +72,7 @@ describe('performance conversion completion date filters', () => { }) expect(result.items.map((item) => item.productId)).toEqual(['222222', '333333']) + expect(result.items.map((item) => item.platform)).toEqual(['天猫', '天猫']) expect(result.total).toBe(2) expect(result.invalidProductIdCount).toBe(1) expect(result.brands.find((item) => item.brand === '亿家达')?.count).toBe(2) @@ -82,6 +84,21 @@ describe('performance conversion completion date filters', () => { }) }) + it('returns the workflow platform for every product id and keeps missing values explicit', async () => { + findMany.mockResolvedValue([ + snapshot('multiple-ids', '亿家达', '2026-07-12T08:00:00.000Z', '111111, 222222', '京东'), + snapshot('missing-platform', '亿家达', '2026-07-11T08:00:00.000Z', '333333', null), + ]) + + const result = await getPerformanceConversionWorkflows(null, { brand: '亿家达' }) + + expect(result.items.map(({ productId, platform }) => ({ productId, platform }))).toEqual([ + { productId: '111111', platform: '京东' }, + { productId: '222222', platform: '京东' }, + { productId: '333333', platform: null }, + ]) + }) + it('rejects invalid or reversed date ranges before reading snapshots', async () => { await expect(getPerformanceConversionWorkflows(null, { completedFrom: '2026-02-29', diff --git a/lib/performance-conversion.ts b/lib/performance-conversion.ts index fe186578..83519acc 100644 --- a/lib/performance-conversion.ts +++ b/lib/performance-conversion.ts @@ -107,6 +107,7 @@ function workflowItems(row: SnapshotRow): PerformanceConversionWorkflowItem[] { brand: brand as PerformanceConversionBrand, productId, spu: clean(fields.spu), + platform: clean(fields.platform), completedAt, monitorStartDate, monitorEndDate,