feat: [문서] 모든 문서 저장 경로에 rendered_html 스냅샷 캡처 추가
- InspectionReportModal: readOnly 모드에서도 콘텐츠 로드 후 자동 캡처 - ImportInspectionInputModal: 수입검사 저장 시 폼 HTML 캡처 전송 - ReceivingManagement/actions: saveInspectionData에 rendered_html 파라미터 추가
This commit is contained in:
@@ -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<HTMLDivElement>(null);
|
||||
|
||||
// Template
|
||||
const [template, setTemplate] = useState<InspectionTemplateResponse | null>(null);
|
||||
const [resolveData, setResolveData] = useState<DocumentResolveResponse | null>(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({
|
||||
검사 템플릿을 불러올 수 없습니다.
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-5">
|
||||
<div ref={contentWrapperRef} className="flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-5">
|
||||
{/* 기본 정보 (읽기전용 인풋 스타일) */}
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
|
||||
@@ -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: '검사 데이터 저장에 실패했습니다.',
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user