Merge branch 'bo_fixes' into 'dev'
[BO] 조사원 현황 상세 새로고침시 탭 유지 See merge request korea-research/korea-research!116
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]');
|
||||
|
||||
getTabData($tab.data('tabType'), $tab.data('tabValue'));
|
||||
}, 500);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
$('.select-tab').on('click', function () {
|
||||
|
||||
@@ -55,10 +55,10 @@
|
||||
<input type="hidden" name="currentMonth" th:value="${currentMonth}">
|
||||
<input type="hidden" name="isPaging">
|
||||
|
||||
<div class="component-tab" data-active="tab1">
|
||||
<div class="component-tab" data-active="none">
|
||||
<div class="tab-head">
|
||||
<button type="button" class="tab-label" 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" data-tab-value="tab1">담당 임가 목록</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;">
|
||||
<select name="searchMonth" class="select-list search-month-container"
|
||||
onchange="getVisitHouseholdPercentage();
|
||||
@@ -178,37 +178,88 @@
|
||||
<div th:replace="researcher/modal/modal-household-visit:: modalFragment"></div>
|
||||
</section>
|
||||
<th:block layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
<script>
|
||||
const form = document.householdReqForm;
|
||||
const managementType = {
|
||||
VISIT: "방문조사",
|
||||
CALL: "전화상담",
|
||||
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 () {
|
||||
const tabButtons = document.querySelectorAll('.tab-label');
|
||||
tabButtons.forEach(button => {
|
||||
button.addEventListener('click', function () {
|
||||
const tabValue = this.getAttribute('data-tab-value');
|
||||
const form = document.householdReqForm;
|
||||
const tabType = this.getAttribute('data-tab-type');
|
||||
|
||||
form.page.value = 0; // 페이지 초기화
|
||||
document.getElementById('monthTab2').style.display = 'block';
|
||||
if (tabValue === 'tab1') {
|
||||
getHouseholdList(0);
|
||||
} else if (tabValue === 'tab2') {
|
||||
if (!form.searchMonth.value) {
|
||||
form.searchMonth.value = '[[${currentMonth}]]'; // 기본값 복원
|
||||
}
|
||||
getVisitHouseholdPercentage();
|
||||
getHouseholdVisitList();
|
||||
}
|
||||
|
||||
sessionStorage.setItem(tabStorageName, tabValue);
|
||||
sessionStorage.setItem(monthStorageName, form.searchMonth.value);
|
||||
|
||||
getTabData(tabType, tabValue);
|
||||
});
|
||||
});
|
||||
// 초기 데이터 로드 (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 f = document.householdReqForm;
|
||||
|
||||
Reference in New Issue
Block a user