diff --git a/frontend/lib/registry/components/rack-structure/RackStructureComponent.tsx b/frontend/lib/registry/components/rack-structure/RackStructureComponent.tsx index 77eadca0..4a8f66a5 100644 --- a/frontend/lib/registry/components/rack-structure/RackStructureComponent.tsx +++ b/frontend/lib/registry/components/rack-structure/RackStructureComponent.tsx @@ -298,11 +298,16 @@ export const RackStructureComponent: React.FC = ({ warehouseName: fieldMapping.warehouseNameField ? formData[fieldMapping.warehouseNameField] : undefined, - // 카테고리 값은 라벨로 변환 + // 카테고리 값은 라벨로 변환 (화면 표시용) floor: getCategoryLabel(rawFloor?.toString()), zone: getCategoryLabel(rawZone), locationType: getCategoryLabel(rawLocationType), status: getCategoryLabel(rawStatus), + // 카테고리 코드 원본값 (DB 쿼리/저장용) + floorCode: rawFloor?.toString(), + zoneCode: rawZone?.toString(), + locationTypeCode: rawLocationType?.toString(), + statusCode: rawStatus?.toString(), }; console.log("🏗️ [RackStructure] context 생성:", { @@ -399,8 +404,12 @@ export const RackStructureComponent: React.FC = ({ // 기존 데이터 조회를 위한 값 추출 (useMemo 객체 참조 문제 방지) const warehouseCodeForQuery = context.warehouseCode; - const floorForQuery = context.floor; // 라벨 값 (예: "1층") - const zoneForQuery = context.zone; // 라벨 값 (예: "A구역") + // DB 쿼리 시에는 카테고리 코드 사용 (코드로 통일) + const floorForQuery = (context as any).floorCode || context.floor; + const zoneForQuery = (context as any).zoneCode || context.zone; + // 화면 표시용 라벨 + const floorLabel = context.floor; + const zoneLabel = context.zone; // 기존 데이터 조회 (창고/층/구역이 변경될 때마다) useEffect(() => { @@ -426,7 +435,7 @@ export const RackStructureComponent: React.FC = ({ // DB에는 라벨 값으로 저장되어 있으므로 라벨 값으로 필터링 // equals 연산자를 사용하여 정확한 일치 검색 (ILIKE가 아닌 = 연산자 사용) const searchParams = { - warehouse_id: { value: warehouseCodeForQuery, operator: "equals" }, + warehouse_code: { value: warehouseCodeForQuery, operator: "equals" }, floor: { value: floorForQuery, operator: "equals" }, zone: { value: zoneForQuery, operator: "equals" }, }; @@ -597,18 +606,20 @@ export const RackStructureComponent: React.FC = ({ for (let level = 1; level <= cond.levels; level++) { const { code, name } = generateLocationCode(row, level); // 테이블 컬럼명과 동일하게 생성 + // DB 저장 시에는 카테고리 코드 사용 (코드로 통일) + const ctxAny = context as any; locations.push({ row_num: String(row), level_num: String(level), location_code: code, location_name: name, - location_type: context?.locationType || "선반", - status: context?.status || "사용", - // 추가 필드 (테이블 컬럼명과 동일) + location_type: ctxAny?.locationTypeCode || context?.locationType || "선반", + status: ctxAny?.statusCode || context?.status || "사용", + // 추가 필드 (테이블 컬럼명과 동일) - 카테고리 코드 사용 warehouse_code: context?.warehouseCode, warehouse_name: context?.warehouseName, - floor: context?.floor, - zone: context?.zone, + floor: ctxAny?.floorCode || context?.floor, + zone: ctxAny?.zoneCode || context?.zone, }); } } @@ -930,13 +941,14 @@ export const RackStructureComponent: React.FC = ({ {idx + 1} {loc.location_code} {loc.location_name} - {loc.floor || context?.floor || "1"} - {loc.zone || context?.zone || "A"} + {/* 미리보기에서는 카테고리 코드를 라벨로 변환하여 표시 */} + {getCategoryLabel(loc.floor) || context?.floor || "1"} + {getCategoryLabel(loc.zone) || context?.zone || "A"} {loc.row_num.padStart(2, "0")} {loc.level_num} - {loc.location_type} + {getCategoryLabel(loc.location_type) || loc.location_type} - ))} diff --git a/frontend/lib/registry/components/rack-structure/types.ts b/frontend/lib/registry/components/rack-structure/types.ts index 8670d4a0..76214972 100644 --- a/frontend/lib/registry/components/rack-structure/types.ts +++ b/frontend/lib/registry/components/rack-structure/types.ts @@ -72,10 +72,15 @@ export interface RackStructureContext { warehouseId?: string; // 창고 ID warehouseCode?: string; // 창고 코드 (예: WH001) warehouseName?: string; // 창고명 (예: 제1창고) - floor?: string; // 층 (예: 1) - zone?: string; // 구역 (예: A) - locationType?: string; // 위치 유형 (예: 선반) - status?: string; // 사용 여부 (예: 사용) + floor?: string; // 층 라벨 (예: 1층) - 화면 표시용 + zone?: string; // 구역 라벨 (예: A구역) - 화면 표시용 + locationType?: string; // 위치 유형 라벨 (예: 선반) + status?: string; // 사용 여부 라벨 (예: 사용) + // 카테고리 코드 (DB 저장/쿼리용) + floorCode?: string; // 층 카테고리 코드 (예: CATEGORY_767659DCUF) + zoneCode?: string; // 구역 카테고리 코드 (예: CATEGORY_82925656Q8) + locationTypeCode?: string; // 위치 유형 카테고리 코드 + statusCode?: string; // 사용 여부 카테고리 코드 } // 컴포넌트 Props diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index 05777580..58d1bf4c 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -1467,11 +1467,12 @@ export class ButtonActionExecutor { console.log("🔍 [handleRackStructureBatchSave] 기존 데이터 중복 체크:", { warehouseCode, floor, zone }); try { + // search 파라미터를 사용하여 백엔드에서 필터링 (filters는 백엔드에서 처리 안됨) const existingResponse = await DynamicFormApi.getTableData(tableName, { - filters: { - warehouse_code: warehouseCode, - floor: floor, - zone: zone, + search: { + warehouse_code: { value: warehouseCode, operator: "equals" }, + floor: { value: floor, operator: "equals" }, + zone: { value: zone, operator: "equals" }, }, page: 1, pageSize: 1000,