리피터 입력폼 수정
This commit is contained in:
@@ -706,7 +706,12 @@ export class ButtonActionExecutor {
|
||||
if (!response.ok) {
|
||||
throw new Error(`저장 실패: ${response.statusText}`);
|
||||
}
|
||||
} else if (tableName && screenId) {
|
||||
}
|
||||
|
||||
// saveResult를 상위 스코프에서 정의 (repeaterSave 이벤트에서 사용)
|
||||
let saveResult: { success: boolean; data?: any; message?: string } | undefined;
|
||||
|
||||
if (tableName && screenId) {
|
||||
// DB에서 실제 기본키 조회하여 INSERT/UPDATE 자동 판단
|
||||
const primaryKeyResult = await DynamicFormApi.getTablePrimaryKeys(tableName);
|
||||
|
||||
@@ -732,8 +737,6 @@ export class ButtonActionExecutor {
|
||||
primaryKeys,
|
||||
});
|
||||
|
||||
let saveResult;
|
||||
|
||||
if (isUpdate) {
|
||||
// UPDATE 처리 - 부분 업데이트 사용 (원본 데이터가 있는 경우)
|
||||
console.log("🔄 UPDATE 모드로 저장:", {
|
||||
@@ -1088,19 +1091,28 @@ export class ButtonActionExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// 메인 저장 건너뛰기 조건: RepeatScreenModal 또는 RepeaterFieldGroup에서 같은 테이블 처리
|
||||
// 🆕 UnifiedRepeater 전역 등록 확인
|
||||
// @ts-ignore - window에 동적 속성 사용
|
||||
const unifiedRepeaterTables = Array.from(window.__unifiedRepeaterInstances || []);
|
||||
|
||||
// 메인 저장 건너뛰기 조건:
|
||||
// 1. RepeatScreenModal 또는 RepeaterFieldGroup에서 같은 테이블 처리
|
||||
// 2. UnifiedRepeater가 같은 테이블에 존재 (리피터 데이터에 메인 폼 데이터 병합되어 저장됨)
|
||||
const shouldSkipMainSave =
|
||||
repeatScreenModalTables.includes(tableName) || repeaterFieldGroupTables.includes(tableName);
|
||||
repeatScreenModalTables.includes(tableName) ||
|
||||
repeaterFieldGroupTables.includes(tableName) ||
|
||||
unifiedRepeaterTables.includes(tableName);
|
||||
|
||||
if (shouldSkipMainSave) {
|
||||
console.log(
|
||||
`⏭️ [handleSave] ${tableName} 메인 저장 건너뜀 (RepeaterFieldGroup/RepeatScreenModal에서 처리)`,
|
||||
`⏭️ [handleSave] ${tableName} 메인 저장 건너뜀`,
|
||||
{
|
||||
repeatScreenModalTables,
|
||||
repeaterFieldGroupTables,
|
||||
unifiedRepeaterTables,
|
||||
},
|
||||
);
|
||||
saveResult = { success: true, message: "RepeaterFieldGroup/RepeatScreenModal에서 처리" };
|
||||
saveResult = { success: true, message: "RepeaterFieldGroup/RepeatScreenModal/UnifiedRepeater에서 처리" };
|
||||
} else {
|
||||
saveResult = await DynamicFormApi.saveFormData({
|
||||
screenId,
|
||||
@@ -1229,6 +1241,40 @@ export class ButtonActionExecutor {
|
||||
// 저장 성공 후 이벤트 발생
|
||||
window.dispatchEvent(new CustomEvent("closeEditModal")); // EditModal 닫기
|
||||
window.dispatchEvent(new CustomEvent("saveSuccessInModal")); // ScreenModal 연속 등록 모드 처리
|
||||
|
||||
// UnifiedRepeater 저장 이벤트 발생 (메인 폼 데이터 + 리피터 데이터 병합 저장)
|
||||
// 🔧 formData를 리피터에 전달하여 각 행에 병합 저장
|
||||
const savedId = saveResult?.data?.id || saveResult?.data?.data?.id || formData.id || context.formData?.id;
|
||||
|
||||
// 메인 폼 데이터 구성 (사용자 정보 포함)
|
||||
const mainFormData = {
|
||||
...formData,
|
||||
writer: formData.writer || context.userId,
|
||||
created_by: context.userId,
|
||||
updated_by: context.userId,
|
||||
company_code: formData.company_code || context.companyCode,
|
||||
};
|
||||
|
||||
// _numberingRuleId 등 메타 필드 제거
|
||||
for (const key of Object.keys(mainFormData)) {
|
||||
if (key.endsWith("_numberingRuleId") || key.startsWith("_")) {
|
||||
delete mainFormData[key];
|
||||
}
|
||||
}
|
||||
|
||||
console.log("🔗 [handleSave] repeaterSave 이벤트 발생:", {
|
||||
savedId,
|
||||
tableName: context.tableName,
|
||||
mainFormDataKeys: Object.keys(mainFormData),
|
||||
saveResultData: saveResult?.data
|
||||
});
|
||||
window.dispatchEvent(new CustomEvent("repeaterSave", {
|
||||
detail: {
|
||||
parentId: savedId,
|
||||
tableName: context.tableName,
|
||||
mainFormData, // 🆕 메인 폼 데이터 전달
|
||||
}
|
||||
}));
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user