refactor(intake): extract non-integrated sku material field
This commit is contained in:
parent
0443b33705
commit
71598ec0f3
@ -34,6 +34,7 @@ import {
|
||||
SkuNationalStandardComplianceField,
|
||||
SkuSupplierNameField,
|
||||
} from "./components/SkuDirectoryFields";
|
||||
import { SkuMaterialField } from "./components/SkuMaterialField";
|
||||
import { SkuBarcodeField } from "./components/SkuBarcodeField";
|
||||
import { BomPartImageField } from "./components/BomPartImageField";
|
||||
import { AdaptableBrandField } from "./components/BrandControls";
|
||||
@ -9073,85 +9074,6 @@ function resolveExecutionStandardOption(value: string) {
|
||||
return EXECUTION_STANDARD_BY_KEY.get(normalizedKey) ?? null;
|
||||
}
|
||||
|
||||
function buildRawMaterialProcessConfigHref(materialName: string) {
|
||||
const params = new URLSearchParams({
|
||||
section: "rawMaterialLibrary",
|
||||
rawMaterialLibrary: "processConfig",
|
||||
});
|
||||
const normalizedMaterialName = materialName.trim();
|
||||
if (normalizedMaterialName) {
|
||||
params.set("material", normalizedMaterialName);
|
||||
}
|
||||
|
||||
return `/intake?${params.toString()}`;
|
||||
}
|
||||
|
||||
function SkuMaterialField({
|
||||
value,
|
||||
placeholder,
|
||||
readOnly,
|
||||
columnWidth,
|
||||
onChange,
|
||||
onColumnResize,
|
||||
onOpenProcessConfig,
|
||||
}: {
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
readOnly: boolean;
|
||||
columnWidth: number;
|
||||
onChange: (value: string) => void;
|
||||
onColumnResize: (width: number) => void;
|
||||
onOpenProcessConfig?: (materialName: string) => void;
|
||||
}) {
|
||||
const normalizedMaterialName = value.trim();
|
||||
const lookupLabel = normalizedMaterialName || "材质";
|
||||
const processConfigHref = normalizedMaterialName
|
||||
? buildRawMaterialProcessConfigHref(normalizedMaterialName)
|
||||
: "";
|
||||
|
||||
return (
|
||||
<SkuColumnResizableFrame
|
||||
columnWidth={columnWidth}
|
||||
minWidth={SKU_COLUMN_DEFAULT_WIDTHS.material}
|
||||
onColumnResize={onColumnResize}
|
||||
className="flex items-stretch gap-1"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<SkuRowField
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
readOnly={readOnly}
|
||||
columnWidth={Math.max(columnWidth - 36, 56)}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</div>
|
||||
{processConfigHref ? (
|
||||
<a
|
||||
href={processConfigHref}
|
||||
onClick={(event) => {
|
||||
if (!onOpenProcessConfig) return;
|
||||
event.preventDefault();
|
||||
onOpenProcessConfig(normalizedMaterialName);
|
||||
}}
|
||||
aria-label={`查看 ${lookupLabel} 的工艺配置`}
|
||||
title={`查看 ${lookupLabel} 的工艺配置`}
|
||||
className="flex h-8 w-8 shrink-0 items-center justify-center rounded border border-apple-separator bg-white text-apple-label-secondary transition hover:border-apple-blue hover:text-apple-blue"
|
||||
>
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
</a>
|
||||
) : (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
title="先填写材质后再查看工艺配置"
|
||||
className="flex h-8 w-8 shrink-0 cursor-not-allowed items-center justify-center rounded border border-apple-separator bg-white text-apple-label-tertiary opacity-40"
|
||||
>
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
</span>
|
||||
)}
|
||||
</SkuColumnResizableFrame>
|
||||
);
|
||||
}
|
||||
|
||||
function BomBoardMaterialField({
|
||||
rowId: _rowId,
|
||||
value,
|
||||
@ -30506,6 +30428,9 @@ function renderFactoryQualityWorkspace() {
|
||||
placeholder="请填写"
|
||||
readOnly={skuRowReadOnly}
|
||||
columnWidth={skuColumnWidths.material}
|
||||
minColumnWidth={
|
||||
SKU_COLUMN_DEFAULT_WIDTHS.material
|
||||
}
|
||||
onChange={(value) =>
|
||||
updateSkuItem(
|
||||
item.id,
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
import { Search } from "lucide-react";
|
||||
import {
|
||||
SkuColumnResizableFrame,
|
||||
SkuRowField,
|
||||
} from "./SkuTableFields";
|
||||
|
||||
function buildRawMaterialProcessConfigHref(materialName: string) {
|
||||
const params = new URLSearchParams({
|
||||
section: "rawMaterialLibrary",
|
||||
rawMaterialLibrary: "processConfig",
|
||||
});
|
||||
const normalizedMaterialName = materialName.trim();
|
||||
if (normalizedMaterialName) {
|
||||
params.set("material", normalizedMaterialName);
|
||||
}
|
||||
|
||||
return `/intake?${params.toString()}`;
|
||||
}
|
||||
|
||||
export function SkuMaterialField({
|
||||
value,
|
||||
placeholder,
|
||||
readOnly,
|
||||
columnWidth,
|
||||
minColumnWidth,
|
||||
onChange,
|
||||
onColumnResize,
|
||||
onOpenProcessConfig,
|
||||
}: {
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
readOnly: boolean;
|
||||
columnWidth: number;
|
||||
minColumnWidth: number;
|
||||
onChange: (value: string) => void;
|
||||
onColumnResize: (width: number) => void;
|
||||
onOpenProcessConfig?: (materialName: string) => void;
|
||||
}) {
|
||||
const normalizedMaterialName = value.trim();
|
||||
const lookupLabel = normalizedMaterialName || "\u6750\u8d28";
|
||||
const processConfigHref = normalizedMaterialName
|
||||
? buildRawMaterialProcessConfigHref(normalizedMaterialName)
|
||||
: "";
|
||||
|
||||
return (
|
||||
<SkuColumnResizableFrame
|
||||
columnWidth={columnWidth}
|
||||
minWidth={minColumnWidth}
|
||||
onColumnResize={onColumnResize}
|
||||
className="flex items-stretch gap-1"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<SkuRowField
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
readOnly={readOnly}
|
||||
columnWidth={Math.max(columnWidth - 36, 56)}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</div>
|
||||
{processConfigHref ? (
|
||||
<a
|
||||
href={processConfigHref}
|
||||
onClick={(event) => {
|
||||
if (!onOpenProcessConfig) return;
|
||||
event.preventDefault();
|
||||
onOpenProcessConfig(normalizedMaterialName);
|
||||
}}
|
||||
aria-label={`\u67e5\u770b ${lookupLabel} \u7684\u5de5\u827a\u914d\u7f6e`}
|
||||
title={`\u67e5\u770b ${lookupLabel} \u7684\u5de5\u827a\u914d\u7f6e`}
|
||||
className="flex h-8 w-8 shrink-0 items-center justify-center rounded border border-apple-separator bg-white text-apple-label-secondary transition hover:border-apple-blue hover:text-apple-blue"
|
||||
>
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
</a>
|
||||
) : (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
title={"\u5148\u586b\u5199\u6750\u8d28\u540e\u518d\u67e5\u770b\u5de5\u827a\u914d\u7f6e"}
|
||||
className="flex h-8 w-8 shrink-0 cursor-not-allowed items-center justify-center rounded border border-apple-separator bg-white text-apple-label-tertiary opacity-40"
|
||||
>
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
</span>
|
||||
)}
|
||||
</SkuColumnResizableFrame>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user