diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index 681e9a3f..472de705 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -996,38 +996,27 @@ export class ButtonActionExecutor { } // ๐Ÿ†• ๋ฃจํŠธ ๋ ˆ๋ฒจ formData์—์„œ RepeaterFieldGroup์— ์ „๋‹ฌํ•  ๊ณตํ†ต ํ•„๋“œ ์ถ”์ถœ - // ์ฃผ๋ฌธ๋ฒˆํ˜ธ, ๋ฐœ์ฃผ๋ฒˆํ˜ธ ๋“ฑ ๋งˆ์Šคํ„ฐ-๋””ํ…Œ์ผ ๊ด€๊ณ„์—์„œ ํ•„์š”ํ•œ ํ•„๋“œ๋งŒ ๋ช…์‹œ์ ์œผ๋กœ ์ง€์ • - const masterDetailFields = [ - // ๋ฒˆํ˜ธ ํ•„๋“œ - "order_no", // ๋ฐœ์ฃผ๋ฒˆํ˜ธ - "sales_order_no", // ์ˆ˜์ฃผ๋ฒˆํ˜ธ - "shipment_no", // ์ถœํ•˜๋ฒˆํ˜ธ - "receipt_no", // ์ž…๊ณ ๋ฒˆํ˜ธ - "work_order_no", // ์ž‘์—…์ง€์‹œ๋ฒˆํ˜ธ - // ๊ฑฐ๋ž˜์ฒ˜ ํ•„๋“œ - "supplier_code", // ๊ณต๊ธ‰์ฒ˜ ์ฝ”๋“œ - "supplier_name", // ๊ณต๊ธ‰์ฒ˜ ์ด๋ฆ„ - "customer_code", // ๊ณ ๊ฐ ์ฝ”๋“œ - "customer_name", // ๊ณ ๊ฐ ์ด๋ฆ„ - // ๋‚ ์งœ ํ•„๋“œ - "order_date", // ๋ฐœ์ฃผ์ผ - "sales_date", // ์ˆ˜์ฃผ์ผ - "shipment_date", // ์ถœํ•˜์ผ - "receipt_date", // ์ž…๊ณ ์ผ - "due_date", // ๋‚ฉ๊ธฐ์ผ - // ๋‹ด๋‹น์ž/๋ฉ”๋ชจ ํ•„๋“œ - "manager", // ๋‹ด๋‹น์ž - "memo", // ๋ฉ”๋ชจ - "remark", // ๋น„๊ณ  - ]; + // ๊ทœ์น™ ๊ธฐ๋ฐ˜ ํ•„ํ„ฐ๋ง: ํ•˜๋“œ์ฝ”๋”ฉ ๋Œ€์‹  ํŒจํ„ด์œผ๋กœ ์ œ์™ธํ•  ํ•„๋“œ๋ฅผ ์ •์˜ + for (const [fieldName, value] of Object.entries(context.formData)) { + // ์ œ์™ธ ๊ทœ์น™ 1: comp_๋กœ ์‹œ์ž‘ํ•˜๋Š” ํ•„๋“œ (ํ•˜์œ„ ํ•ญ๋ชฉ ๋ฐฐ์—ด) + if (fieldName.startsWith("comp_")) continue; + // ์ œ์™ธ ๊ทœ์น™ 2: _numberingRuleId๋กœ ๋๋‚˜๋Š” ํ•„๋“œ (์ฑ„๋ฒˆ ๊ทœ์น™ ๋ฉ”ํƒ€ ์ •๋ณด) + if (fieldName.endsWith("_numberingRuleId")) continue; + // ์ œ์™ธ ๊ทœ์น™ 3: _๋กœ ์‹œ์ž‘ํ•˜๋Š” ํ•„๋“œ (๋‚ด๋ถ€ ๋ฉ”ํƒ€ ํ•„๋“œ) + if (fieldName.startsWith("_")) continue; + // ์ œ์™ธ ๊ทœ์น™ 4: ๋ฐฐ์—ด ํƒ€์ž… (ํ•˜์œ„ ํ•ญ๋ชฉ ๋ฐ์ดํ„ฐ) + if (Array.isArray(value)) continue; + // ์ œ์™ธ ๊ทœ์น™ 5: ๊ฐ์ฒด ํƒ€์ž… (๋ณต์žกํ•œ ๊ตฌ์กฐ ๋ฐ์ดํ„ฐ) - null ์ œ์™ธ + if (value !== null && typeof value === "object") continue; + // ์ œ์™ธ ๊ทœ์น™ 6: ๋นˆ ๊ฐ’ + if (value === undefined || value === "" || value === null) continue; + // ์ œ์™ธ ๊ทœ์น™ 7: ์ด๋ฏธ commonFields์— ์žˆ๋Š” ํ•„๋“œ (๋ฒ”์šฉ ํผ ๋ชจ๋‹ฌ์—์„œ ๊ฐ€์ ธ์˜จ ํ•„๋“œ) + if (fieldName in commonFields) continue; - for (const fieldName of masterDetailFields) { - const value = context.formData[fieldName]; - if (value !== undefined && value !== "" && value !== null && !(fieldName in commonFields)) { - commonFields[fieldName] = value; - } + // ์œ„ ๊ทœ์น™์— ํ•ด๋‹นํ•˜์ง€ ์•Š๋Š” ๋‹จ์ˆœ ๊ฐ’(๋ฌธ์ž์—ด, ์ˆซ์ž, ๋‚ ์งœ ๋“ฑ)์€ ๊ณตํ†ต ํ•„๋“œ๋กœ ์ „๋‹ฌ + commonFields[fieldName] = value; } - console.log("๐Ÿ“‹ [handleSave] ์ตœ์ข… ๊ณตํ†ต ํ•„๋“œ (๋งˆ์Šคํ„ฐ-๋””ํ…Œ์ผ ํ•„๋“œ ํฌํ•จ):", commonFields); + console.log("๐Ÿ“‹ [handleSave] ์ตœ์ข… ๊ณตํ†ต ํ•„๋“œ (๊ทœ์น™ ๊ธฐ๋ฐ˜ ์ž๋™ ์ถ”์ถœ):", commonFields); for (const item of parsedData) { // ๋ฉ”ํƒ€ ํ•„๋“œ ์ œ๊ฑฐ (eslint ๊ฒฝ๊ณ  ๋ฌด์‹œ - ์˜๋„์ ์œผ๋กœ ๋ถ„๋ฆฌ) @@ -1089,10 +1078,15 @@ export class ButtonActionExecutor { console.log("โœ… [handleSave] RepeaterFieldGroup UPDATE ์™„๋ฃŒ:", updateResult.data); } } catch (err) { - const error = err as { response?: { data?: unknown }; message?: string }; + const error = err as { response?: { data?: unknown; status?: number }; message?: string }; console.error( `โŒ [handleSave] RepeaterFieldGroup ์ €์žฅ ์‹คํŒจ (${repeaterTargetTable}):`, - error.response?.data || error.message, + { + status: error.response?.status, + data: error.response?.data, + message: error.message, + fullError: JSON.stringify(error.response?.data, null, 2), + }, ); } }