Merge branch 'bo_fixes' into 'dev'

[BO] 조사원 현황 상세 새로고침시 탭 유지

See merge request korea-research/korea-research!116
This commit is contained in:
이강선 매니저/ST
2025-07-17 02:36:39 +00:00
2 changed files with 68 additions and 17 deletions

View File

@@ -252,7 +252,7 @@
let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]'); let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]');
getTabData($tab.data('tabType'), $tab.data('tabValue')); getTabData($tab.data('tabType'), $tab.data('tabValue'));
}, 500); }, 100);
}); });
$('.select-tab').on('click', function () { $('.select-tab').on('click', function () {

View File

@@ -55,10 +55,10 @@
<input type="hidden" name="currentMonth" th:value="${currentMonth}"> <input type="hidden" name="currentMonth" th:value="${currentMonth}">
<input type="hidden" name="isPaging"> <input type="hidden" name="isPaging">
<div class="component-tab" data-active="tab1"> <div class="component-tab" data-active="none">
<div class="tab-head"> <div class="tab-head">
<button type="button" class="tab-label" data-tab-value="tab1">담당 임가 목록</button> <button type="button" class="tab-label" data-tab-type="household" data-tab-value="tab1">담당 임가 목록</button>
<button type="button" class="tab-label" data-tab-value="tab2">임가방문정보</button> <button type="button" class="tab-label" data-tab-type="household-visit" data-tab-value="tab2">임가방문정보</button>
<div class="component-select select-date" id="monthTab2" style="display: none;"> <div class="component-select select-date" id="monthTab2" style="display: none;">
<select name="searchMonth" class="select-list search-month-container" <select name="searchMonth" class="select-list search-month-container"
onchange="getVisitHouseholdPercentage(); onchange="getVisitHouseholdPercentage();
@@ -178,37 +178,88 @@
<div th:replace="researcher/modal/modal-household-visit:: modalFragment"></div> <div th:replace="researcher/modal/modal-household-visit:: modalFragment"></div>
</section> </section>
<th:block layout:fragment="script"> <th:block layout:fragment="script">
<script th:inline="javascript"> <script>
const form = document.householdReqForm;
const managementType = { const managementType = {
VISIT: "방문조사", VISIT: "방문조사",
CALL: "전화상담", CALL: "전화상담",
ETC: "기타" ETC: "기타"
}; };
</script>
<script>
const tabStorageName = 'researcherTabActive';
const monthStorageName = 'searchMonth';
let tabActive = 'tab1';
let tabMonth = document.householdReqForm.searchMonth.value;
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);
}
if (sessionStorage.getItem(monthStorageName)) {
tabMonth = sessionStorage.getItem(monthStorageName);
document.householdReqForm.searchMonth.value = tabMonth;
}
}
} else if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
sessionStorage.removeItem(tabStorageName);
sessionStorage.removeItem(monthStorageName);
}
}
</script>
<script th:inline="javascript">
// 탭 클릭 시 함수 호출 // 탭 클릭 시 함수 호출
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const tabButtons = document.querySelectorAll('.tab-label'); const tabButtons = document.querySelectorAll('.tab-label');
tabButtons.forEach(button => { tabButtons.forEach(button => {
button.addEventListener('click', function () { button.addEventListener('click', function () {
const tabValue = this.getAttribute('data-tab-value'); const tabValue = this.getAttribute('data-tab-value');
const form = document.householdReqForm; const tabType = this.getAttribute('data-tab-type');
form.page.value = 0; // 페이지 초기화 form.page.value = 0; // 페이지 초기화
document.getElementById('monthTab2').style.display = 'block'; document.getElementById('monthTab2').style.display = 'block';
if (tabValue === 'tab1') {
getHouseholdList(0); sessionStorage.setItem(tabStorageName, tabValue);
} else if (tabValue === 'tab2') { sessionStorage.setItem(monthStorageName, form.searchMonth.value);
if (!form.searchMonth.value) {
form.searchMonth.value = '[[${currentMonth}]]'; // 기본값 복원 getTabData(tabType, tabValue);
}
getVisitHouseholdPercentage();
getHouseholdVisitList();
}
}); });
}); });
// 초기 데이터 로드 (tab1)
getHouseholdList(document.householdReqForm.page.value);
}); });
$(document).ready(() => {
setTimeout(function () {
let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]');
getTabData($tab.data('tabType'), $tab.data('tabValue'));
}, 100);
});
const getTabData = (tabType, tabValue) => {
switch (tabType) {
case 'household':
getHouseholdList(0);
break;
case 'household-visit':
document.getElementById('monthTab2').style.display = 'block';
if (!form.searchMonth.value) {
form.searchMonth.value = '[[${currentMonth}]]'; // 기본값 복원
}
getVisitHouseholdPercentage();
getHouseholdVisitList();
break;
}
sessionStorage.setItem(tabStorageName, tabValue);
sessionStorage.setItem(monthStorageName, document.householdReqForm.searchMonth.value);
document.querySelector('.component-tab').ui.setValue(tabValue);
}
// 담당 임가 목록 // 담당 임가 목록
const getHouseholdList = (pageNo) => { const getHouseholdList = (pageNo) => {
const f = document.householdReqForm; const f = document.householdReqForm;