From 685f3cc7568d595ed56a2b5f481df05e3a23ae31 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Thu, 8 Oct 2026 08:50:19 +0800 Subject: [PATCH] =?UTF-8?q?perf(supply-chain):=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E6=A1=A3=E6=A1=88=E8=A1=A8=E4=BD=93=E8=A1=8C?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=8C=96=EF=BC=88=E8=A7=86=E5=8F=A3=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=B8=B2=E6=9F=93+=E5=8D=A0=E4=BD=8D=E8=A1=8C?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductArchiveTableBody.tsx | 33 +++++++- .../product-archive/ProductArchiveView.tsx | 4 + .../useArchiveRowWindowing.test.ts | 47 ++++++++++++ .../product-archive/useArchiveRowWindowing.ts | 75 +++++++++++++++++++ 4 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 furniture-3d-system/src/app/supply-chain/database/product-archive/useArchiveRowWindowing.test.ts create mode 100644 furniture-3d-system/src/app/supply-chain/database/product-archive/useArchiveRowWindowing.ts diff --git a/furniture-3d-system/src/app/supply-chain/database/product-archive/ProductArchiveTableBody.tsx b/furniture-3d-system/src/app/supply-chain/database/product-archive/ProductArchiveTableBody.tsx index b56b420f..48af5e58 100644 --- a/furniture-3d-system/src/app/supply-chain/database/product-archive/ProductArchiveTableBody.tsx +++ b/furniture-3d-system/src/app/supply-chain/database/product-archive/ProductArchiveTableBody.tsx @@ -5,6 +5,7 @@ import type { ArchiveColumnGroup } from './columns' import { ProductArchiveActions } from './ProductArchiveActions' import { ProductArchiveMaterialImageCell } from './ProductArchiveMaterialImageCell' import type { ProductArchivePageImageState } from './useProductArchivePageImages' +import { ARCHIVE_ROW_HEIGHT, type ArchiveRowWindow } from './useArchiveRowWindowing' const IDLE_IMAGE_STATE: ProductArchivePageImageState = { status: 'idle', @@ -15,6 +16,8 @@ type ProductArchiveTableBodyProps = { rows: SupplyChainProductArchiveRow[] columns: ArchiveColumnGroup[] startIndex: number + /** 行虚拟化窗口:只渲染 [start, end) 的行,其余用占位行撑高。 */ + rowWindow: ArchiveRowWindow imageStates: Record onImageVisible: (archiveId: string) => void onPreviewImage: (image: string, title: string) => void @@ -57,6 +60,8 @@ function areTableBodyPropsEqual( return previous.rows === next.rows && previous.startIndex === next.startIndex + && previous.rowWindow.start === next.rowWindow.start + && previous.rowWindow.end === next.rowWindow.end && previous.onImageVisible === next.onImageVisible && previous.onPreviewImage === next.onPreviewImage && previous.onViewRow === next.onViewRow @@ -94,17 +99,29 @@ export const ProductArchiveTableBody = memo(function ProductArchiveTableBody({ rows, columns, startIndex, + rowWindow, imageStates, onImageVisible, onPreviewImage, onViewRow, onOpenChangeLog, }: ProductArchiveTableBodyProps) { + const columnCount = columns.reduce((count, group) => count + group.columns.length, 0) + const spacerColSpan = columnCount + 2 + const visibleRows = rows.slice(rowWindow.start, rowWindow.end) + const topPadHeight = rowWindow.start * ARCHIVE_ROW_HEIGHT + const bottomPadHeight = Math.max(0, rows.length - rowWindow.end) * ARCHIVE_ROW_HEIGHT + return ( - {rows.map((row, rowIndex) => ( + {topPadHeight > 0 && ( + + + + )} + {visibleRows.map((row, rowIndex) => ( - {startIndex + rowIndex + 1} + {startIndex + rowWindow.start + rowIndex + 1} {columns.map((group) => group.columns.map((column) => { const value = renderCell( @@ -139,12 +156,23 @@ export const ProductArchiveTableBody = memo(function ProductArchiveTableBody({ ))} + {bottomPadHeight > 0 && ( + + + + )}