From f35df29264ef15a7863a1687260c1c6bc7b6b36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Sat, 21 Feb 2026 01:06:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(WEB):=20=EC=88=98=EC=A3=BC=20=EA=B0=9C?= =?UTF-8?q?=EC=86=8C=20=EA=B7=B8=EB=A3=B9=ED=95=91=20=EA=B0=9C=EC=84=A0=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=9C=ED=92=88=EB=AA=85=20=ED=91=9C=EC=8B=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - floor+code 동일 시 인덱스 기반 균등 분배 로직 추가 - 제품명을 root_nodes[0].options.product_name에서 가져오도록 변경 --- src/components/orders/OrderRegistration.tsx | 44 ++++++++++++++++++++- src/components/orders/actions.ts | 4 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/components/orders/OrderRegistration.tsx b/src/components/orders/OrderRegistration.tsx index ccc09b3d..4a373b99 100644 --- a/src/components/orders/OrderRegistration.tsx +++ b/src/components/orders/OrderRegistration.tsx @@ -234,13 +234,55 @@ export function OrderRegistration({ }, []) ); - // 아이템을 개소별(floor+code)로 그룹핑 + // 아이템을 개소별로 그룹핑 const itemGroups = useMemo(() => { const calcItems = form.selectedQuotation?.calculationInputs?.items; if (!calcItems || calcItems.length === 0) { return null; } + // floor+code 고유 키 수 확인 (모두 같은 값인지 판별) + const uniqueLocKeys = new Set( + calcItems.map(ci => `${ci.floor || '-'}|${ci.code || '-'}`) + ); + + // 개소가 여러 개인데 floor+code가 모두 동일 → 인덱스 기반 균등 분배 + const useIndexGrouping = calcItems.length > 1 && uniqueLocKeys.size === 1; + + if (useIndexGrouping) { + const itemsPerLocation = Math.ceil(form.items.length / calcItems.length); + const result: Array<{ + key: string; + label: string; + productCode: string; + locationCount: number; + quantity: number; + amount: number; + items: OrderItem[]; + }> = []; + + calcItems.forEach((ci, idx) => { + const start = idx * itemsPerLocation; + const end = Math.min(start + itemsPerLocation, form.items.length); + const groupItems = form.items.slice(start, end); + const amount = groupItems.reduce((sum, item) => sum + (item.amount ?? 0), 0); + const floor = ci.floor || '-'; + const code = ci.code || '-'; + + result.push({ + key: `loc_${idx}`, + label: `${idx + 1}. ${floor} / ${code}`, + productCode: ci.productName || ci.productCode || '', + locationCount: 1, + quantity: ci.quantity ?? 1, + amount, + items: groupItems, + }); + }); + + return result; + } + // floor+code → calculationInput 매핑 (개소 메타정보) const locationMetaMap = new Map