lhj #356
|
|
@ -308,6 +308,14 @@ export function UniversalFormModalComponent({
|
|||
console.log("[UniversalFormModal] beforeFormSave 이벤트 수신");
|
||||
console.log("[UniversalFormModal] 설정된 필드 목록:", Array.from(configuredFields));
|
||||
|
||||
// 🆕 시스템 필드 병합: id는 설정 여부와 관계없이 항상 전달 (UPDATE/INSERT 판단용)
|
||||
// - 신규 등록: formData.id가 없으므로 영향 없음
|
||||
// - 편집 모드: formData.id가 있으면 메인 테이블 UPDATE에 사용
|
||||
if (formData.id !== undefined && formData.id !== null && formData.id !== "") {
|
||||
event.detail.formData.id = formData.id;
|
||||
console.log(`[UniversalFormModal] 시스템 필드 병합: id =`, formData.id);
|
||||
}
|
||||
|
||||
// UniversalFormModal에 설정된 필드만 병합 (채번 규칙 포함)
|
||||
// 외부 formData에 이미 값이 있어도 UniversalFormModal 값으로 덮어씀
|
||||
// (UniversalFormModal이 해당 필드의 주인이므로)
|
||||
|
|
|
|||
|
|
@ -1971,19 +1971,43 @@ export class ButtonActionExecutor {
|
|||
}
|
||||
});
|
||||
|
||||
console.log("📦 [handleUniversalFormModalTableSectionSave] 메인 테이블 저장 데이터:", mainRowToSave);
|
||||
// 🆕 메인 테이블 UPDATE/INSERT 판단
|
||||
// - formData.id가 있으면 편집 모드 → UPDATE
|
||||
// - formData.id가 없으면 신규 등록 → INSERT
|
||||
const existingMainId = formData.id;
|
||||
const isMainUpdate = existingMainId !== undefined && existingMainId !== null && existingMainId !== "";
|
||||
|
||||
const mainSaveResult = await DynamicFormApi.saveFormData({
|
||||
screenId: screenId!,
|
||||
tableName: tableName!,
|
||||
data: mainRowToSave,
|
||||
console.log("📦 [handleUniversalFormModalTableSectionSave] 메인 테이블 저장 데이터:", mainRowToSave);
|
||||
console.log("📦 [handleUniversalFormModalTableSectionSave] UPDATE/INSERT 판단:", {
|
||||
existingMainId,
|
||||
isMainUpdate,
|
||||
});
|
||||
|
||||
let mainSaveResult: { success: boolean; data?: any; message?: string };
|
||||
|
||||
if (isMainUpdate) {
|
||||
// 🔄 편집 모드: UPDATE 실행
|
||||
console.log("🔄 [handleUniversalFormModalTableSectionSave] 메인 테이블 UPDATE 실행, ID:", existingMainId);
|
||||
mainSaveResult = await DynamicFormApi.updateFormData(existingMainId, {
|
||||
tableName: tableName!,
|
||||
data: mainRowToSave,
|
||||
});
|
||||
mainRecordId = existingMainId;
|
||||
} else {
|
||||
// ➕ 신규 등록: INSERT 실행
|
||||
console.log("➕ [handleUniversalFormModalTableSectionSave] 메인 테이블 INSERT 실행");
|
||||
mainSaveResult = await DynamicFormApi.saveFormData({
|
||||
screenId: screenId!,
|
||||
tableName: tableName!,
|
||||
data: mainRowToSave,
|
||||
});
|
||||
mainRecordId = mainSaveResult.data?.id || null;
|
||||
}
|
||||
|
||||
if (!mainSaveResult.success) {
|
||||
throw new Error(mainSaveResult.message || "메인 데이터 저장 실패");
|
||||
}
|
||||
|
||||
mainRecordId = mainSaveResult.data?.id || null;
|
||||
console.log("✅ [handleUniversalFormModalTableSectionSave] 메인 테이블 저장 완료, ID:", mainRecordId);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue