diff --git a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.test.tsx b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.test.tsx index 19e7a920..f2f962c9 100644 --- a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.test.tsx +++ b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.test.tsx @@ -106,4 +106,55 @@ describe('SupplierManagementClient supply assurance', () => { expect(await screen.findByRole('button', { name: '能力画像' })).toBeInTheDocument() expect(screen.queryByRole('button', { name: '风险清单' })).not.toBeInTheDocument() }) + + it('collapses and expands the high-cost category details', async () => { + global.fetch = jest.fn().mockResolvedValue({ + ok: true, + json: async () => ({ + success: true, + data: [{ + supplierName: '高成本供应商', + supplierCode: 'SUP-HIGH', + grade: 'D', + gradeLabel: '成本显著偏高', + deviationRate: 0.2, + coverageRate: 1, + productCount: 5, + validPriceCount: 5, + categories: [{ + category: '板式 / 书桌', + productCount: 5, + validPriceCount: 5, + supplierMedianPrice: 120, + categoryBenchmarkPrice: 100, + deviationRate: 0.2, + grade: 'D', + }], + }], + }), + }) as Response + + const store = createLegacySupplierStore() + store.capabilities = [capability('SUP-HIGH', '高成本供应商', '开料')] + render( + , + ) + + fireEvent.click(screen.getByRole('button', { name: '采购成本评估' })) + await waitFor(() => expect(screen.getByRole('button', { name: '收合明细' })).toBeInTheDocument()) + expect(document.getElementById('high-cost-category-details')).toBeInTheDocument() + + fireEvent.click(screen.getByRole('button', { name: '收合明细' })) + expect(screen.getByRole('button', { name: '展开明细' })).toHaveAttribute('aria-expanded', 'false') + expect(document.getElementById('high-cost-category-details')).not.toBeInTheDocument() + + fireEvent.click(screen.getByRole('button', { name: '展开明细' })) + expect(screen.getByRole('button', { name: '收合明细' })).toHaveAttribute('aria-expanded', 'true') + expect(document.getElementById('high-cost-category-details')).toBeInTheDocument() + }) }) diff --git a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.tsx b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.tsx index ae92e2e9..c5dad4b2 100644 --- a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.tsx +++ b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/SupplierManagementClient.tsx @@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'react' import Link from 'next/link' -import { Download, FileUp, Search } from 'lucide-react' +import { ChevronDown, ChevronUp, Download, FileUp, Search } from 'lucide-react' import type { LegacySupplierCapabilityRecord, LegacySupplierEquipmentRecord, @@ -209,6 +209,7 @@ export function SupplierManagementClient({ const [costAssessments, setCostAssessments] = useState([]) const [costLoading, setCostLoading] = useState(true) const [costError, setCostError] = useState('') + const [highCostExpanded, setHighCostExpanded] = useState(true) const [analysisTab, setAnalysisTab] = useState('capability') const [query, setQuery] = useState('') const [category, setCategory] = useState('all') @@ -509,8 +510,30 @@ export function SupplierManagementClient({
-

高成本材质 / 类目

优先复核采购价高于同材质、同二级类目基准的产品

{highCostCategories.length} 项
-
{highCostCategories.slice(0, 50).map(({ profile, category }) => )}
供应商材质 / 二级类目采购价中位同业基准偏差等级
{profile.supplier}{category.category}{category.supplierMedianPrice?.toFixed(2) || '—'}{category.categoryBenchmarkPrice?.toFixed(2) || '—'}{costDeviation(category.deviationRate)}{category.grade}
+
+

高成本材质 / 类目

优先复核采购价高于同材质、同二级类目基准的产品

+
+ {highCostCategories.length} 项 + +
+
+ {highCostExpanded ? ( +
+ + + {highCostCategories.slice(0, 50).map(({ profile, category }) => )} +
供应商材质 / 二级类目采购价中位同业基准偏差等级
{profile.supplier}{category.category}{category.supplierMedianPrice?.toFixed(2) || '—'}{category.categoryBenchmarkPrice?.toFixed(2) || '—'}{costDeviation(category.deviationRate)}{category.grade}
+
+ ) : null}
diff --git a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/legacy-purchase-modules.module.css b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/legacy-purchase-modules.module.css index 3b29db75..9f89f9bb 100644 --- a/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/legacy-purchase-modules.module.css +++ b/furniture-3d-system/src/app/supply-chain/purchase/legacy-modules/legacy-purchase-modules.module.css @@ -137,6 +137,24 @@ .panelHeader h2 { margin: 0; color: #27272a; font-size: 13px; } .panelHeader p { margin: 4px 0 0; color: #8b8b92; font-size: 10px; } +.panelHeaderActions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; } +.compactButton { + display: inline-flex; + height: 28px; + align-items: center; + justify-content: center; + gap: 5px; + border: 1px solid #d4d4d8; + border-radius: 6px; + background: #fff; + padding: 0 9px; + color: #3f3f46; + font: inherit; + font-size: 11px; + font-weight: 600; + cursor: pointer; +} +.compactButton:hover { border-color: #a1a1aa; background: #fafafa; } .toolbar { border-bottom: 1px solid #e4e4e7;