fix: 채번 규칙 할당 로직 개선 - 복사 시 품목코드 자동생성 수정
This commit is contained in:
@@ -104,6 +104,20 @@ export const TextInputComponent: React.FC<TextInputComponentProps> = ({
|
||||
const currentFormValue = formData?.[component.columnName];
|
||||
const currentComponentValue = component.value;
|
||||
|
||||
// 🆕 채번 규칙이 설정되어 있으면 항상 _numberingRuleId를 formData에 설정
|
||||
// (값 생성 성공 여부와 관계없이, 저장 시점에 allocateCode를 호출하기 위함)
|
||||
if (testAutoGeneration.type === "numbering_rule" && testAutoGeneration.options?.numberingRuleId) {
|
||||
const ruleId = testAutoGeneration.options.numberingRuleId;
|
||||
if (ruleId && ruleId !== "undefined" && ruleId !== "null" && ruleId !== "") {
|
||||
const ruleIdKey = `${component.columnName}_numberingRuleId`;
|
||||
// formData에 아직 설정되지 않은 경우에만 설정
|
||||
if (isInteractive && onFormDataChange && !formData?.[ruleIdKey]) {
|
||||
onFormDataChange(ruleIdKey, ruleId);
|
||||
console.log("📝 채번 규칙 ID 사전 설정:", ruleIdKey, ruleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 자동생성된 값이 없고, 현재 값도 없을 때만 생성
|
||||
if (!autoGeneratedValue && !currentFormValue && !currentComponentValue) {
|
||||
isGeneratingRef.current = true; // 생성 시작 플래그
|
||||
@@ -144,13 +158,6 @@ export const TextInputComponent: React.FC<TextInputComponentProps> = ({
|
||||
if (isInteractive && onFormDataChange && component.columnName) {
|
||||
console.log("📝 formData 업데이트:", component.columnName, generatedValue);
|
||||
onFormDataChange(component.columnName, generatedValue);
|
||||
|
||||
// 채번 규칙 ID도 함께 저장 (저장 시점에 실제 할당하기 위함)
|
||||
if (testAutoGeneration.type === "numbering_rule" && testAutoGeneration.options?.numberingRuleId) {
|
||||
const ruleIdKey = `${component.columnName}_numberingRuleId`;
|
||||
onFormDataChange(ruleIdKey, testAutoGeneration.options.numberingRuleId);
|
||||
console.log("📝 채번 규칙 ID 저장:", ruleIdKey, testAutoGeneration.options.numberingRuleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!autoGeneratedValue && testAutoGeneration.type !== "none") {
|
||||
|
||||
Reference in New Issue
Block a user