Files
korea-research/admin/src/main/resources/templates/households/tab/household-visit.html

132 lines
5.3 KiB
HTML

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
layout:decorate="~{layout/layout}">
<div class="layer-wrap" th:fragment="tabFragment">
<div class="tab-content household-visit" data-tab-value="tab4">
<div class="content-inner">
<section class="table-group">
<div class="table-tit-group">
<h3></h3>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn small btn-secondary" onclick="goDeleteVisitInfo();">
<span class=" btn-txt">삭제</span>
</button>
<button type="button" class="btn small btn-primary" onclick="showVisitInfoModal();">
<span class="btn-txt">추가</span>
</button>
</div>
</div>
</div>
<table id="household-visit">
<thead>
<tr>
<th>선택</th>
<th>방문일</th>
<th>관리분야</th>
<th>내용</th>
<th>최종 수정자</th>
<th>답례품 전달</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</section>
</div>
</div>
<script th:inline="javascript">
// 임가방문정보 조회
const getVisitInfo = () => {
const f = document.reqForm;
ajaxUtil._ajaxMethod(
'/api/household/visitInfos',
{
householdSeq: f.householdSeq.value,
recordMonth: f.recordMonth.value
},
(response) => { // 성공
console.log("임가 방문정보 조회 : ", response);
const tbody = $('.tab-content.household-visit tbody');
tbody.empty();
if(response.length === 0) {
tbody.append(`<tr><td colspan="6" style="text-align: center;">등록이 필요합니다.</td></tr>`);
return;
}
let tmpl = '';
$(response).each((idx, item) => {
tmpl +=
`
<tr>
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="visitRemoveIds_${item.id}" name="visitRemoveIds" value="${item.id}">
</label>
</div>
</td>
<td>${ifNullHyphen(item.visitDate)}</td> <!-- 방문일 -->
<td>${ifNullHyphen(managementType[item.managementType])}</td> <!-- 관리분야 -->
<td class="underline"><a href="javascript:void(0);" onclick="showVisitInfoModal(${item.id});">${ifNullHyphen(item.content)}</a></td> <!-- 내용 -->
<td>
${item.updatedBy}<br>
(${item.updatedAt})
</td><!-- 최종 수정자 -->
<td>${item.isGiftSent ? "전달 완료" : "미전달"}</td> <!-- 답례품 전달 -->
</tr>
`;
});
tbody.append(tmpl);
},
function (code, rstData) { // 실패
console.log("error : ", code);
},
'get',
'json'
);
}
// 임가방문정보 삭제
const goDeleteVisitInfo = () => {
const checkedIds = Array.from(
document.querySelectorAll('input[name="visitRemoveIds"]:checked')
).map(el => Number(el.value));
if(checkedIds.length <= 0) {
alert("임가방문정보를 선택해주세요.");
return
}
if(confirm("선택하신 내용을 삭제하시겠습니까? 삭제한 항목은 복구할 수 없습니다.")) {
const f = document.reqForm;
ajaxUtil._ajaxMethod(
'/api/visitInfo/remove',
JSON.stringify({
householdSeq: f.householdSeq.value,
visitRemoveIds: checkedIds
}),
(response) => { // 성공
alert("방문정보가 삭제되었습니다.");
getVisitInfo();
},
function (code, rstData) {
if(code == 422) alert(rstData.responseText);
},
'delete',
'json',
{ handle422Type: 'alert' }
);
}
}
</script>
</div>
</html>