feat:[근태현황] 년도/월 드롭박스 변경 시 시작일·종료일 자동 갱신

This commit is contained in:
김보곤
2026-03-20 10:42:29 +09:00
parent f256052f02
commit dbd06cead0

View File

@@ -277,6 +277,27 @@ function loadTabData(tab) {
document.getElementById('statsMonth').addEventListener('change', onPeriodChange);
function onPeriodChange() {
const year = parseInt(document.getElementById('statsYear').value);
const month = parseInt(document.getElementById('statsMonth').value);
// 해당 월의 시작일
const startDate = `${year}-${String(month).padStart(2, '0')}-01`;
// 해당 월의 마지막 날 계산 (현재 월이면 오늘 날짜)
const now = new Date();
const isCurrentMonth = (year === now.getFullYear() && month === (now.getMonth() + 1));
let endDate;
if (isCurrentMonth) {
endDate = now.toISOString().split('T')[0];
} else {
const lastDay = new Date(year, month, 0).getDate();
endDate = `${year}-${String(month).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`;
}
// 시작일/종료일 입력 필드 업데이트
document.querySelector('input[name="date_from"]').value = startDate;
document.querySelector('input[name="date_to"]').value = endDate;
refreshStats();
if (tabLoaded.calendar) {
tabLoaded.calendar = false;