ix: 부모-자식 모달 데이터 전달 문제 해결 및 미사용 multiRowSave 기능 제거

InteractiveScreenViewerDynamic: 생성 모드에서 formData를 initialData로 전달하도록 수정
UniversalFormModal: saveMultipleRows 함수 및 multiRowSave 관련 코드 전체 제거
types/config: MultiRowSaveConfig 인터페이스 및 기본값 제거
FieldDetailSettingsModal: receiveFromParent UI 옵션 제거
SaveSettingsModal: 저장 모드 설명 개선
DB: multiRowSave.enabled=true인 화면 3개 설정 수정
This commit is contained in:
SeongHyun Kim
2026-01-07 17:42:40 +09:00
parent 42d1a3fc5e
commit 6f4c9b7fdd
9 changed files with 40 additions and 229 deletions

View File

@@ -139,6 +139,7 @@ export function UniversalFormModalComponent({
}: UniversalFormModalComponentProps & { _initialData?: any; _originalData?: any; _groupedData?: any }) {
// initialData 우선순위: 직접 전달된 prop > DynamicComponentRenderer에서 전달된 prop
const initialData = propInitialData || _initialData;
// 설정 병합
const config: UniversalFormModalConfig = useMemo(() => {
const componentConfig = component?.config || {};
@@ -155,11 +156,6 @@ export function UniversalFormModalComponent({
...defaultConfig.saveConfig,
...propConfig?.saveConfig,
...componentConfig.saveConfig,
multiRowSave: {
...defaultConfig.saveConfig.multiRowSave,
...propConfig?.saveConfig?.multiRowSave,
...componentConfig.saveConfig?.multiRowSave,
},
afterSave: {
...defaultConfig.saveConfig.afterSave,
...propConfig?.saveConfig?.afterSave,
@@ -1504,118 +1500,6 @@ export function UniversalFormModalComponent({
formData,
]);
// 다중 행 저장 (겸직 등)
const saveMultipleRows = useCallback(async () => {
const { multiRowSave } = config.saveConfig;
if (!multiRowSave) return;
let { commonFields = [], repeatSectionId = "" } = multiRowSave;
const { typeColumn, mainTypeValue, subTypeValue, mainSectionFields = [] } = multiRowSave;
// 공통 필드가 설정되지 않은 경우, 기본정보 섹션의 모든 필드를 공통 필드로 사용
if (commonFields.length === 0) {
const nonRepeatableSections = config.sections.filter((s) => !s.repeatable);
commonFields = nonRepeatableSections.flatMap((s) => (s.fields || []).map((f) => f.columnName));
}
// 반복 섹션 ID가 설정되지 않은 경우, 첫 번째 반복 섹션 사용
if (!repeatSectionId) {
const repeatableSection = config.sections.find((s) => s.repeatable);
if (repeatableSection) {
repeatSectionId = repeatableSection.id;
}
}
// 반복 섹션 데이터
const repeatItems = repeatSections[repeatSectionId] || [];
// 저장할 행들 생성
const rowsToSave: any[] = [];
// 공통 데이터 (모든 행에 적용)
const commonData: any = {};
commonFields.forEach((fieldName) => {
if (formData[fieldName] !== undefined) {
commonData[fieldName] = formData[fieldName];
}
});
// 메인 섹션 필드 데이터 (메인 행에만 적용되는 부서/직급 등)
const mainSectionData: any = {};
mainSectionFields.forEach((fieldName) => {
if (formData[fieldName] !== undefined) {
mainSectionData[fieldName] = formData[fieldName];
}
});
// 메인 행 (공통 데이터 + 메인 섹션 필드)
const mainRow: any = { ...commonData, ...mainSectionData };
if (typeColumn) {
mainRow[typeColumn] = mainTypeValue || "main";
}
rowsToSave.push(mainRow);
// 반복 섹션 행들 (공통 데이터 + 반복 섹션 필드)
for (const item of repeatItems) {
const subRow: any = { ...commonData };
// 반복 섹션의 필드 값 추가
const repeatSection = config.sections.find((s) => s.id === repeatSectionId);
(repeatSection?.fields || []).forEach((field) => {
if (item[field.columnName] !== undefined) {
subRow[field.columnName] = item[field.columnName];
}
});
if (typeColumn) {
subRow[typeColumn] = subTypeValue || "concurrent";
}
rowsToSave.push(subRow);
}
// 저장 시점 채번규칙 처리 (메인 행만)
for (const section of config.sections) {
if (section.repeatable || section.type === "table") continue;
for (const field of section.fields || []) {
if (field.numberingRule?.enabled && field.numberingRule?.ruleId) {
// generateOnSave 또는 generateOnOpen 모두 저장 시 실제 순번 할당
const shouldAllocate = field.numberingRule.generateOnSave || field.numberingRule.generateOnOpen;
if (shouldAllocate) {
const response = await allocateNumberingCode(field.numberingRule.ruleId);
if (response.success && response.data?.generatedCode) {
// 모든 행에 동일한 채번 값 적용 (공통 필드인 경우)
if (commonFields.includes(field.columnName)) {
rowsToSave.forEach((row) => {
row[field.columnName] = response.data?.generatedCode;
});
} else {
rowsToSave[0][field.columnName] = response.data?.generatedCode;
}
}
}
}
}
}
// 모든 행 저장
for (let i = 0; i < rowsToSave.length; i++) {
const row = rowsToSave[i];
// 빈 객체 체크
if (Object.keys(row).length === 0) {
continue;
}
const response = await apiClient.post(`/table-management/tables/${config.saveConfig.tableName}/add`, row);
if (!response.data?.success) {
throw new Error(response.data?.message || `${i + 1}번째 행 저장 실패`);
}
}
}, [config.sections, config.saveConfig, formData, repeatSections]);
// 다중 테이블 저장 (범용)
const saveWithMultiTable = useCallback(async () => {
const { customApiSave } = config.saveConfig;
@@ -1863,16 +1747,13 @@ export function UniversalFormModalComponent({
setSaving(true);
try {
const { multiRowSave, customApiSave } = config.saveConfig;
const { customApiSave } = config.saveConfig;
// 커스텀 API 저장 모드
// 커스텀 API 저장 모드 (다중 테이블)
if (customApiSave?.enabled) {
await saveWithCustomApi();
} else if (multiRowSave?.enabled) {
// 다중 행 저장
await saveMultipleRows();
} else {
// 단일 저장
// 단일 테이블 저장
await saveSingleRow();
}
@@ -1886,7 +1767,7 @@ export function UniversalFormModalComponent({
}
// onSave 콜백은 저장 완료 알림용으로만 사용
// 실제 저장은 이미 위에서 완료됨 (saveSingleRow 또는 saveMultipleRows)
// 실제 저장은 이미 위에서 완료됨
// EditModal 등 부모 컴포넌트의 저장 로직이 다시 실행되지 않도록
// _saveCompleted 플래그를 포함하여 전달
if (onSave) {
@@ -1916,7 +1797,6 @@ export function UniversalFormModalComponent({
onSave,
validateRequiredFields,
saveSingleRow,
saveMultipleRows,
saveWithCustomApi,
]);