diff --git a/docker/deploy/frontend.Dockerfile b/docker/deploy/frontend.Dockerfile index de8df2a9..87393f04 100644 --- a/docker/deploy/frontend.Dockerfile +++ b/docker/deploy/frontend.Dockerfile @@ -29,6 +29,7 @@ ENV SERVER_API_URL=$SERVER_API_URL # Build the application ENV DISABLE_ESLINT_PLUGIN=true +ENV NODE_OPTIONS="--max-old-space-size=8192" RUN npm run build # Production image, copy all the files and run next diff --git a/docker/prod/frontend.Dockerfile b/docker/prod/frontend.Dockerfile index e4741ad5..f730f763 100644 --- a/docker/prod/frontend.Dockerfile +++ b/docker/prod/frontend.Dockerfile @@ -28,6 +28,7 @@ ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL # Build the application ENV DISABLE_ESLINT_PLUGIN=true +ENV NODE_OPTIONS="--max-old-space-size=8192" RUN npm run build # Production image, copy all the files and run next diff --git a/frontend/lib/registry/components/v2-process-work-standard/components/DetailFormModal.tsx b/frontend/lib/registry/components/v2-process-work-standard/components/DetailFormModal.tsx index 78a9b2bc..af7b173c 100644 --- a/frontend/lib/registry/components/v2-process-work-standard/components/DetailFormModal.tsx +++ b/frontend/lib/registry/components/v2-process-work-standard/components/DetailFormModal.tsx @@ -133,33 +133,51 @@ export function DetailFormModal({ // BOM 자재 로드 완료 후 체크 상태 초기화 // bomChecked 키는 BOM detail 고유 id(mat.id) 기준 — 동일 child_item_id가 여러 row로 // 있어도 독립적으로 체크되도록 함. legacy 저장값은 child_item_id로 저장되어 있을 수 - // 있으므로 폴백 매핑으로 복원. + // 있으므로 폴백 매핑으로 복원. selected_bom_items 미저장 데이터는 bom_item_id 단일값으로 폴백. useEffect(() => { if (!open || bomMaterials.length === 0) return; - if (mode === "edit" && editData?.selected_bom_items) { - const savedBom = editData.selected_bom_items; - const parsedBom = typeof savedBom === "string" ? JSON.parse(savedBom) : savedBom; - if (Array.isArray(parsedBom)) { - const matIds = new Set(bomMaterials.map((m) => m.id)); - const restored = new Set(); - const seenChildForLegacy = new Set(); + if (mode === "edit") { + const matIds = new Set(bomMaterials.map((m) => m.id)); + const restored = new Set(); + const seenChildForLegacy = new Set(); + + // 1차 — selected_bom_items 배열 (정상 포맷) + const savedBom = editData?.selected_bom_items; + let parsedBom: unknown = savedBom; + if (typeof savedBom === "string" && savedBom) { + try { parsedBom = JSON.parse(savedBom); } catch { parsedBom = []; } + } + if (Array.isArray(parsedBom) && parsedBom.length > 0) { for (const saved of parsedBom) { - if (matIds.has(saved)) { - restored.add(saved); // 신규 포맷: bom_detail id 저장값 + const key = String(saved); + if (matIds.has(key)) { + restored.add(key); // 신규 포맷: bom_detail id 저장값 } else { // legacy 폴백: child_item_id로 저장된 값 → 해당 품목의 첫 번째 행 1건 자동 체크 - const legacyKey = String(saved); - if (seenChildForLegacy.has(legacyKey)) continue; - const firstMat = bomMaterials.find((m) => m.child_item_id === legacyKey); + if (seenChildForLegacy.has(key)) continue; + const firstMat = bomMaterials.find((m) => m.child_item_id === key); if (firstMat) { restored.add(firstMat.id); - seenChildForLegacy.add(legacyKey); + seenChildForLegacy.add(key); } } } - setBomChecked(restored); - return; } + + // 2차 — selected_bom_items가 비어있으면 bom_item_id 단일값 폴백 + // (구버전 저장 데이터: selected_bom_items 누락 + bom_item_id에 단일 자재 식별자만 채워진 경우) + if (restored.size === 0 && editData?.bom_item_id) { + const bomItemId = String(editData.bom_item_id); + if (matIds.has(bomItemId)) { + restored.add(bomItemId); // bom_detail.id 직접 매칭 + } else { + const firstMat = bomMaterials.find((m) => m.child_item_id === bomItemId); + if (firstMat) restored.add(firstMat.id); // child_item_id 매칭 + } + } + + setBomChecked(restored); + return; } // 신규 추가 또는 저장값 없으면 전체 해제 setBomChecked(new Set()); diff --git a/frontend/lib/registry/components/v2-process-work-standard/types.ts b/frontend/lib/registry/components/v2-process-work-standard/types.ts index 95143107..f4556acb 100644 --- a/frontend/lib/registry/components/v2-process-work-standard/types.ts +++ b/frontend/lib/registry/components/v2-process-work-standard/types.ts @@ -138,7 +138,12 @@ export interface WorkItemDetail { material_name?: string; quantity?: string; material_unit?: string; - selected_bom_items?: string[]; + selected_bom_items?: string[] | string; + // 단일 자재 식별자(구버전 저장 데이터 호환). selected_bom_items가 비었을 때 폴백 매칭에 사용. + bom_item_id?: string; + bom_item_name?: string; + bom_qty?: string; + bom_unit?: string; } export interface InspectionStandard {