[BO] 임가현황 새로고침 Tab 유지, 등록 현황 엑셀다운로드

This commit is contained in:
김현주
2025-07-02 13:54:24 +09:00
parent 5d058f9683
commit 78c5441f90
3 changed files with 1029 additions and 285 deletions

View File

@@ -164,8 +164,17 @@
<span class="btn-txt">목록</span>
</button>
</div>
<div class="btns-col-2 align-right" th:unless="${activeProfile != 'local'}">
<button type="button" class="btn">
<div class="btns-col-2 align-right _excelDownload" th:unless="${activeProfile != 'local'}">
<button type="button" class="btn" data-tab-type="daily-record" data-tab-value="tab1" onclick="goExcel(this)">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn" data-tab-type="forest-product" data-tab-value="tab2" onclick="goExcel(this)">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn" data-tab-type="bank-auto-transfer" data-tab-value="tab3" onclick="goExcel(this)">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn" data-tab-type="household-visit" data-tab-value="tab4" onclick="goExcel(this)">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button>
</div>
@@ -218,12 +227,32 @@
</script>
<script>
const tabStorageName = 'tabActive';
let tabActive = 'tab1';
window.onpageshow = function (event) {
if (event.persisted || (window.performance && window.performance.navigation.type == 1)) {
if (('sessionStorage' in window) && window['sessionStorage'] !== null) {
if (sessionStorage.getItem(tabStorageName)) {
tabActive = sessionStorage.getItem(tabStorageName);
}
}
} else if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
sessionStorage.removeItem(tabStorageName);
}
}
$(document).ready(() => {
getDailyRecords();
$('._excelDownload button').hide();
setTimeout(function () {
let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]');
getTabData($tab.data('tabType'), $tab.data('tabValue'));
}, 500);
});
$('.select-tab').on('click', function () {
getTabData(this.dataset.tabType);
getTabData(this.dataset.tabType, this.dataset.tabValue);
});
</script>
@@ -236,7 +265,7 @@
getTabData(selectedTab.dataset.tabType);
}
const getTabData = (tabType) => {
const getTabData = (tabType, tabValue) => {
switch (tabType) {
case 'daily-record': // 일계부 등록 현황
getDailyRecords();
@@ -251,6 +280,13 @@
getVisitInfo();
break;
}
sessionStorage.setItem(tabStorageName, tabValue);
document.querySelector('.component-tab').ui.setValue(tabValue);
$('._excelDownload button').hide();
$('._excelDownload button[data-tab-value="' + tabValue + '"]').show();
}
</script>
@@ -341,6 +377,36 @@
}
}
</script>
<script>
// 엑셀 다운로드
const goExcel = (el) => {
let url = '';
if (el.dataset.tabValue === 'tab1') {
url = $('.tab-content .daily-record-list').is(':hidden') ? '' : '/api/household/dailyRecordsStatus/excel';
} else if (el.dataset.tabValue === 'tab2') {
url = '';
} else if (el.dataset.tabValue === 'tab3') {
url = '';
} else if (el.dataset.tabValue === 'tab4') {
url = '';
}
console.log('goExcel', el.dataset.tabValue, url);
const f = document.reqForm;
const data = $(f).serializeObject();
// size 를 제거하면 전체 목록을 가져온다.
delete data.size;
if (url !== '') {
location.href = url + '?' + new URLSearchParams(data).toString();
} else {
console.warn('엑셀 다운르도 경로 없음.')
}
}
</script>
</section>
</html>