Files
korea-research/admin/src/main/resources/templates/researcher/detail.html

399 lines
17 KiB
HTML

<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<th layout:fragment="content">
<section>
<table class="type-form confirm" th:object="${researcherDto}" >
<colgroup>
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
</colgroup>
<tbody>
<tr>
<th>아이디</th>
<td>
<span th:text="*{id}"></span>
</td>
<th>이름</th>
<td>
<span th:text="*{name}"></span>
</td>
<th>휴대폰번호</th>
<td>
<span th:text="*{phone}"></span>
</td>
</tr>
<tr>
<th>실사</th>
<td>
<span th:text="*{regionMainCodeName}"></span>
</td>
<th>계정사용여부</th>
<td>
<span th:text="*{accountDisabledFlag}"></span>
</td>
</tr>
</tbody>
</table>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<a th:href="@{'/settings/admins/update/' + ${researcherDto.id}}">
<button type="button" class="btn">
<span class="btn-txt">정보수정</span>
</button>
</a>
</div>
</div>
</section>
<section>
<form autocomplete="off" method="get" name="householdReqForm" th:object="${reqVO}">
<input type="hidden" name="currentMonth" th:value="${currentMonth}">
<input type="hidden" name="isPaging">
<div class="component-tab" data-active="tab1">
<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>
<div class="component-select select-date" id="monthTab2" style="display: none;">
<select name="searchMonth" class="select-list search-month-container" onchange="getHouseholdVisitList();">
<option th:each="month : ${monthList}"
th:value="${month.value}"
th:text="${month.label}"
th:selected="${month.value == currentMonth}">
</option>
</select>
</div>
</div>
<!-- hidden parameters -->
<input name="page" th:field="*{page}" type="hidden"/>
<input name="adminSeq" th:field="${researcherDto.seq}" type="hidden"/>
<div class="tab-body">
<div class="tab-content" data-tab-value="tab1">
<div class="content-inner">
<section class="table-group">
<div class="table-tit-group">
<h3>총 <strong id="household-totalElements"></strong>건</h3>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn small" th:data-researcher-seq="${researcherDto.seq}" th:data-region-main-code="${researcherDto.regionMainCode}" th:data-researcher-name="${researcherDto.name}" onclick="showHouseholdModal(this)">
<span class="btn-txt">임가 매핑</span>
</button>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>임가번호</th>
<th>경영주명</th>
<th>휴대폰번호</th>
<th>실사</th>
<th>지역</th>
<th>세부지역</th>
<th>업종 대분류</th>
<th>업종 중분류1</th>
<th>유지여부</th>
</tr>
</thead>
<tbody id="household-list">
</tbody>
</table>
</section>
<div class="row paging"></div>
</div>
</div>
<div class="tab-content" data-tab-value="tab2">
<div class="content-inner">
<article class="summary-area">
<ul>
<li>
<p>당월 1차 방문</p>
<span><strong id="firstVisitCount">6</strong>/<strong class="totalHouseholdCount">6</strong>(<strong id="firstVisitPercentage">6</strong>%)</span>
</li>
<li>
<p>당월 2차 방문</p>
<span><strong id="secondVisitCount">6</strong>/<strong class="totalHouseholdCount">6</strong>(<strong id="secondVisitPercentage">6</strong>%)</span>
</li>
<li>
<p>답례품 전달</p>
<span><strong id="giftSentCount">6</strong>/<strong class="totalHouseholdCount">6</strong>(<strong id="giftSentPercentage">6</strong>%)</span>
</li>
</ul>
</article>
<section class="table-group">
<div class="table-tit-group">
<h3>총 <strong id="household-visit-totalElements"></strong>건</h3>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn small btn-secondary" onClick="goRemove();">
<span class="btn-txt">삭제</span>
</button>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>
<input onchange="toggleCheckbox(this);" type="checkbox"/>
</th>
<th>임가번호</th>
<th>경영주명</th>
<th>방문일</th>
<th>관리분야</th>
<th>내용</th>
<th>작성일</th>
<th>답례품 전달</th>
</tr>
</thead>
<tbody id="household-visit-list">
</tbody>
</table>
</section>
</div>
</div>
</div>
</div>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<div class="btns-col-1">
<button type="button" class="btn" onclick="location.href='/researcher/researchers'">
<span class="btn-txt">목록</span>
</button>
</div>
</div>
</div>
</form>
<div th:replace="common/modal-household-mapping:: modalFragment"></div>
<div th:replace="researcher/modal/modal-household-visit:: modalFragment"></div>
</section>
<th:block layout:fragment="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;
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();
}
});
});
// 초기 데이터 로드 (tab1)
getHouseholdList(document.householdReqForm.page.value);
});
// 담당 임가 목록
const getHouseholdList = (pageNo) => {
const f = document.householdReqForm;
f.page.value = pageNo;
f.isPaging.value = true;
let dataOj = $(f).serializeObject();
ajaxUtil._ajaxMethod(
'/api/researcher/mappingHouseholdList',
dataOj,
function (response) {
$('#household-totalElements').text(response.totalElements);
// List 구성하기
const tbody = $('#household-list');
tbody.empty();
document.getElementById('monthTab2').style.display = 'none';
$(response.content).each((idx, ct) => {
tbody.append(
`
<tr data-id="${ct.seq}">
<td><a href="/households/${ct.seq}?recordMonth=${f.currentMonth.value}">${ct.householdNum}</a></td>
<td><a href="/households/${ct.seq}?recordMonth=${f.currentMonth.value}">${ct.ownerName || '-'}</a></td>
<td>${ct.phone || '-'}</td>
<td>${ct.regionMainCodeName || '-'}</td>
<td>${ct.regionSubCodeName || '-'}</td>
<td>${ct.regionDetailCodeName || '-'}</td>
<td>${ct.industryLargeCodeName || '-'}</td>
<td>${ct.industryMiddleCodeName || '-'}</td>
<td>${ct.panelFlag || '-'}</td>
</tr>
`
);
});
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="9" class="text-center text-muted">담당임가정보가 존재하지 않습니다.</td>
</tr>
`);
}
// Pagination 구성하기
const paging = $('.paging');
paging.empty();
paging.append(
uiUtil.getPagingUI(pageNo, response.size, response.totalPages,
(movePageNo) => {
f.page.value = movePageNo;
getHouseholdList(movePageNo);
}));
},
function (code, rstData) {
},
'get',
'json',
null
);
}
// 임가 방문 퍼센트
const getVisitHouseholdPercentage=()=>{
const f = document.householdReqForm;
let dataObj = {
seq: f.seq.value,
searchMonth: f.searchMonth.value,
};
ajaxUtil._ajaxMethod(
'/api/researcher/visitHousehold/percentage',
dataObj,
function (response) {
$('#firstVisitCount').text(response.firstVisitCount);
$('#secondVisitCount').text(response.secondVisitCount);
$('#giftSentCount').text(response.giftSentCount);
$('#firstVisitPercentage').text(response.firstVisitPercentage);
$('#secondVisitPercentage').text(response.secondVisitPercentage);
$('#giftSentPercentage').text(response.giftSentPercentage);
$('.totalHouseholdCount').text(response.totalHouseholdCount);
},
function (code, rstData) {
},
'get',
'json',
null
);
}
// 임가 방문 정보
const getHouseholdVisitList = () => {
const f = document.householdReqForm;
let dataObj = {
seq: f.seq.value,
searchMonth: f.searchMonth.value,
};
ajaxUtil._ajaxMethod(
'/api/researcher/visitHousehold/list',
dataObj,
function (response) {
$('#household-visit-totalElements').text(response.length);
// List 구성하기
const tbody = $('#household-visit-list');
tbody.empty();
$(response).each((idx, ct) => {
tbody.append(
`
<tr data-id="${ct.id}">
<td>
<label>
<input class="form-check-input" name="selectIds" type="checkbox" value="${ct.id}"/>
</label>
</td>
<td><a href="#" onclick="showHouseholdModal2(${ct.id});">${ct.householdNum}</a></td>
<td>${ct.ownerName}</td>
<td>${ct.visitDate}</td>
<td>${ct.managementType}</td>
<td><a href="javascript:void(0);" class="ellipsis" style="text-decoration: none;">${ct.content}</a></td>
<td>${ct.updatedAt}</td>
<td>${ct.isGiftSentFlag}</td>
</tr>
`
);
});
if (response.length == 0) {
tbody.append(`
<tr>
<td colspan="8" class="text-center text-muted">임가 방문 정보가 존재하지 않습니다.</td>
</tr>
`);
}
},
function (code, rstData) {
},
'get',
'json',
null
);
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=selectIds]').prop("checked", oj.checked);
}
function goRemove() {
const selectIds = $('input[name=selectIds]:checked').map(function() {
return parseInt(this.value);
}).get();
if (!selectIds.length) {
alert('삭제할 항목을 선택해주세요.');
return;
}
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
const f = document.householdReqForm;
const data = $(f).serializeObject();
ajaxUtil._ajaxMethod(
'/api/researcher/visitHousehold/remove',
JSON.stringify(selectIds),
function (response) {
if(response > 0){
alert('선택한 임가 방문 정보가 삭제되었습니다.');
getHouseholdVisitList();
} else {
alert('삭제에 실패했습니다.');
}
},
function (code, rstData) {
console.error("Error in goRemove: ", err);
alert('삭제 중 오류가 발생했습니다.');
},
'delete',
'json',
null
);
}
}
</script>
</th:block>
</html>