모달에서 저장 안되는 문제 수정
This commit is contained in:
@@ -129,9 +129,57 @@ export class DynamicFormService {
|
||||
dataToInsert.updated_by = updated_by;
|
||||
}
|
||||
if (company_code && tableColumns.includes("company_code")) {
|
||||
dataToInsert.company_code = company_code;
|
||||
// company_code가 UUID 형태(36자)라면 하이픈 제거하여 32자로 만듦
|
||||
let processedCompanyCode = company_code;
|
||||
if (
|
||||
typeof company_code === "string" &&
|
||||
company_code.length === 36 &&
|
||||
company_code.includes("-")
|
||||
) {
|
||||
processedCompanyCode = company_code.replace(/-/g, "");
|
||||
console.log(
|
||||
`🔧 company_code 길이 조정: "${company_code}" -> "${processedCompanyCode}" (${processedCompanyCode.length}자)`
|
||||
);
|
||||
}
|
||||
// 여전히 32자를 초과하면 앞의 32자만 사용
|
||||
if (
|
||||
typeof processedCompanyCode === "string" &&
|
||||
processedCompanyCode.length > 32
|
||||
) {
|
||||
processedCompanyCode = processedCompanyCode.substring(0, 32);
|
||||
console.log(
|
||||
`⚠️ company_code 길이 제한: 앞의 32자로 자름 -> "${processedCompanyCode}"`
|
||||
);
|
||||
}
|
||||
dataToInsert.company_code = processedCompanyCode;
|
||||
}
|
||||
|
||||
// 날짜/시간 문자열을 적절한 형태로 변환
|
||||
Object.keys(dataToInsert).forEach((key) => {
|
||||
const value = dataToInsert[key];
|
||||
|
||||
// 날짜/시간 관련 컬럼명 패턴 체크 (regdate, created_at, updated_at 등)
|
||||
if (
|
||||
typeof value === "string" &&
|
||||
(key.toLowerCase().includes("date") ||
|
||||
key.toLowerCase().includes("time") ||
|
||||
key.toLowerCase().includes("created") ||
|
||||
key.toLowerCase().includes("updated") ||
|
||||
key.toLowerCase().includes("reg"))
|
||||
) {
|
||||
// YYYY-MM-DD HH:mm:ss 형태의 문자열을 Date 객체로 변환
|
||||
if (value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/)) {
|
||||
console.log(`📅 날짜 변환: ${key} = "${value}" -> Date 객체`);
|
||||
dataToInsert[key] = new Date(value);
|
||||
}
|
||||
// YYYY-MM-DD 형태의 문자열을 Date 객체로 변환
|
||||
else if (value.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
||||
console.log(`📅 날짜 변환: ${key} = "${value}" -> Date 객체`);
|
||||
dataToInsert[key] = new Date(value + "T00:00:00");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 존재하지 않는 컬럼 제거
|
||||
Object.keys(dataToInsert).forEach((key) => {
|
||||
if (!tableColumns.includes(key)) {
|
||||
|
||||
Reference in New Issue
Block a user