거래처 품목정보 거래처품번/단가 입력 없이 저장되도록

This commit is contained in:
2026-01-06 15:01:50 +09:00
parent 64105bf525
commit e08c50c771
2 changed files with 32 additions and 3 deletions

View File

@@ -432,10 +432,25 @@ export const SelectedItemsDetailInputComponent: React.FC<SelectedItemsDetailInpu
const groups = componentConfig.fieldGroups || [];
const additionalFields = componentConfig.additionalFields || [];
itemsList.forEach((item) => {
itemsList.forEach((item, itemIndex) => {
// 각 그룹의 엔트리 배열들을 준비
const groupEntriesArrays: GroupEntry[][] = groups.map((group) => item.fieldGroups[group.id] || []);
// 🆕 모든 그룹이 비어있는지 확인
const allGroupsEmpty = groupEntriesArrays.every((arr) => arr.length === 0);
if (allGroupsEmpty) {
// 🆕 모든 그룹이 비어있으면 품목 기본 정보만으로 레코드 생성
// (거래처 품번/품명, 기간별 단가 없이도 저장 가능)
console.log("📝 [generateCartesianProduct] 모든 그룹이 비어있음 - 품목 기본 레코드 생성", {
itemIndex,
itemId: item.id,
});
// 빈 객체를 추가하면 parentKeys와 합쳐져서 기본 레코드가 됨
allRecords.push({});
return;
}
// Cartesian Product 재귀 함수
const cartesian = (arrays: GroupEntry[][], currentIndex: number, currentCombination: Record<string, any>) => {
if (currentIndex === arrays.length) {
@@ -446,7 +461,8 @@ export const SelectedItemsDetailInputComponent: React.FC<SelectedItemsDetailInpu
const currentGroupEntries = arrays[currentIndex];
if (currentGroupEntries.length === 0) {
// 현재 그룹에 데이터가 없으면 빈 조합으로 다음 그룹 진행
// 🆕 현재 그룹에 데이터가 없으면 빈 조합으로 다음 그룹 진행
// (그룹이 비어있어도 다른 그룹의 데이터로 레코드 생성)
cartesian(arrays, currentIndex + 1, currentCombination);
return;
}