From 109380b9e5ea1b19936c0cb2fce18b51518f9d59 Mon Sep 17 00:00:00 2001 From: leeheejin Date: Mon, 15 Dec 2025 17:01:04 +0900 Subject: [PATCH 001/104] =?UTF-8?q?=EC=9D=B4=EC=A0=9C=20=EB=94=94=EB=B9=84?= =?UTF-8?q?=EC=97=90=20=ED=95=9C=EA=B8=80=EB=A1=9C=20=EC=B6=9C=EB=B0=9C?= =?UTF-8?q?=EC=A7=80=20=EB=AA=A9=EC=A0=81=EC=A7=80=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LocationSwapSelectorComponent.tsx | 6 +++--- .../lib/registry/components/location-swap-selector/index.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/lib/registry/components/location-swap-selector/LocationSwapSelectorComponent.tsx b/frontend/lib/registry/components/location-swap-selector/LocationSwapSelectorComponent.tsx index 7a693ad5..88e9002a 100644 --- a/frontend/lib/registry/components/location-swap-selector/LocationSwapSelectorComponent.tsx +++ b/frontend/lib/registry/components/location-swap-selector/LocationSwapSelectorComponent.tsx @@ -107,10 +107,10 @@ export function LocationSwapSelectorComponent(props: LocationSwapSelectorProps) const dbTableName = config.dbTableName || "vehicles"; const dbKeyField = config.dbKeyField || "user_id"; - // 기본 옵션 (포항/광양) + // 기본 옵션 (포항/광양) - 한글로 저장 const DEFAULT_OPTIONS: LocationOption[] = [ - { value: "pohang", label: "포항" }, - { value: "gwangyang", label: "광양" }, + { value: "포항", label: "포항" }, + { value: "광양", label: "광양" }, ]; // 상태 diff --git a/frontend/lib/registry/components/location-swap-selector/index.ts b/frontend/lib/registry/components/location-swap-selector/index.ts index c4c30418..7f7447cf 100644 --- a/frontend/lib/registry/components/location-swap-selector/index.ts +++ b/frontend/lib/registry/components/location-swap-selector/index.ts @@ -26,9 +26,9 @@ export const LocationSwapSelectorDefinition = createComponentDefinition({ labelField: "location_name", // 표시 필드 codeCategory: "", // 코드 관리 카테고리 (type이 "code"일 때) staticOptions: [ - { value: "pohang", label: "포항" }, - { value: "gwangyang", label: "광양" }, - ], // 정적 옵션 (type이 "static"일 때) + { value: "포항", label: "포항" }, + { value: "광양", label: "광양" }, + ], // 정적 옵션 (type이 "static"일 때) - 한글로 저장 }, // 필드 매핑 departureField: "departure", // 출발지 저장 필드 From 239e4800c716c4d1376801a5d35020310a11e48f Mon Sep 17 00:00:00 2001 From: kjs Date: Mon, 5 Jan 2026 13:37:39 +0900 Subject: [PATCH 002/104] =?UTF-8?q?=EC=A6=89=EC=8B=9C=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=95=A1=EC=85=98=20=ED=95=84=EC=88=98=ED=95=AD=EB=AA=A9=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/lib/utils/buttonActions.ts | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index 327cb87f..5587fc1a 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -5931,6 +5931,69 @@ export class ButtonActionExecutor { return false; } + // ✅ allComponents가 있으면 기존 필수 항목 검증 수행 + if (context.allComponents && context.allComponents.length > 0) { + console.log("🔍 [handleQuickInsert] 필수 항목 검증 시작:", { + hasAllComponents: !!context.allComponents, + allComponentsLength: context.allComponents?.length || 0, + }); + const requiredValidation = this.validateRequiredFields(context); + if (!requiredValidation.isValid) { + console.log("❌ [handleQuickInsert] 필수 항목 누락:", requiredValidation.missingFields); + toast.error(`필수 항목을 입력해주세요: ${requiredValidation.missingFields.join(", ")}`); + return false; + } + console.log("✅ [handleQuickInsert] 필수 항목 검증 통과"); + } + + // ✅ quickInsert 전용 검증: component 타입 매핑에서 값이 비어있는지 확인 + const mappingsForValidation = quickInsertConfig.columnMappings || []; + const missingMappingFields: string[] = []; + + for (const mapping of mappingsForValidation) { + // component 타입 매핑은 필수 입력으로 간주 + if (mapping.sourceType === "component" && mapping.sourceComponentId) { + let value: any = undefined; + + // 값 가져오기 (formData에서) + if (mapping.sourceColumnName) { + value = context.formData?.[mapping.sourceColumnName]; + } + if (value === undefined || value === null) { + value = context.formData?.[mapping.sourceComponentId]; + } + // allComponents에서 컴포넌트 찾아서 columnName으로 시도 + if ((value === undefined || value === null) && context.allComponents) { + const comp = context.allComponents.find((c: any) => c.id === mapping.sourceComponentId); + if (comp?.columnName) { + value = context.formData?.[comp.columnName]; + } + } + // targetColumn으로 폴백 + if ((value === undefined || value === null) && mapping.targetColumn) { + value = context.formData?.[mapping.targetColumn]; + } + + // 값이 비어있으면 필수 누락으로 처리 + if (value === undefined || value === null || (typeof value === "string" && value.trim() === "")) { + console.log("❌ [handleQuickInsert] component 매핑 값 누락:", { + targetColumn: mapping.targetColumn, + sourceComponentId: mapping.sourceComponentId, + sourceColumnName: mapping.sourceColumnName, + value, + }); + missingMappingFields.push(mapping.targetColumn); + } + } + } + + if (missingMappingFields.length > 0) { + console.log("❌ [handleQuickInsert] 필수 입력 항목 누락:", missingMappingFields); + toast.error(`다음 항목을 입력해주세요: ${missingMappingFields.join(", ")}`); + return false; + } + console.log("✅ [handleQuickInsert] quickInsert 매핑 검증 통과"); + const { formData, splitPanelContext, userId, userName, companyCode } = context; console.log("⚡ Quick Insert 상세 정보:", { From 85519e302fd99de8fab4308ccf104a77c79e8d01 Mon Sep 17 00:00:00 2001 From: kjs Date: Mon, 5 Jan 2026 13:54:41 +0900 Subject: [PATCH 003/104] =?UTF-8?q?=ED=96=89=EC=84=A0=ED=83=9D=EC=8B=9C?= =?UTF-8?q?=EC=97=90=EB=A7=8C=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../button-primary/ButtonPrimaryComponent.tsx | 22 +++++-- .../table-list/TableListComponent.tsx | 64 +++++++++---------- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx b/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx index f311c035..a71f6e03 100644 --- a/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx +++ b/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx @@ -299,6 +299,20 @@ export const ButtonPrimaryComponent: React.FC = ({ // 🆕 modalDataStore에서 선택된 데이터 확인 (분할 패널 등에서 저장됨) const [modalStoreData, setModalStoreData] = useState>({}); + // 🆕 splitPanelContext?.selectedLeftData를 로컬 상태로 추적 (리렌더링 보장) + const [trackedSelectedLeftData, setTrackedSelectedLeftData] = useState | null>(null); + + // splitPanelContext?.selectedLeftData 변경 감지 및 로컬 상태 동기화 + useEffect(() => { + const newData = splitPanelContext?.selectedLeftData ?? null; + setTrackedSelectedLeftData(newData); + console.log("🔄 [ButtonPrimary] selectedLeftData 변경 감지:", { + label: component.label, + hasData: !!newData, + dataKeys: newData ? Object.keys(newData) : [], + }); + }, [splitPanelContext?.selectedLeftData, component.label]); + // modalDataStore 상태 구독 (실시간 업데이트) useEffect(() => { const actionConfig = component.componentConfig?.action; @@ -357,8 +371,8 @@ export const ButtonPrimaryComponent: React.FC = ({ // 2. 분할 패널 좌측 선택 데이터 확인 if (rowSelectionSource === "auto" || rowSelectionSource === "splitPanelLeft") { - // SplitPanelContext에서 확인 - if (splitPanelContext?.selectedLeftData && Object.keys(splitPanelContext.selectedLeftData).length > 0) { + // SplitPanelContext에서 확인 (trackedSelectedLeftData 사용으로 리렌더링 보장) + if (trackedSelectedLeftData && Object.keys(trackedSelectedLeftData).length > 0) { if (!hasSelection) { hasSelection = true; selectionCount = 1; @@ -397,7 +411,7 @@ export const ButtonPrimaryComponent: React.FC = ({ selectionCount, selectionSource, hasSplitPanelContext: !!splitPanelContext, - selectedLeftData: splitPanelContext?.selectedLeftData, + trackedSelectedLeftData: trackedSelectedLeftData, selectedRowsData: selectedRowsData?.length, selectedRows: selectedRows?.length, flowSelectedData: flowSelectedData?.length, @@ -429,7 +443,7 @@ export const ButtonPrimaryComponent: React.FC = ({ component.label, selectedRows, selectedRowsData, - splitPanelContext?.selectedLeftData, + trackedSelectedLeftData, flowSelectedData, splitPanelContext, modalStoreData, diff --git a/frontend/lib/registry/components/table-list/TableListComponent.tsx b/frontend/lib/registry/components/table-list/TableListComponent.tsx index 7ac521af..7a787ed3 100644 --- a/frontend/lib/registry/components/table-list/TableListComponent.tsx +++ b/frontend/lib/registry/components/table-list/TableListComponent.tsx @@ -2043,7 +2043,7 @@ export const TableListComponent: React.FC = ({ return row.id || row.uuid || `row-${index}`; }; - const handleRowSelection = (rowKey: string, checked: boolean) => { + const handleRowSelection = (rowKey: string, checked: boolean, rowData?: any) => { const newSelectedRows = new Set(selectedRows); if (checked) { newSelectedRows.add(rowKey); @@ -2086,6 +2086,31 @@ export const TableListComponent: React.FC = ({ }); } + // 🆕 분할 패널 컨텍스트에 선택된 데이터 저장/해제 (체크박스 선택 시에도 작동) + const effectiveSplitPosition = splitPanelPosition || currentSplitPosition; + if (splitPanelContext && effectiveSplitPosition === "left" && !splitPanelContext.disableAutoDataTransfer) { + if (checked && selectedRowsData.length > 0) { + // 선택된 경우: 첫 번째 선택된 데이터 저장 (또는 전달된 rowData) + const dataToStore = rowData || selectedRowsData[selectedRowsData.length - 1]; + splitPanelContext.setSelectedLeftData(dataToStore); + console.log("🔗 [TableList] handleRowSelection - 분할 패널 좌측 데이터 저장:", { + rowKey, + dataToStore, + }); + } else if (!checked && selectedRowsData.length === 0) { + // 모든 선택이 해제된 경우: 데이터 초기화 + splitPanelContext.setSelectedLeftData(null); + console.log("🔗 [TableList] handleRowSelection - 분할 패널 좌측 데이터 초기화"); + } else if (selectedRowsData.length > 0) { + // 일부 선택 해제된 경우: 남은 첫 번째 데이터로 업데이트 + splitPanelContext.setSelectedLeftData(selectedRowsData[0]); + console.log("🔗 [TableList] handleRowSelection - 분할 패널 좌측 데이터 업데이트:", { + remainingCount: selectedRowsData.length, + firstData: selectedRowsData[0], + }); + } + } + const allRowsSelected = filteredData.every((row, index) => newSelectedRows.has(getRowKey(row, index))); setIsAllSelected(allRowsSelected && filteredData.length > 0); }; @@ -2155,35 +2180,8 @@ export const TableListComponent: React.FC = ({ const rowKey = getRowKey(row, index); const isCurrentlySelected = selectedRows.has(rowKey); - handleRowSelection(rowKey, !isCurrentlySelected); - - // 🆕 분할 패널 컨텍스트에 선택된 데이터 저장 (좌측 화면인 경우) - // disableAutoDataTransfer가 true이면 자동 전달 비활성화 (버튼 클릭으로만 전달) - // currentSplitPosition을 사용하여 정확한 위치 확인 (splitPanelPosition이 없을 수 있음) - const effectiveSplitPosition = splitPanelPosition || currentSplitPosition; - - console.log("🔗 [TableList] 행 클릭 - 분할 패널 위치 확인:", { - splitPanelPosition, - currentSplitPosition, - effectiveSplitPosition, - hasSplitPanelContext: !!splitPanelContext, - disableAutoDataTransfer: splitPanelContext?.disableAutoDataTransfer, - }); - - if (splitPanelContext && effectiveSplitPosition === "left" && !splitPanelContext.disableAutoDataTransfer) { - if (!isCurrentlySelected) { - // 선택된 경우: 데이터 저장 - splitPanelContext.setSelectedLeftData(row); - console.log("🔗 [TableList] 분할 패널 좌측 데이터 저장:", { - row, - parentDataMapping: splitPanelContext.parentDataMapping, - }); - } else { - // 선택 해제된 경우: 데이터 초기화 - splitPanelContext.setSelectedLeftData(null); - console.log("🔗 [TableList] 분할 패널 좌측 데이터 초기화"); - } - } + // handleRowSelection에서 분할 패널 데이터 처리도 함께 수행됨 + handleRowSelection(rowKey, !isCurrentlySelected, row); console.log("행 클릭:", { row, index, isSelected: !isCurrentlySelected }); }; @@ -3918,7 +3916,7 @@ export const TableListComponent: React.FC = ({ if (enterRow) { const rowKey = getRowKey(enterRow, rowIndex); const isCurrentlySelected = selectedRows.has(rowKey); - handleRowSelection(rowKey, !isCurrentlySelected); + handleRowSelection(rowKey, !isCurrentlySelected, enterRow); } break; case " ": // Space @@ -3928,7 +3926,7 @@ export const TableListComponent: React.FC = ({ if (spaceRow) { const currentRowKey = getRowKey(spaceRow, rowIndex); const isChecked = selectedRows.has(currentRowKey); - handleRowSelection(currentRowKey, !isChecked); + handleRowSelection(currentRowKey, !isChecked, spaceRow); } break; case "F2": @@ -4142,7 +4140,7 @@ export const TableListComponent: React.FC = ({ return ( handleRowSelection(rowKey, checked as boolean)} + onCheckedChange={(checked) => handleRowSelection(rowKey, checked as boolean, row)} aria-label={`행 ${index + 1} 선택`} /> ); From 914f3d57f33ffd2bc0aa14da820505d00c0c7814 Mon Sep 17 00:00:00 2001 From: SeongHyun Kim Date: Mon, 5 Jan 2026 13:58:13 +0900 Subject: [PATCH 004/104] =?UTF-8?q?fix:=20TableList=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EB=9D=BC=EB=B2=A8=20=ED=91=9C=EC=8B=9C?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EB=A9=80=ED=8B=B0=ED=85=8C?= =?UTF-8?q?=EB=84=8C=EC=8B=9C=20fallback=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20getColumnInputTypes=20API=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=9A=8C=EC=82=AC=EB=B3=84=20=EC=84=A4=EC=A0=95=EC=9D=B4=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EB=95=8C=20=EA=B8=B0=EB=B3=B8=EC=84=A4?= =?UTF-8?q?=EC=A0=95()=20fallback=20=EC=A0=81=EC=9A=A9=20table=5Ftype=5Fco?= =?UTF-8?q?lumns,=20category=5Fcolumn=5Fmapping=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=8B=9C=20DISTINCT=20ON=20+=20ORDER=20BY=20CASE=20WHEN=20?= =?UTF-8?q?=ED=8C=A8=ED=84=B4=20=EC=82=AC=EC=9A=A9=20=EC=98=81=ED=96=A5=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84:=20=EB=AA=A8=EB=93=A0=20TableList=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=9D=98=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EC=BB=AC=EB=9F=BC=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/services/tableManagementService.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend-node/src/services/tableManagementService.ts b/backend-node/src/services/tableManagementService.ts index b714b186..def9a978 100644 --- a/backend-node/src/services/tableManagementService.ts +++ b/backend-node/src/services/tableManagementService.ts @@ -3930,9 +3930,10 @@ export class TableManagementService { `컬럼 입력타입 정보 조회: ${tableName}, company: ${companyCode}` ); - // table_type_columns에서 입력타입 정보 조회 (company_code 필터링) + // table_type_columns에서 입력타입 정보 조회 + // 회사별 설정 우선, 없으면 기본 설정(*) fallback const rawInputTypes = await query( - `SELECT + `SELECT DISTINCT ON (ttc.column_name) ttc.column_name as "columnName", COALESCE(cl.column_label, ttc.column_name) as "displayName", ttc.input_type as "inputType", @@ -3946,8 +3947,10 @@ export class TableManagementService { LEFT JOIN information_schema.columns ic ON ttc.table_name = ic.table_name AND ttc.column_name = ic.column_name WHERE ttc.table_name = $1 - AND ttc.company_code = $2 - ORDER BY ttc.display_order, ttc.column_name`, + AND ttc.company_code IN ($2, '*') + ORDER BY ttc.column_name, + CASE WHEN ttc.company_code = $2 THEN 0 ELSE 1 END, + ttc.display_order`, [tableName, companyCode] ); @@ -3961,17 +3964,20 @@ export class TableManagementService { const mappingTableExists = tableExistsResult[0]?.table_exists === true; // 카테고리 컬럼의 경우, 매핑된 메뉴 목록 조회 + // 회사별 설정 우선, 없으면 기본 설정(*) fallback let categoryMappings: Map = new Map(); if (mappingTableExists) { logger.info("카테고리 매핑 조회 시작", { tableName, companyCode }); const mappings = await query( - `SELECT + `SELECT DISTINCT ON (logical_column_name, menu_objid) logical_column_name as "columnName", menu_objid as "menuObjid" FROM category_column_mapping WHERE table_name = $1 - AND company_code = $2`, + AND company_code IN ($2, '*') + ORDER BY logical_column_name, menu_objid, + CASE WHEN company_code = $2 THEN 0 ELSE 1 END`, [tableName, companyCode] ); From 2a7066b6fd6feddbcf4d86a88aea1c6f3332c11a Mon Sep 17 00:00:00 2001 From: hjjeong Date: Mon, 5 Jan 2026 17:08:03 +0900 Subject: [PATCH 005/104] =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20=EC=BB=AC=EB=9F=BC?= =?UTF-8?q?=EB=A7=8C=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-node/src/services/tableManagementService.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend-node/src/services/tableManagementService.ts b/backend-node/src/services/tableManagementService.ts index def9a978..8ac5989b 100644 --- a/backend-node/src/services/tableManagementService.ts +++ b/backend-node/src/services/tableManagementService.ts @@ -2409,11 +2409,19 @@ export class TableManagementService { } // SET 절 생성 (수정할 데이터) - 먼저 생성 + // 🔧 테이블에 존재하는 컬럼만 UPDATE (가상 컬럼 제외) const setConditions: string[] = []; const setValues: any[] = []; let paramIndex = 1; + const skippedColumns: string[] = []; Object.keys(updatedData).forEach((column) => { + // 테이블에 존재하지 않는 컬럼은 스킵 + if (!columnTypeMap.has(column)) { + skippedColumns.push(column); + return; + } + const dataType = columnTypeMap.get(column) || "text"; setConditions.push( `"${column}" = $${paramIndex}::${this.getPostgreSQLType(dataType)}` @@ -2424,6 +2432,10 @@ export class TableManagementService { paramIndex++; }); + if (skippedColumns.length > 0) { + logger.info(`⚠️ 테이블에 존재하지 않는 컬럼 스킵: ${skippedColumns.join(", ")}`); + } + // WHERE 조건 생성 (PRIMARY KEY 우선, 없으면 모든 원본 데이터 사용) let whereConditions: string[] = []; let whereValues: any[] = []; From 714698c20f6e7109c096563ae1275cc4dc1f6568 Mon Sep 17 00:00:00 2001 From: hjjeong Date: Mon, 5 Jan 2026 17:08:47 +0900 Subject: [PATCH 006/104] =?UTF-8?q?=EA=B5=AC=EB=A7=A4=EA=B4=80=EB=A6=AC=5F?= =?UTF-8?q?=EB=B0=9C=EC=A3=BC=EA=B4=80=EB=A6=AC=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EB=A7=88=EC=8A=A4=ED=84=B0=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=ED=92=88=EB=AA=A9=EC=97=90=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/lib/utils/buttonActions.ts | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index 5587fc1a..681e9a3f 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -995,6 +995,40 @@ export class ButtonActionExecutor { console.log("📋 [handleSave] 범용 폼 모달 공통 필드:", commonFields); } + // 🆕 루트 레벨 formData에서 RepeaterFieldGroup에 전달할 공통 필드 추출 + // 주문번호, 발주번호 등 마스터-디테일 관계에서 필요한 필드만 명시적으로 지정 + const masterDetailFields = [ + // 번호 필드 + "order_no", // 발주번호 + "sales_order_no", // 수주번호 + "shipment_no", // 출하번호 + "receipt_no", // 입고번호 + "work_order_no", // 작업지시번호 + // 거래처 필드 + "supplier_code", // 공급처 코드 + "supplier_name", // 공급처 이름 + "customer_code", // 고객 코드 + "customer_name", // 고객 이름 + // 날짜 필드 + "order_date", // 발주일 + "sales_date", // 수주일 + "shipment_date", // 출하일 + "receipt_date", // 입고일 + "due_date", // 납기일 + // 담당자/메모 필드 + "manager", // 담당자 + "memo", // 메모 + "remark", // 비고 + ]; + + for (const fieldName of masterDetailFields) { + const value = context.formData[fieldName]; + if (value !== undefined && value !== "" && value !== null && !(fieldName in commonFields)) { + commonFields[fieldName] = value; + } + } + console.log("📋 [handleSave] 최종 공통 필드 (마스터-디테일 필드 포함):", commonFields); + for (const item of parsedData) { // 메타 필드 제거 (eslint 경고 무시 - 의도적으로 분리) From 64105bf525644f6c76f8f87b8ba3ea1d7acd0788 Mon Sep 17 00:00:00 2001 From: hjjeong Date: Mon, 5 Jan 2026 18:21:29 +0900 Subject: [PATCH 007/104] =?UTF-8?q?=EB=B0=9C=EC=A3=BC=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=8B=9C=20=EA=B3=B5=EA=B8=89=EC=B2=98=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutocompleteSearchInputComponent.tsx | 145 +++++++++++++++++- 1 file changed, 141 insertions(+), 4 deletions(-) diff --git a/frontend/lib/registry/components/autocomplete-search-input/AutocompleteSearchInputComponent.tsx b/frontend/lib/registry/components/autocomplete-search-input/AutocompleteSearchInputComponent.tsx index 7a115ea3..cbd2744c 100644 --- a/frontend/lib/registry/components/autocomplete-search-input/AutocompleteSearchInputComponent.tsx +++ b/frontend/lib/registry/components/autocomplete-search-input/AutocompleteSearchInputComponent.tsx @@ -44,7 +44,42 @@ export function AutocompleteSearchInputComponent({ const displayField = config?.displayField || propDisplayField || ""; const displayFields = config?.displayFields || (displayField ? [displayField] : []); // 다중 표시 필드 const displaySeparator = config?.displaySeparator || " → "; // 구분자 - const valueField = config?.valueField || propValueField || ""; + + // valueField 결정: fieldMappings 기반으로 추론 (config.valueField가 fieldMappings에 없으면 무시) + const getValueField = () => { + // fieldMappings가 있으면 그 안에서 추론 (가장 신뢰할 수 있는 소스) + if (config?.fieldMappings && config.fieldMappings.length > 0) { + // config.valueField가 fieldMappings의 sourceField에 있으면 사용 + if (config?.valueField) { + const hasValueFieldInMappings = config.fieldMappings.some( + (m: any) => m.sourceField === config.valueField + ); + if (hasValueFieldInMappings) { + return config.valueField; + } + // fieldMappings에 없으면 무시하고 추론 + } + + // _code 또는 _id로 끝나는 필드 우선 (보통 PK나 코드 필드) + const codeMapping = config.fieldMappings.find( + (m: any) => m.sourceField?.endsWith("_code") || m.sourceField?.endsWith("_id") + ); + if (codeMapping) { + return codeMapping.sourceField; + } + + // 없으면 첫 번째 매핑 사용 + return config.fieldMappings[0].sourceField || ""; + } + + // fieldMappings가 없으면 기존 방식 + if (config?.valueField) return config.valueField; + if (propValueField) return propValueField; + + return ""; + }; + const valueField = getValueField(); + const searchFields = config?.searchFields || propSearchFields || displayFields; // 검색 필드도 다중 표시 필드 사용 const placeholder = config?.placeholder || propPlaceholder || "검색..."; @@ -76,11 +111,39 @@ export function AutocompleteSearchInputComponent({ // 선택된 데이터를 ref로도 유지 (리렌더링 시 초기화 방지) const selectedDataRef = useRef(null); const inputValueRef = useRef(""); + const initialValueLoadedRef = useRef(null); // 초기값 로드 추적 // formData에서 현재 값 가져오기 (isInteractive 모드) - const currentValue = isInteractive && formData && component?.columnName - ? formData[component.columnName] - : value; + // 우선순위: 1) component.columnName, 2) fieldMappings에서 valueField에 매핑된 targetField + const getCurrentValue = () => { + if (!isInteractive || !formData) { + return value; + } + + // 1. component.columnName으로 직접 바인딩된 경우 + if (component?.columnName && formData[component.columnName] !== undefined) { + return formData[component.columnName]; + } + + // 2. fieldMappings에서 valueField와 매핑된 targetField에서 값 가져오기 + if (config?.fieldMappings && Array.isArray(config.fieldMappings)) { + const valueFieldMapping = config.fieldMappings.find( + (mapping: any) => mapping.sourceField === valueField + ); + + if (valueFieldMapping) { + const targetField = valueFieldMapping.targetField || valueFieldMapping.targetColumn; + + if (targetField && formData[targetField] !== undefined) { + return formData[targetField]; + } + } + } + + return value; + }; + + const currentValue = getCurrentValue(); // selectedData 변경 시 ref도 업데이트 useEffect(() => { @@ -98,6 +161,79 @@ export function AutocompleteSearchInputComponent({ } }, []); + // 초기값이 있을 때 해당 값의 표시 텍스트를 조회하여 설정 + useEffect(() => { + const loadInitialDisplayValue = async () => { + // 이미 로드된 값이거나, 값이 없거나, 이미 선택된 데이터가 있으면 스킵 + if (!currentValue || selectedData || selectedDataRef.current) { + return; + } + + // 이미 같은 값을 로드한 적이 있으면 스킵 + if (initialValueLoadedRef.current === currentValue) { + return; + } + + // 테이블명과 필드 정보가 없으면 스킵 + if (!tableName || !valueField) { + return; + } + + console.log("🔄 AutocompleteSearchInput 초기값 로드:", { + currentValue, + tableName, + valueField, + displayFields, + }); + + try { + // API를 통해 해당 값의 표시 텍스트 조회 + const { apiClient } = await import("@/lib/api/client"); + const filterConditionWithValue = { + ...filterCondition, + [valueField]: currentValue, + }; + + const params = new URLSearchParams({ + searchText: "", + searchFields: searchFields.join(","), + filterCondition: JSON.stringify(filterConditionWithValue), + page: "1", + limit: "10", + }); + + const response = await apiClient.get<{ success: boolean; data: EntitySearchResult[] }>( + `/entity-search/${tableName}?${params.toString()}` + ); + + if (response.data.success && response.data.data && response.data.data.length > 0) { + const matchedItem = response.data.data.find((item: EntitySearchResult) => + String(item[valueField]) === String(currentValue) + ); + + if (matchedItem) { + const displayText = getDisplayValue(matchedItem); + console.log("✅ 초기값 표시 텍스트 로드 성공:", { + currentValue, + displayText, + matchedItem, + }); + + setSelectedData(matchedItem); + setInputValue(displayText); + selectedDataRef.current = matchedItem; + inputValueRef.current = displayText; + initialValueLoadedRef.current = currentValue; + } + } + } catch (error) { + console.error("❌ 초기값 표시 텍스트 로드 실패:", error); + } + }; + + loadInitialDisplayValue(); + }, [currentValue, tableName, valueField, displayFields, filterCondition, searchFields, selectedData]); + // value가 변경되면 표시값 업데이트 - 단, selectedData가 있으면 유지 useEffect(() => { // selectedData가 있으면 표시값 유지 (사용자가 방금 선택한 경우) @@ -107,6 +243,7 @@ export function AutocompleteSearchInputComponent({ if (!currentValue) { setInputValue(""); + initialValueLoadedRef.current = null; // 값이 없어지면 초기화 } }, [currentValue, selectedData]); From b3ee2b50e8ad0da804de0c1f3f2e9e28e7c10388 Mon Sep 17 00:00:00 2001 From: SeongHyun Kim Date: Mon, 5 Jan 2026 18:41:49 +0900 Subject: [PATCH 008/104] =?UTF-8?q?fix:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20Select=20=ED=95=84=EB=93=9C=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EB=9D=BC=EB=B2=A8=EA=B0=92=20=EB=8C=80=EC=8B=A0=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EA=B0=92=20=EC=A0=80=EC=9E=A5=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - UniversalFormModalComponent.tsx: 카테고리 옵션 value를 valueLabel에서 valueCode로 변경 - 제어 로직 조건 비교 정상화 및 500 에러 해결 --- .../universal-form-modal/UniversalFormModalComponent.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/lib/registry/components/universal-form-modal/UniversalFormModalComponent.tsx b/frontend/lib/registry/components/universal-form-modal/UniversalFormModalComponent.tsx index 5f087b71..1484d4fd 100644 --- a/frontend/lib/registry/components/universal-form-modal/UniversalFormModalComponent.tsx +++ b/frontend/lib/registry/components/universal-form-modal/UniversalFormModalComponent.tsx @@ -866,9 +866,9 @@ export function UniversalFormModalComponent({ `/table-categories/${categoryTable}/${categoryColumn}/values` ); if (response.data?.success && response.data?.data) { - // 라벨값을 DB에 저장 (화면에 표시되는 값 그대로 저장) + // 코드값을 DB에 저장하고 라벨값을 화면에 표시 options = response.data.data.map((item: any) => ({ - value: item.valueLabel || item.value_label, + value: item.valueCode || item.value_code, label: item.valueLabel || item.value_label, })); } From 4f77c382077ca2a499f76d1badf8417dcacb79ad Mon Sep 17 00:00:00 2001 From: kjs Date: Tue, 6 Jan 2026 10:27:54 +0900 Subject: [PATCH 009/104] =?UTF-8?q?=EA=B6=8C=ED=95=9C=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/routes/cascadingAutoFillRoutes.ts | 1 + .../src/routes/cascadingConditionRoutes.ts | 1 + .../src/routes/cascadingHierarchyRoutes.ts | 1 + .../routes/cascadingMutualExclusionRoutes.ts | 1 + backend-node/src/services/adminService.ts | 18 ++++++++++++++++++ docs/노드플로우_개선사항.md | 1 + docs/메일발송_기능_사용_가이드.md | 1 + docs/즉시저장_버튼_액션_구현_계획서.md | 1 + .../admin/screenMng/screenMngList/page.tsx | 1 + frontend/contexts/ActiveTabContext.tsx | 1 + frontend/hooks/useAutoFill.ts | 1 + ..._임베딩_및_데이터_전달_시스템_구현_계획서.md | 1 + 화면_임베딩_시스템_Phase1-4_구현_완료.md | 1 + 화면_임베딩_시스템_충돌_분석_보고서.md | 1 + 14 files changed, 31 insertions(+) diff --git a/backend-node/src/routes/cascadingAutoFillRoutes.ts b/backend-node/src/routes/cascadingAutoFillRoutes.ts index a5107448..c1d69e9f 100644 --- a/backend-node/src/routes/cascadingAutoFillRoutes.ts +++ b/backend-node/src/routes/cascadingAutoFillRoutes.ts @@ -55,3 +55,4 @@ export default router; + diff --git a/backend-node/src/routes/cascadingConditionRoutes.ts b/backend-node/src/routes/cascadingConditionRoutes.ts index 22cd2d2b..bbc9384d 100644 --- a/backend-node/src/routes/cascadingConditionRoutes.ts +++ b/backend-node/src/routes/cascadingConditionRoutes.ts @@ -51,3 +51,4 @@ export default router; + diff --git a/backend-node/src/routes/cascadingHierarchyRoutes.ts b/backend-node/src/routes/cascadingHierarchyRoutes.ts index 79a1c6e8..35ced071 100644 --- a/backend-node/src/routes/cascadingHierarchyRoutes.ts +++ b/backend-node/src/routes/cascadingHierarchyRoutes.ts @@ -67,3 +67,4 @@ export default router; + diff --git a/backend-node/src/routes/cascadingMutualExclusionRoutes.ts b/backend-node/src/routes/cascadingMutualExclusionRoutes.ts index 352a05b5..29ac8ee4 100644 --- a/backend-node/src/routes/cascadingMutualExclusionRoutes.ts +++ b/backend-node/src/routes/cascadingMutualExclusionRoutes.ts @@ -55,3 +55,4 @@ export default router; + diff --git a/backend-node/src/services/adminService.ts b/backend-node/src/services/adminService.ts index 1b9280db..95d8befa 100644 --- a/backend-node/src/services/adminService.ts +++ b/backend-node/src/services/adminService.ts @@ -65,6 +65,13 @@ export class AdminService { } ); + // [임시 비활성화] 메뉴 권한 그룹 체크 - 모든 사용자에게 전체 메뉴 표시 + // TODO: 권한 체크 다시 활성화 필요 + logger.info( + `⚠️ [임시 비활성화] 권한 그룹 체크 스킵 - 사용자 ${userId}(${userType})에게 전체 메뉴 표시` + ); + + /* [원본 코드 - 권한 그룹 체크] if (userType === "COMPANY_ADMIN") { // 회사 관리자: 권한 그룹 기반 필터링 적용 if (userRoleGroups.length > 0) { @@ -141,6 +148,7 @@ export class AdminService { return []; } } + */ } else if ( menuType !== undefined && userType === "SUPER_ADMIN" && @@ -412,6 +420,15 @@ export class AdminService { let queryParams: any[] = [userLang]; let paramIndex = 2; + // [임시 비활성화] 메뉴 권한 그룹 체크 - 모든 사용자에게 전체 메뉴 표시 + // TODO: 권한 체크 다시 활성화 필요 + logger.info( + `⚠️ [임시 비활성화] getUserMenuList 권한 그룹 체크 스킵 - 사용자 ${userId}(${userType})에게 전체 메뉴 표시` + ); + authFilter = ""; + unionFilter = ""; + + /* [원본 코드 - getUserMenuList 권한 그룹 체크] if (userType === "SUPER_ADMIN") { // SUPER_ADMIN: 권한 그룹 체크 없이 해당 회사의 모든 메뉴 표시 logger.info(`✅ 좌측 사이드바 (SUPER_ADMIN): 회사 ${userCompanyCode}의 모든 메뉴 표시`); @@ -471,6 +488,7 @@ export class AdminService { return []; } } + */ // 2. 회사별 필터링 조건 생성 let companyFilter = ""; diff --git a/docs/노드플로우_개선사항.md b/docs/노드플로우_개선사항.md index c9349b94..32757807 100644 --- a/docs/노드플로우_개선사항.md +++ b/docs/노드플로우_개선사항.md @@ -587,3 +587,4 @@ const result = await executeNodeFlow(flowId, { + diff --git a/docs/메일발송_기능_사용_가이드.md b/docs/메일발송_기능_사용_가이드.md index 42900211..8bfe484e 100644 --- a/docs/메일발송_기능_사용_가이드.md +++ b/docs/메일발송_기능_사용_가이드.md @@ -360,3 +360,4 @@ + diff --git a/docs/즉시저장_버튼_액션_구현_계획서.md b/docs/즉시저장_버튼_액션_구현_계획서.md index c392eece..8d8fb497 100644 --- a/docs/즉시저장_버튼_액션_구현_계획서.md +++ b/docs/즉시저장_버튼_액션_구현_계획서.md @@ -346,3 +346,4 @@ const getComponentValue = (componentId: string) => { + diff --git a/frontend/app/(main)/admin/screenMng/screenMngList/page.tsx b/frontend/app/(main)/admin/screenMng/screenMngList/page.tsx index 3145d9d3..0327e122 100644 --- a/frontend/app/(main)/admin/screenMng/screenMngList/page.tsx +++ b/frontend/app/(main)/admin/screenMng/screenMngList/page.tsx @@ -127,3 +127,4 @@ export default function ScreenManagementPage() { ); } + diff --git a/frontend/contexts/ActiveTabContext.tsx b/frontend/contexts/ActiveTabContext.tsx index 228dc990..35081225 100644 --- a/frontend/contexts/ActiveTabContext.tsx +++ b/frontend/contexts/ActiveTabContext.tsx @@ -140,3 +140,4 @@ export const useActiveTabOptional = () => { + diff --git a/frontend/hooks/useAutoFill.ts b/frontend/hooks/useAutoFill.ts index caa1e826..7d78322b 100644 --- a/frontend/hooks/useAutoFill.ts +++ b/frontend/hooks/useAutoFill.ts @@ -197,3 +197,4 @@ export function applyAutoFillToFormData( + diff --git a/화면_임베딩_및_데이터_전달_시스템_구현_계획서.md b/화면_임베딩_및_데이터_전달_시스템_구현_계획서.md index f61ab2fb..1108475c 100644 --- a/화면_임베딩_및_데이터_전달_시스템_구현_계획서.md +++ b/화면_임베딩_및_데이터_전달_시스템_구현_계획서.md @@ -1689,3 +1689,4 @@ const 출고등록_설정: ScreenSplitPanel = { + diff --git a/화면_임베딩_시스템_Phase1-4_구현_완료.md b/화면_임베딩_시스템_Phase1-4_구현_완료.md index 0596216f..c20a94bc 100644 --- a/화면_임베딩_시스템_Phase1-4_구현_완료.md +++ b/화면_임베딩_시스템_Phase1-4_구현_완료.md @@ -536,3 +536,4 @@ const { data: config } = await getScreenSplitPanel(screenId); + diff --git a/화면_임베딩_시스템_충돌_분석_보고서.md b/화면_임베딩_시스템_충돌_분석_보고서.md index 4f0bfabb..77ad05b2 100644 --- a/화면_임베딩_시스템_충돌_분석_보고서.md +++ b/화면_임베딩_시스템_충돌_분석_보고서.md @@ -523,3 +523,4 @@ function ScreenViewPage() { + From 6bfc1a97a32e481f2242b48083fe0e050e6e727c Mon Sep 17 00:00:00 2001 From: kjs Date: Tue, 6 Jan 2026 11:43:26 +0900 Subject: [PATCH 010/104] =?UTF-8?q?=EB=B2=94=EC=9A=A9=20=ED=8F=BC=20?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20=EC=82=AC=EC=A0=84=ED=95=84=ED=84=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/controllers/entitySearchController.ts | 86 ++- .../entity-search-input/useEntitySearch.ts | 6 + .../ItemSelectionModal.tsx | 76 +- .../components/modal-repeater-table/types.ts | 3 + .../TableSectionRenderer.tsx | 43 +- .../UniversalFormModalConfigPanel.tsx | 686 +++++++++--------- .../modals/TableSectionSettingsModal.tsx | 186 +++-- 7 files changed, 689 insertions(+), 397 deletions(-) diff --git a/backend-node/src/controllers/entitySearchController.ts b/backend-node/src/controllers/entitySearchController.ts index 4d911c57..5f198c3f 100644 --- a/backend-node/src/controllers/entitySearchController.ts +++ b/backend-node/src/controllers/entitySearchController.ts @@ -107,14 +107,88 @@ export async function searchEntity(req: AuthenticatedRequest, res: Response) { } // 추가 필터 조건 (존재하는 컬럼만) + // 지원 연산자: =, !=, >, <, >=, <=, in, notIn, like + // 특수 키 형식: column__operator (예: division__in, name__like) const additionalFilter = JSON.parse(filterCondition as string); for (const [key, value] of Object.entries(additionalFilter)) { - if (existingColumns.has(key)) { - whereConditions.push(`${key} = $${paramIndex}`); - params.push(value); - paramIndex++; - } else { - logger.warn("엔티티 검색: 필터 조건에 존재하지 않는 컬럼 제외", { tableName, key }); + // 특수 키 형식 파싱: column__operator + let columnName = key; + let operator = "="; + + if (key.includes("__")) { + const parts = key.split("__"); + columnName = parts[0]; + operator = parts[1] || "="; + } + + if (!existingColumns.has(columnName)) { + logger.warn("엔티티 검색: 필터 조건에 존재하지 않는 컬럼 제외", { tableName, key, columnName }); + continue; + } + + // 연산자별 WHERE 조건 생성 + switch (operator) { + case "=": + whereConditions.push(`"${columnName}" = $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case "!=": + whereConditions.push(`"${columnName}" != $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case ">": + whereConditions.push(`"${columnName}" > $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case "<": + whereConditions.push(`"${columnName}" < $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case ">=": + whereConditions.push(`"${columnName}" >= $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case "<=": + whereConditions.push(`"${columnName}" <= $${paramIndex}`); + params.push(value); + paramIndex++; + break; + case "in": + // IN 연산자: 값이 배열이거나 쉼표로 구분된 문자열 + const inValues = Array.isArray(value) ? value : String(value).split(",").map(v => v.trim()); + if (inValues.length > 0) { + const placeholders = inValues.map((_, i) => `$${paramIndex + i}`).join(", "); + whereConditions.push(`"${columnName}" IN (${placeholders})`); + params.push(...inValues); + paramIndex += inValues.length; + } + break; + case "notIn": + // NOT IN 연산자 + const notInValues = Array.isArray(value) ? value : String(value).split(",").map(v => v.trim()); + if (notInValues.length > 0) { + const placeholders = notInValues.map((_, i) => `$${paramIndex + i}`).join(", "); + whereConditions.push(`"${columnName}" NOT IN (${placeholders})`); + params.push(...notInValues); + paramIndex += notInValues.length; + } + break; + case "like": + whereConditions.push(`"${columnName}"::text ILIKE $${paramIndex}`); + params.push(`%${value}%`); + paramIndex++; + break; + default: + // 알 수 없는 연산자는 등호로 처리 + whereConditions.push(`"${columnName}" = $${paramIndex}`); + params.push(value); + paramIndex++; + break; } } diff --git a/frontend/lib/registry/components/entity-search-input/useEntitySearch.ts b/frontend/lib/registry/components/entity-search-input/useEntitySearch.ts index 1fac26d6..2ae71595 100644 --- a/frontend/lib/registry/components/entity-search-input/useEntitySearch.ts +++ b/frontend/lib/registry/components/entity-search-input/useEntitySearch.ts @@ -53,6 +53,12 @@ export function useEntitySearch({ limit: pagination.limit.toString(), }); + console.log("[useEntitySearch] 검색 실행:", { + tableName, + filterCondition: filterConditionRef.current, + searchText: text, + }); + const response = await apiClient.get( `/entity-search/${tableName}?${params.toString()}` ); diff --git a/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx b/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx index ad73c317..1eca9fab 100644 --- a/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx +++ b/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx @@ -32,6 +32,7 @@ export function ItemSelectionModal({ onSelect, columnLabels = {}, modalFilters = [], + categoryColumns = [], }: ItemSelectionModalProps) { const [localSearchText, setLocalSearchText] = useState(""); const [selectedItems, setSelectedItems] = useState([]); @@ -41,6 +42,9 @@ export function ItemSelectionModal({ // 카테고리 옵션 상태 (categoryRef별로 로드된 옵션) const [categoryOptions, setCategoryOptions] = useState>({}); + + // 카테고리 코드 → 라벨 매핑 (테이블 데이터 표시용) + const [categoryLabelMap, setCategoryLabelMap] = useState>({}); // 모달 필터 값과 기본 filterCondition을 합친 최종 필터 조건 const combinedFilterCondition = useMemo(() => { @@ -152,6 +156,54 @@ export function ItemSelectionModal({ } }, [modalFilterValues]); + // 검색 결과가 변경되면 카테고리 값들의 라벨 조회 + useEffect(() => { + const loadCategoryLabels = async () => { + if (!open || categoryColumns.length === 0 || results.length === 0) { + return; + } + + // 현재 결과에서 카테고리 컬럼의 모든 고유한 값 수집 + // 쉼표로 구분된 다중 값도 개별적으로 수집 + const allCodes = new Set(); + for (const row of results) { + for (const col of categoryColumns) { + const val = row[col]; + if (val && typeof val === "string") { + // 쉼표로 구분된 다중 값 처리 + const codes = val.split(",").map((c) => c.trim()).filter(Boolean); + for (const code of codes) { + if (!categoryLabelMap[code]) { + allCodes.add(code); + } + } + } + } + } + + if (allCodes.size === 0) { + return; + } + + try { + const response = await apiClient.post("/table-categories/labels-by-codes", { + valueCodes: Array.from(allCodes), + }); + + if (response.data?.success && response.data.data) { + setCategoryLabelMap((prev) => ({ + ...prev, + ...response.data.data, + })); + } + } catch (error) { + console.error("카테고리 라벨 조회 실패:", error); + } + }; + + loadCategoryLabels(); + }, [open, results, categoryColumns]); + // 모달 필터 값 변경 핸들러 const handleModalFilterChange = (column: string, value: any) => { setModalFilterValues((prev) => ({ @@ -450,11 +502,25 @@ export function ItemSelectionModal({ )} - {validColumns.map((col) => ( - - {item[col] || "-"} - - ))} + {validColumns.map((col) => { + const rawValue = item[col]; + // 카테고리 컬럼이면 라벨로 변환 + const isCategory = categoryColumns.includes(col); + let displayValue = rawValue; + + if (isCategory && rawValue && typeof rawValue === "string") { + // 쉼표로 구분된 다중 값 처리 + const codes = rawValue.split(",").map((c) => c.trim()).filter(Boolean); + const labels = codes.map((code) => categoryLabelMap[code] || code); + displayValue = labels.join(", "); + } + + return ( + + {displayValue || "-"} + + ); + })} ); }) diff --git a/frontend/lib/registry/components/modal-repeater-table/types.ts b/frontend/lib/registry/components/modal-repeater-table/types.ts index ad373200..ba23c60e 100644 --- a/frontend/lib/registry/components/modal-repeater-table/types.ts +++ b/frontend/lib/registry/components/modal-repeater-table/types.ts @@ -202,4 +202,7 @@ export interface ItemSelectionModalProps { // 모달 내부 필터 (사용자 선택 가능) modalFilters?: ModalFilterConfig[]; + + // 카테고리 타입 컬럼 목록 (해당 컬럼은 코드 → 라벨로 변환하여 표시) + categoryColumns?: string[]; } diff --git a/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx b/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx index 405e2abf..fb1b2ea3 100644 --- a/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx +++ b/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx @@ -381,6 +381,34 @@ export function TableSectionRenderer({ const [dynamicOptions, setDynamicOptions] = useState<{ id: string; value: string; label: string }[]>([]); const [dynamicOptionsLoading, setDynamicOptionsLoading] = useState(false); const dynamicOptionsLoadedRef = React.useRef(false); + + // 소스 테이블의 카테고리 타입 컬럼 목록 + const [sourceCategoryColumns, setSourceCategoryColumns] = useState([]); + + // 소스 테이블의 카테고리 타입 컬럼 목록 로드 + useEffect(() => { + const loadCategoryColumns = async () => { + if (!tableConfig.source.tableName) return; + + try { + const response = await apiClient.get( + `/table-categories/${tableConfig.source.tableName}/columns` + ); + + if (response.data?.success && Array.isArray(response.data.data)) { + const categoryColNames = response.data.data.map( + (col: { columnName?: string; column_name?: string }) => + col.columnName || col.column_name || "" + ).filter(Boolean); + setSourceCategoryColumns(categoryColNames); + } + } catch (error) { + console.error("카테고리 컬럼 목록 조회 실패:", error); + } + }; + + loadCategoryColumns(); + }, [tableConfig.source.tableName]); // 조건부 테이블: 동적 옵션 로드 (optionSource 설정이 있는 경우) useEffect(() => { @@ -1281,16 +1309,25 @@ export function TableSectionRenderer({ const addRowButtonText = uiConfig?.addRowButtonText || "직접 입력"; // 기본 필터 조건 생성 (사전 필터만 - 모달 필터는 ItemSelectionModal에서 처리) + // 연산자별로 특수 키 형식 사용: column__operator (예: division__in) const baseFilterCondition: Record = useMemo(() => { const condition: Record = {}; if (filters?.preFilters) { for (const filter of filters.preFilters) { - // 간단한 "=" 연산자만 처리 (확장 가능) - if (filter.operator === "=") { + if (!filter.column || filter.value === undefined || filter.value === "") continue; + + const operator = filter.operator || "="; + + if (operator === "=") { + // 기본 등호 연산자는 그대로 전달 condition[filter.column] = filter.value; + } else { + // 다른 연산자는 특수 키 형식 사용: column__operator + condition[`${filter.column}__${operator}`] = filter.value; } } } + console.log("[TableSectionRenderer] baseFilterCondition:", condition, "preFilters:", filters?.preFilters); return condition; }, [filters?.preFilters]); @@ -1892,6 +1929,7 @@ export function TableSectionRenderer({ onSelect={handleConditionalAddItems} columnLabels={columnLabels} modalFilters={modalFiltersForModal} + categoryColumns={sourceCategoryColumns} /> ); @@ -2000,6 +2038,7 @@ export function TableSectionRenderer({ onSelect={handleAddItems} columnLabels={columnLabels} modalFilters={modalFiltersForModal} + categoryColumns={sourceCategoryColumns} /> ); diff --git a/frontend/lib/registry/components/universal-form-modal/UniversalFormModalConfigPanel.tsx b/frontend/lib/registry/components/universal-form-modal/UniversalFormModalConfigPanel.tsx index 27af68f1..7186ca7e 100644 --- a/frontend/lib/registry/components/universal-form-modal/UniversalFormModalConfigPanel.tsx +++ b/frontend/lib/registry/components/universal-form-modal/UniversalFormModalConfigPanel.tsx @@ -9,17 +9,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"; import { Badge } from "@/components/ui/badge"; import { Separator } from "@/components/ui/separator"; -import { - Plus, - Trash2, - GripVertical, - ChevronUp, - ChevronDown, - Settings, - Database, - Layout, - Table, -} from "lucide-react"; +import { Plus, Trash2, GripVertical, ChevronUp, ChevronDown, Settings, Database, Layout, Table } from "lucide-react"; import { cn } from "@/lib/utils"; import { apiClient } from "@/lib/api/client"; import { getNumberingRules } from "@/lib/api/numberingRule"; @@ -31,11 +21,7 @@ import { MODAL_SIZE_OPTIONS, SECTION_TYPE_OPTIONS, } from "./types"; -import { - defaultSectionConfig, - defaultTableSectionConfig, - generateSectionId, -} from "./config"; +import { defaultSectionConfig, defaultTableSectionConfig, generateSectionId } from "./config"; // 모달 import import { FieldDetailSettingsModal } from "./modals/FieldDetailSettingsModal"; @@ -45,22 +31,26 @@ import { TableSectionSettingsModal } from "./modals/TableSectionSettingsModal"; // 도움말 텍스트 컴포넌트 const HelpText = ({ children }: { children: React.ReactNode }) => ( -

