Compare commits
2 Commits
183f68e89a
...
7d6bff49aa
| Author | SHA1 | Date |
|---|---|---|
|
|
7d6bff49aa | |
|
|
4421ccaa71 |
|
|
@ -1608,6 +1608,66 @@ export class ButtonActionExecutor {
|
||||||
return { handled: false, success: false };
|
return { handled: false, success: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🎯 채번 규칙 할당 처리 (저장 시점에 실제 순번 증가)
|
||||||
|
console.log("🔍 [handleUniversalFormModalTableSectionSave] 채번 규칙 할당 체크 시작");
|
||||||
|
|
||||||
|
const fieldsWithNumbering: Record<string, string> = {};
|
||||||
|
|
||||||
|
// commonFieldsData와 modalData에서 채번 규칙이 설정된 필드 찾기
|
||||||
|
for (const [key, value] of Object.entries(modalData)) {
|
||||||
|
if (key.endsWith("_numberingRuleId") && value) {
|
||||||
|
const fieldName = key.replace("_numberingRuleId", "");
|
||||||
|
fieldsWithNumbering[fieldName] = value as string;
|
||||||
|
console.log(`🎯 [handleUniversalFormModalTableSectionSave] 채번 필드 발견: ${fieldName} → 규칙 ${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// formData에서도 확인 (모달 외부에 있을 수 있음)
|
||||||
|
for (const [key, value] of Object.entries(formData)) {
|
||||||
|
if (key.endsWith("_numberingRuleId") && value && !fieldsWithNumbering[key.replace("_numberingRuleId", "")]) {
|
||||||
|
const fieldName = key.replace("_numberingRuleId", "");
|
||||||
|
fieldsWithNumbering[fieldName] = value as string;
|
||||||
|
console.log(
|
||||||
|
`🎯 [handleUniversalFormModalTableSectionSave] 채번 필드 발견 (formData): ${fieldName} → 규칙 ${value}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("📋 [handleUniversalFormModalTableSectionSave] 채번 규칙이 설정된 필드:", fieldsWithNumbering);
|
||||||
|
|
||||||
|
// 🔥 저장 시점에 allocateCode 호출하여 실제 순번 증가
|
||||||
|
if (Object.keys(fieldsWithNumbering).length > 0) {
|
||||||
|
console.log("🎯 [handleUniversalFormModalTableSectionSave] 채번 규칙 할당 시작 (allocateCode 호출)");
|
||||||
|
const { allocateNumberingCode } = await import("@/lib/api/numberingRule");
|
||||||
|
|
||||||
|
for (const [fieldName, ruleId] of Object.entries(fieldsWithNumbering)) {
|
||||||
|
try {
|
||||||
|
console.log(
|
||||||
|
`🔄 [handleUniversalFormModalTableSectionSave] ${fieldName} 필드에 대해 allocateCode 호출: ${ruleId}`,
|
||||||
|
);
|
||||||
|
const allocateResult = await allocateNumberingCode(ruleId);
|
||||||
|
|
||||||
|
if (allocateResult.success && allocateResult.data?.generatedCode) {
|
||||||
|
const newCode = allocateResult.data.generatedCode;
|
||||||
|
console.log(
|
||||||
|
`✅ [handleUniversalFormModalTableSectionSave] ${fieldName} 새 코드 할당: ${commonFieldsData[fieldName]} → ${newCode}`,
|
||||||
|
);
|
||||||
|
commonFieldsData[fieldName] = newCode;
|
||||||
|
} else {
|
||||||
|
console.warn(
|
||||||
|
`⚠️ [handleUniversalFormModalTableSectionSave] ${fieldName} 코드 할당 실패, 기존 값 유지:`,
|
||||||
|
allocateResult.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (allocateError) {
|
||||||
|
console.error(`❌ [handleUniversalFormModalTableSectionSave] ${fieldName} 코드 할당 오류:`, allocateError);
|
||||||
|
// 오류 시 기존 값 유지
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("✅ [handleUniversalFormModalTableSectionSave] 채번 규칙 할당 완료");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 사용자 정보 추가
|
// 사용자 정보 추가
|
||||||
if (!context.userId) {
|
if (!context.userId) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue