fix(tkuser): vacation_type_id 빈값 fallback + getVacTypeId 근본 수정
- 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) <noreply@anthropic.com>
This commit is contained in:
@@ -2424,7 +2424,7 @@
|
||||
<script src="/static/js/tkuser-issue-types.js?v=2026031401"></script>
|
||||
<script src="/static/js/tkuser-workplaces.js?v=2026031401"></script>
|
||||
<script src="/static/js/tkuser-tasks.js?v=2026031401"></script>
|
||||
<script src="/static/js/tkuser-vacations.js?v=2026033102"></script>
|
||||
<script src="/static/js/tkuser-vacations.js?v=2026033103"></script>
|
||||
<script src="/static/js/tkuser-vacation-settings.js?v=2026032501"></script>
|
||||
<script src="/static/js/tkuser-layout-map.js?v=2026031401"></script>
|
||||
<script src="/static/js/tkuser-partners.js?v=2026031601"></script>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user