diff --git a/src/components/material/ReceivingManagement/ImportInspectionInputModal.tsx b/src/components/material/ReceivingManagement/ImportInspectionInputModal.tsx index 593f15c6..ae817459 100644 --- a/src/components/material/ReceivingManagement/ImportInspectionInputModal.tsx +++ b/src/components/material/ReceivingManagement/ImportInspectionInputModal.tsx @@ -12,7 +12,7 @@ * - saveInspectionData()로 저장 */ -import { useState, useEffect, useMemo, useCallback } from 'react'; +import { useState, useEffect, useMemo, useCallback, useRef } from 'react'; import { Dialog, DialogContent, @@ -216,6 +216,9 @@ export function ImportInspectionInputModal({ receivingId, onSave, }: ImportInspectionInputModalProps) { + // HTML 스냅샷 캡처 ref (MNG 출력용) + const contentWrapperRef = useRef(null); + // Template const [template, setTemplate] = useState(null); const [resolveData, setResolveData] = useState(null); @@ -636,7 +639,10 @@ export function ImportInspectionInputModal({ })), ]; - // 4. 저장 API 호출 + // 4. HTML 스냅샷 캡처 (MNG 출력용) + const renderedHtml = contentWrapperRef.current?.innerHTML || undefined; + + // 5. 저장 API 호출 const result = await saveInspectionData({ templateId: parseInt(template.templateId), itemId, @@ -645,6 +651,7 @@ export function ImportInspectionInputModal({ attachments, receivingId, inspectionResult: overallResult, + rendered_html: renderedHtml, }); if (result.success) { @@ -734,7 +741,7 @@ export function ImportInspectionInputModal({ 검사 템플릿을 불러올 수 없습니다. ) : ( -
+
{/* 기본 정보 (읽기전용 인풋 스타일) */}
diff --git a/src/components/material/ReceivingManagement/actions.ts b/src/components/material/ReceivingManagement/actions.ts index adf5d47e..18291598 100644 --- a/src/components/material/ReceivingManagement/actions.ts +++ b/src/components/material/ReceivingManagement/actions.ts @@ -1874,6 +1874,7 @@ export async function saveInspectionData(params: { attachments?: Array<{ file_id: number; attachment_type: string; description?: string }>; receivingId: string; inspectionResult?: 'pass' | 'fail' | null; + rendered_html?: string; }): Promise<{ success: boolean; error?: string; @@ -1889,6 +1890,7 @@ export async function saveInspectionData(params: { title: params.title || '수입검사 성적서', data: params.data, attachments: params.attachments || [], + rendered_html: params.rendered_html, }, errorMessage: '검사 데이터 저장에 실패했습니다.', }); diff --git a/src/components/production/WorkOrders/documents/InspectionReportModal.tsx b/src/components/production/WorkOrders/documents/InspectionReportModal.tsx index 8593cf84..6aa94651 100644 --- a/src/components/production/WorkOrders/documents/InspectionReportModal.tsx +++ b/src/components/production/WorkOrders/documents/InspectionReportModal.tsx @@ -469,6 +469,21 @@ export function InspectionReportModal({ } }; + // readOnly 모드에서도 콘텐츠 렌더 후 rendered_html 자동 캡처 (MNG 출력용) + useEffect(() => { + if (!open || !order || isLoading || !readOnly || !workOrderId) return; + // 렌더링 완료 후 캡처 + const timer = setTimeout(() => { + const html = contentWrapperRef.current?.innerHTML; + if (html && html.length > 100) { + saveInspectionDocument(workOrderId, { rendered_html: html }).catch(() => { + // 자동 캡처 실패는 무시 (template 미연결 시 404 가능) + }); + } + }, 500); + return () => clearTimeout(timer); + }, [open, order, isLoading, readOnly, workOrderId]); + // 결재 상신 가능 여부: 저장된 DRAFT 문서가 있을 때 const canSubmitForApproval = savedDocumentId != null && savedDocumentStatus === 'DRAFT';