{children}

+

{children}

); // 부모 화면에서 전달 가능한 필드 타입 interface AvailableParentField { - name: string; // 필드명 (columnName) - label: string; // 표시 라벨 + name: string; // 필드명 (columnName) + label: string; // 표시 라벨 sourceComponent?: string; // 출처 컴포넌트 (예: "TableList", "SplitPanelLayout2") - sourceTable?: string; // 출처 테이블명 + sourceTable?: string; // 출처 테이블명 } -export function UniversalFormModalConfigPanel({ config, onChange, allComponents = [] }: UniversalFormModalConfigPanelProps) { +export function UniversalFormModalConfigPanel({ + config, + onChange, + allComponents = [], +}: UniversalFormModalConfigPanelProps) { // 테이블 목록 const [tables, setTables] = useState<{ name: string; label: string }[]>([]); const [tableColumns, setTableColumns] = useState<{ - [tableName: string]: { name: string; type: string; label: string }[]; + [tableName: string]: { name: string; type: string; label: string; inputType?: string }[]; }>({}); // 부모 화면에서 전달 가능한 필드 목록 @@ -140,7 +130,7 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents } }); } - + // 좌측 패널 테이블 컬럼도 추출 const leftTableName = compConfig.leftPanel?.tableName; if (leftTableName) { @@ -152,7 +142,7 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents const colName = col.columnName || col.column_name; const colLabel = col.displayName || col.columnComment || col.column_comment || colName; // 중복 방지 - if (!fields.some(f => f.name === colName && f.sourceTable === leftTableName)) { + if (!fields.some((f) => f.name === colName && f.sourceTable === leftTableName)) { fields.push({ name: colName, label: colLabel, @@ -179,7 +169,7 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents columns.forEach((col: any) => { const colName = col.columnName || col.column_name; const colLabel = col.displayName || col.columnComment || col.column_comment || colName; - if (!fields.some(f => f.name === colName && f.sourceTable === tableName)) { + if (!fields.some((f) => f.name === colName && f.sourceTable === tableName)) { fields.push({ name: colName, label: colLabel, @@ -198,11 +188,11 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents // 4. 버튼 컴포넌트 - openModalWithData의 fieldMappings/dataMapping에서 소스 컬럼 추출 if (compType === "button-primary" || compType === "button" || compType === "button-secondary") { const action = compConfig.action || {}; - + // fieldMappings에서 소스 컬럼 추출 const fieldMappings = action.fieldMappings || []; fieldMappings.forEach((mapping: any) => { - if (mapping.sourceColumn && !fields.some(f => f.name === mapping.sourceColumn)) { + if (mapping.sourceColumn && !fields.some((f) => f.name === mapping.sourceColumn)) { fields.push({ name: mapping.sourceColumn, label: mapping.sourceColumn, @@ -211,11 +201,11 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents }); } }); - + // dataMapping에서 소스 컬럼 추출 const dataMapping = action.dataMapping || []; dataMapping.forEach((mapping: any) => { - if (mapping.sourceColumn && !fields.some(f => f.name === mapping.sourceColumn)) { + if (mapping.sourceColumn && !fields.some((f) => f.name === mapping.sourceColumn)) { fields.push({ name: mapping.sourceColumn, label: mapping.sourceColumn, @@ -237,7 +227,7 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents columns.forEach((col: any) => { const colName = col.columnName || col.column_name; const colLabel = col.displayName || col.columnComment || col.column_comment || colName; - if (!fields.some(f => f.name === colName)) { + if (!fields.some((f) => f.name === colName)) { fields.push({ name: colName, label: colLabel, @@ -253,8 +243,8 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents } // 중복 제거 (같은 name이면 첫 번째만 유지) - const uniqueFields = fields.filter((field, index, self) => - index === self.findIndex(f => f.name === field.name) + const uniqueFields = fields.filter( + (field, index, self) => index === self.findIndex((f) => f.name === field.name), ); setAvailableParentFields(uniqueFields); @@ -276,11 +266,19 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents const data = response.data?.data; if (response.data?.success && Array.isArray(data)) { setTables( - data.map((t: { tableName?: string; table_name?: string; displayName?: string; tableLabel?: string; table_label?: string }) => ({ - name: t.tableName || t.table_name || "", - // displayName 우선, 없으면 tableLabel, 그것도 없으면 테이블명 - label: t.displayName || t.tableLabel || t.table_label || "", - })), + data.map( + (t: { + tableName?: string; + table_name?: string; + displayName?: string; + tableLabel?: string; + table_label?: string; + }) => ({ + name: t.tableName || t.table_name || "", + // displayName 우선, 없으면 tableLabel, 그것도 없으면 테이블명 + label: t.displayName || t.tableLabel || t.table_label || "", + }), + ), ); } } catch (error) { @@ -308,10 +306,13 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents displayName?: string; columnComment?: string; column_comment?: string; + inputType?: string; + input_type?: string; }) => ({ name: c.columnName || c.column_name || "", type: c.dataType || c.data_type || "text", label: c.displayName || c.columnComment || c.column_comment || c.columnName || c.column_name || "", + inputType: c.inputType || c.input_type || "text", }), ), })); @@ -359,21 +360,24 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents ); // 섹션 관리 - const addSection = useCallback((type: "fields" | "table" = "fields") => { - const newSection: FormSectionConfig = { - ...defaultSectionConfig, - id: generateSectionId(), - title: type === "table" ? `테이블 섹션 ${config.sections.length + 1}` : `섹션 ${config.sections.length + 1}`, - type, - fields: type === "fields" ? [] : undefined, - tableConfig: type === "table" ? { ...defaultTableSectionConfig } : undefined, - }; - onChange({ - ...config, - sections: [...config.sections, newSection], - }); - }, [config, onChange]); - + const addSection = useCallback( + (type: "fields" | "table" = "fields") => { + const newSection: FormSectionConfig = { + ...defaultSectionConfig, + id: generateSectionId(), + title: type === "table" ? `테이블 섹션 ${config.sections.length + 1}` : `섹션 ${config.sections.length + 1}`, + type, + fields: type === "fields" ? [] : undefined, + tableConfig: type === "table" ? { ...defaultTableSectionConfig } : undefined, + }; + onChange({ + ...config, + sections: [...config.sections, newSection], + }); + }, + [config, onChange], + ); + // 섹션 타입 변경 const changeSectionType = useCallback( (sectionId: string, newType: "fields" | "table") => { @@ -381,7 +385,7 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents ...config, sections: config.sections.map((s) => { if (s.id !== sectionId) return s; - + if (newType === "table") { return { ...s, @@ -400,9 +404,9 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents }), }); }, - [config, onChange] + [config, onChange], ); - + // 테이블 섹션 설정 모달 열기 const handleOpenTableSectionSettings = (section: FormSectionConfig) => { setSelectedSection(section); @@ -487,293 +491,310 @@ export function UniversalFormModalConfigPanel({ config, onChange, allComponents }; return ( -
-
-
- {/* 모달 기본 설정 */} - - - -
- - 모달 기본 설정 -
-
- -
- - updateModalConfig({ title: e.target.value })} - className="h-9 text-sm w-full max-w-full" - /> - 모달 상단에 표시될 제목입니다 -
- -
- - - 모달 창의 크기를 선택하세요 -
- - {/* 저장 버튼 표시 설정 */} -
-
- updateModalConfig({ showSaveButton: checked === true })} - /> - +
+
+
+ {/* 모달 기본 설정 */} + + + +
+ + 모달 기본 설정
- 체크 해제 시 모달 하단의 저장 버튼이 숨겨집니다 -
- -
+ +
- + updateModalConfig({ saveButtonText: e.target.value })} - className="h-9 text-sm w-full max-w-full" + value={config.modal.title} + onChange={(e) => updateModalConfig({ title: e.target.value })} + className="h-9 w-full max-w-full text-sm" /> + 모달 상단에 표시될 제목입니다
+
- - updateModalConfig({ cancelButtonText: e.target.value })} - className="h-9 text-sm w-full max-w-full" - /> + + + 모달 창의 크기를 선택하세요
-
- - - - {/* 저장 설정 */} - - - -
- - 저장 설정 -
-
- -
-
- -

- {config.saveConfig.tableName || "(미설정)"} -

- {config.saveConfig.customApiSave?.enabled && config.saveConfig.customApiSave?.multiTable?.enabled && ( - - 다중 테이블 모드 - - )} + {/* 저장 버튼 표시 설정 */} +
+
+ updateModalConfig({ showSaveButton: checked === true })} + /> + +
+ 체크 해제 시 모달 하단의 저장 버튼이 숨겨집니다
- -
- - 데이터를 저장할 테이블과 방식을 설정합니다. -
- "저장 설정 열기"를 클릭하여 상세 설정을 변경하세요. -
- - - - {/* 섹션 구성 */} - - - -
- - 섹션 구성 - - {config.sections.length}개 - -
-
- - {/* 섹션 추가 버튼들 */} -
- -