diff --git a/frontend/components/report/designer/ReportPreviewModal.tsx b/frontend/components/report/designer/ReportPreviewModal.tsx index c6fb2604..f64daaea 100644 --- a/frontend/components/report/designer/ReportPreviewModal.tsx +++ b/frontend/components/report/designer/ReportPreviewModal.tsx @@ -18,10 +18,49 @@ interface ReportPreviewModalProps { } export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps) { - const { components, canvasWidth, canvasHeight } = useReportDesigner(); + const { components, canvasWidth, canvasHeight, getQueryResult } = useReportDesigner(); + + // 컴포넌트의 실제 표시 값 가져오기 + const getComponentValue = (component: any): string => { + if (component.queryId && component.fieldName) { + const queryResult = getQueryResult(component.queryId); + if (queryResult && queryResult.rows.length > 0) { + const value = queryResult.rows[0][component.fieldName]; + if (value !== null && value !== undefined) { + return String(value); + } + } + return `{${component.fieldName}}`; + } + return component.defaultValue || "텍스트"; + }; const handlePrint = () => { - window.print(); + // 현재 미리보기 영역만 인쇄 + const printContent = document.getElementById("preview-content"); + if (!printContent) return; + + const printWindow = window.open("", "_blank"); + if (!printWindow) return; + + printWindow.document.write(` + +
+| 품목명 | -수량 | -단가 | + {queryResult.fields.map((field) => ( ++ {field} + | + ))}
|---|---|---|---|
| 샘플1 | -10 | -50,000 | -|
| + {String(row[field] ?? "")} + | + ))} +