From d7408ce603ee298c0f9aa246061938b63e88255d Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Tue, 31 Mar 2026 09:17:13 +0900 Subject: [PATCH] =?UTF-8?q?fix(tkuser):=20vacation=5Ftype=5Fid=20=EB=B9=88?= =?UTF-8?q?=EA=B0=92=20fallback=20+=20getVacTypeId=20=EA=B7=BC=EB=B3=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getVacTypeId(): vacTypes 미로딩 시 DB 고정 ID fallback (ANNUAL_FULL→1, CARRYOVER→6, LONG_SERVICE→7) - form submit: vacation_type_id NaN이면 balance_type 기반 자동 결정 Co-Authored-By: Claude Opus 4.6 (1M context) --- user-management/web/index.html | 2 +- user-management/web/static/js/tkuser-vacations.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/user-management/web/index.html b/user-management/web/index.html index 3a0d539..e3553be 100644 --- a/user-management/web/index.html +++ b/user-management/web/index.html @@ -2424,7 +2424,7 @@ - + diff --git a/user-management/web/static/js/tkuser-vacations.js b/user-management/web/static/js/tkuser-vacations.js index dddcec5..09ecae7 100644 --- a/user-management/web/static/js/tkuser-vacations.js +++ b/user-management/web/static/js/tkuser-vacations.js @@ -320,10 +320,11 @@ async function autoCalcVacation() { } catch(e) { showToast(e.message, 'error'); } } -// vacation_type_id 자동 매핑 (vacTypes에서 type_code로 찾기) +// vacation_type_id 자동 매핑 (vacTypes에서 type_code로 찾기, fallback 내장) +const VAC_TYPE_FALLBACK = { ANNUAL_FULL: 1, CARRYOVER: 6, LONG_SERVICE: 7 }; function getVacTypeId(typeCode) { const t = vacTypes.find(v => v.type_code === typeCode); - return t ? t.id : null; + return t ? t.id : (VAC_TYPE_FALLBACK[typeCode] || 1); } // balance_type 변경 시 vacation_type_id + expires_at + 경조사 드롭다운 조정 @@ -444,9 +445,16 @@ document.getElementById('vacBalanceForm').addEventListener('submit', async e => })}); showToast('수정되었습니다.'); } else { + // vacation_type_id: hidden input에서 가져오되, 빈값이면 balance_type 기반 자동 결정 + let vacTypeId = parseInt(document.getElementById('vbType').value); + if (!vacTypeId || isNaN(vacTypeId)) { + const bt = document.getElementById('vbBalanceType').value; + const btMap = { AUTO: 'ANNUAL_FULL', MANUAL: 'ANNUAL_FULL', CARRY_OVER: 'CARRYOVER', LONG_SERVICE: 'LONG_SERVICE' }; + vacTypeId = getVacTypeId(btMap[bt] || 'ANNUAL_FULL'); + } await api('/vacations/balances', { method: 'POST', body: JSON.stringify({ user_id: parseInt(document.getElementById('vbUser').value), - vacation_type_id: parseInt(document.getElementById('vbType').value), + vacation_type_id: vacTypeId, year: parseInt(document.getElementById('vbYear').value), total_days: parseFloat(document.getElementById('vbTotalDays').value) || 0, used_days: parseFloat(document.getElementById('vbUsedDays').value) || 0,