diff --git a/furniture-3d-system/src/app/intake/non-integrated/NonIntegratedDetailClient.tsx b/furniture-3d-system/src/app/intake/non-integrated/NonIntegratedDetailClient.tsx index 92bd1a80..4c894edd 100644 --- a/furniture-3d-system/src/app/intake/non-integrated/NonIntegratedDetailClient.tsx +++ b/furniture-3d-system/src/app/intake/non-integrated/NonIntegratedDetailClient.tsx @@ -44,6 +44,7 @@ import { DocumentAttachmentWorkspace } from "./DocumentAttachmentWorkspace"; import { OpeningReferenceWorkspace } from "./OpeningReferenceWorkspace"; import { PatentApplicationWorkspace } from "./PatentApplicationWorkspace"; import { PlanningLayoutWorkspace } from "./PlanningLayoutWorkspace"; +import { ProductPricingWorkspace } from "./ProductPricingWorkspace"; import { ProjectReviewWorkspace } from "./ProjectReviewWorkspace"; import { ProductDataWorkspace } from "./ProductDataWorkspace"; import { QualityInspectionWorkspace } from "./QualityInspectionWorkspace"; @@ -18596,241 +18597,19 @@ export default function NonIntegratedDetailClient({ } function renderProductPricingWorkspace() { - const renderReadOnlyCell = (value: string) => ( -
- {value || "-"} -
- ); - const getVirtualInventoryStatusMeta = (row: ProductPricingDisplayRow) => { - const virtualInventorySkipTitle = - row.jstVirtualInventoryError || "无需推虚拟库存"; - const normalizedVirtualInventoryError = - row.jstVirtualInventoryError - ?.replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-") - .replace(/\s+/g, "") ?? ""; - const isVirtualInventorySkipReason = - normalizedVirtualInventoryError.includes("未包含成品代发仓-虚拟库存") || - normalizedVirtualInventoryError.includes("未命中成品代发仓-虚拟库存") || - normalizedVirtualInventoryError.includes("真实库存") || - normalizedVirtualInventoryError.includes("无需推虚拟库存"); - const skippedMeta = { - label: "无需库存", - tone: "bg-apple-bg-secondary text-apple-label-secondary", - title: virtualInventorySkipTitle, - }; - - switch (row.jstVirtualInventoryStatus) { - case "pending": - return { - label: "库存待推", - tone: "bg-[#e7f1ff] text-[#1764ad]", - title: row.jstVirtualInventoryScheduledAt - ? `计划 ${row.jstVirtualInventoryScheduledAt} 推送` - : "已生成虚拟库存待推送", - }; - case "pushed": - return { - label: "库存已推", - tone: "bg-[#dff7e8] text-[#137a38]", - title: row.jstVirtualInventoryPushedAt - ? `已于 ${row.jstVirtualInventoryPushedAt} 推送` - : "虚拟库存已推送", - }; - case "failed": - if (isVirtualInventorySkipReason) return skippedMeta; - return { - label: "库存失败", - tone: "bg-[#ffe3df] text-[#b42318]", - title: row.jstVirtualInventoryError || "虚拟库存推送失败", - }; - case "skipped": - return skippedMeta; - default: - return null; - } - }; - const adjustCostPrice = (row: ProductPricingDisplayRow, offset: number) => { - if (isReadOnly || isProductPricingNodeLocked) return; - const currentValue = Number(row.costPrice); - const nextValue = Math.max( - 0, - (Number.isFinite(currentValue) ? currentValue : 0) + offset, - ); - updateProductPricingRow(row.skuId, "costPrice", String(nextValue)); - }; - return ( -
-
-
- {renderInheritedSkuBatchTabs()} -
-
- -
- {productPricingRows.length === 0 ? ( -
- 当前还没有 SKU 信息,先维护 SKU 后再核价。 -
- ) : displayedProductPricingRows.length === 0 ? ( -
- 当前批次还没有 SKU 信息。 -
- ) : ( -
- - - - {[ - "型号", - "货号", - "条码", - "套件量", - "规格名称", - "供应商名称", - "成本价", - "是否录入系统", - ].map((label) => ( - - ))} - - - - {displayedProductPricingRows.map((row) => { - const isSystemEntered = - isProductPricingRowSystemEntered(row); - const pricingReadyForFuturePush = - row.costPrice.trim().length > 0; - const virtualInventoryStatusMeta = - getVirtualInventoryStatusMeta(row); - - return ( - - - - - - - - - - - ); - })} - -
- {label} -
- {renderReadOnlyCell(row.model)} - - {renderReadOnlyCell(row.skuCode)} - - {renderReadOnlyCell(row.barcode)} - - {renderReadOnlyCell(row.setCount)} - - {renderReadOnlyCell(row.specName)} - - {renderReadOnlyCell(row.supplierName)} - -
- - - updateProductPricingRow( - row.skuId, - "costPrice", - event.target.value, - ) - } - readOnly={isReadOnly || isProductPricingNodeLocked} - placeholder="0" - className="h-8 w-16 bg-transparent px-2 text-center outline-none placeholder:text-apple-label-tertiary" - /> - -
-
-
- - {isSystemEntered ? "已录入" : "未录入"} - - {virtualInventoryStatusMeta ? ( - - {virtualInventoryStatusMeta.label} - - ) : null} - {canUseProductPricingPushControls ? ( - - ) : null} -
-
-
- )} -
-
+ ); } - function renderArchiveFileTile({ file, isActive, diff --git a/furniture-3d-system/src/app/intake/non-integrated/ProductPricingWorkspace.tsx b/furniture-3d-system/src/app/intake/non-integrated/ProductPricingWorkspace.tsx new file mode 100644 index 00000000..f532db6d --- /dev/null +++ b/furniture-3d-system/src/app/intake/non-integrated/ProductPricingWorkspace.tsx @@ -0,0 +1,272 @@ +"use client"; + +import type { ReactNode } from "react"; +import type { NonIntegratedPricingRow } from "./nonIntegratedStorage"; +import { + isProductPricingRowSystemEntered, + PRODUCT_PRICING_JST_PUSH_ENABLED, + type ProductPricingDisplayRow, +} from "./productWorkflowRowHelpers"; + +type ProductPricingFieldKey = Exclude; + +type ProductPricingWorkspaceProps = { + allRows: ProductPricingDisplayRow[]; + displayedRows: ProductPricingDisplayRow[]; + inheritedSkuBatchTabs: ReactNode; + isReadOnly: boolean; + isNodeLocked: boolean; + canUsePushControls: boolean; + onUpdateRow: ( + skuId: string, + key: ProductPricingFieldKey, + value: string, + ) => void; + onConfirmPushRows: (rows: ProductPricingDisplayRow[]) => void | Promise; +}; + +function ReadOnlyCell({ value }: { value: string }) { + return ( +
+ {value || "-"} +
+ ); +} + +function getVirtualInventoryStatusMeta(row: ProductPricingDisplayRow) { + const virtualInventorySkipTitle = + row.jstVirtualInventoryError || "无需推虚拟库存"; + const normalizedVirtualInventoryError = + row.jstVirtualInventoryError + ?.replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-") + .replace(/\s+/g, "") ?? ""; + const isVirtualInventorySkipReason = + normalizedVirtualInventoryError.includes("未包含成品代发仓-虚拟库存") || + normalizedVirtualInventoryError.includes("未命中成品代发仓-虚拟库存") || + normalizedVirtualInventoryError.includes("真实库存") || + normalizedVirtualInventoryError.includes("无需推虚拟库存"); + const skippedMeta = { + label: "无需库存", + tone: "bg-apple-bg-secondary text-apple-label-secondary", + title: virtualInventorySkipTitle, + }; + + switch (row.jstVirtualInventoryStatus) { + case "pending": + return { + label: "库存待推", + tone: "bg-[#e7f1ff] text-[#1764ad]", + title: row.jstVirtualInventoryScheduledAt + ? `计划 ${row.jstVirtualInventoryScheduledAt} 推送` + : "已生成虚拟库存待推送", + }; + case "pushed": + return { + label: "库存已推", + tone: "bg-[#dff7e8] text-[#137a38]", + title: row.jstVirtualInventoryPushedAt + ? `已于 ${row.jstVirtualInventoryPushedAt} 推送` + : "虚拟库存已推送", + }; + case "failed": + if (isVirtualInventorySkipReason) return skippedMeta; + return { + label: "库存失败", + tone: "bg-[#ffe3df] text-[#b42318]", + title: row.jstVirtualInventoryError || "虚拟库存推送失败", + }; + case "skipped": + return skippedMeta; + default: + return null; + } +} + +export function ProductPricingWorkspace({ + allRows, + displayedRows, + inheritedSkuBatchTabs, + isReadOnly, + isNodeLocked, + canUsePushControls, + onUpdateRow, + onConfirmPushRows, +}: ProductPricingWorkspaceProps) { + const adjustCostPrice = (row: ProductPricingDisplayRow, offset: number) => { + if (isReadOnly || isNodeLocked) return; + const currentValue = Number(row.costPrice); + const nextValue = Math.max( + 0, + (Number.isFinite(currentValue) ? currentValue : 0) + offset, + ); + onUpdateRow(row.skuId, "costPrice", String(nextValue)); + }; + + return ( +
+
+
+ {inheritedSkuBatchTabs} +
+
+ +
+ {allRows.length === 0 ? ( +
+ 当前还没有 SKU 信息,先维护 SKU 后再核价。 +
+ ) : displayedRows.length === 0 ? ( +
+ 当前批次还没有 SKU 信息。 +
+ ) : ( +
+ + + + {[ + "型号", + "货号", + "条码", + "套件量", + "规格名称", + "供应商名称", + "成本价", + "是否录入系统", + ].map((label) => ( + + ))} + + + + {displayedRows.map((row) => { + const isSystemEntered = isProductPricingRowSystemEntered(row); + const pricingReadyForFuturePush = + row.costPrice.trim().length > 0; + const virtualInventoryStatusMeta = + getVirtualInventoryStatusMeta(row); + + return ( + + + + + + + + + + + ); + })} + +
+ {label} +
+ + + + + + + + + + + + +
+ + + onUpdateRow( + row.skuId, + "costPrice", + event.target.value, + ) + } + readOnly={isReadOnly || isNodeLocked} + placeholder="0" + className="h-8 w-16 bg-transparent px-2 text-center outline-none placeholder:text-apple-label-tertiary" + /> + +
+
+
+ + {isSystemEntered ? "已录入" : "未录入"} + + {virtualInventoryStatusMeta ? ( + + {virtualInventoryStatusMeta.label} + + ) : null} + {canUsePushControls ? ( + + ) : null} +
+
+
+ )} +
+
+ ); +}