오류 해결
This commit is contained in:
parent
60b4bffdf9
commit
c6f0750050
|
|
@ -191,7 +191,14 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps)
|
||||||
const generatePrintHTML = (): string => {
|
const generatePrintHTML = (): string => {
|
||||||
const pagesHTML = layoutConfig.pages
|
const pagesHTML = layoutConfig.pages
|
||||||
.sort((a, b) => a.page_order - b.page_order)
|
.sort((a, b) => a.page_order - b.page_order)
|
||||||
.map((page) => generatePageHTML(page.components, page.width, page.height, page.background_color))
|
.map((page) =>
|
||||||
|
generatePageHTML(
|
||||||
|
Array.isArray(page.components) ? page.components : [],
|
||||||
|
page.width,
|
||||||
|
page.height,
|
||||||
|
page.background_color,
|
||||||
|
),
|
||||||
|
)
|
||||||
.join('<div style="page-break-after: always;"></div>');
|
.join('<div style="page-break-after: always;"></div>');
|
||||||
|
|
||||||
return `
|
return `
|
||||||
|
|
@ -305,7 +312,7 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps)
|
||||||
const pagesWithBase64 = await Promise.all(
|
const pagesWithBase64 = await Promise.all(
|
||||||
layoutConfig.pages.map(async (page) => {
|
layoutConfig.pages.map(async (page) => {
|
||||||
const componentsWithBase64 = await Promise.all(
|
const componentsWithBase64 = await Promise.all(
|
||||||
page.components.map(async (component) => {
|
(Array.isArray(page.components) ? page.components : []).map(async (component) => {
|
||||||
// 이미지가 있는 컴포넌트는 Base64로 변환
|
// 이미지가 있는 컴포넌트는 Base64로 변환
|
||||||
if (component.imageUrl) {
|
if (component.imageUrl) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -325,7 +332,8 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps)
|
||||||
// 쿼리 결과 수집
|
// 쿼리 결과 수집
|
||||||
const queryResults: Record<string, { fields: string[]; rows: Record<string, unknown>[] }> = {};
|
const queryResults: Record<string, { fields: string[]; rows: Record<string, unknown>[] }> = {};
|
||||||
for (const page of layoutConfig.pages) {
|
for (const page of layoutConfig.pages) {
|
||||||
for (const component of page.components) {
|
const pageComponents = Array.isArray(page.components) ? page.components : [];
|
||||||
|
for (const component of pageComponents) {
|
||||||
if (component.queryId) {
|
if (component.queryId) {
|
||||||
const result = getQueryResult(component.queryId);
|
const result = getQueryResult(component.queryId);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
@ -404,7 +412,7 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps)
|
||||||
backgroundColor: page.background_color,
|
backgroundColor: page.background_color,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{page.components.map((component) => {
|
{(Array.isArray(page.components) ? page.components : []).map((component) => {
|
||||||
const displayValue = getComponentValue(component);
|
const displayValue = getComponentValue(component);
|
||||||
const queryResult = component.queryId ? getQueryResult(component.queryId) : null;
|
const queryResult = component.queryId ? getQueryResult(component.queryId) : null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,8 @@ export function ReportDesignerProvider({ reportId, children }: { reportId: strin
|
||||||
// 현재 페이지 계산
|
// 현재 페이지 계산
|
||||||
const currentPage = layoutConfig.pages.find((p) => p.page_id === currentPageId);
|
const currentPage = layoutConfig.pages.find((p) => p.page_id === currentPageId);
|
||||||
|
|
||||||
// 현재 페이지의 컴포넌트 (읽기 전용)
|
// 현재 페이지의 컴포넌트 (읽기 전용) - 배열인지 확인
|
||||||
const components = currentPage?.components || [];
|
const components = Array.isArray(currentPage?.components) ? currentPage.components : [];
|
||||||
|
|
||||||
// currentPageId를 ref로 저장하여 클로저 문제 해결
|
// currentPageId를 ref로 저장하여 클로저 문제 해결
|
||||||
const currentPageIdRef = useRef<string | null>(currentPageId);
|
const currentPageIdRef = useRef<string | null>(currentPageId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue