223 lines
9.6 KiB
HTML
223 lines
9.6 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 bank-auto-transfer" data-tab-value="tab3">
|
|
<div class="content-inner">
|
|
<div class="content-inner">
|
|
<!-- 수입 -->
|
|
<section class="table-group">
|
|
<div class="table-tit-group">
|
|
<h3>수입 <strong>(<span id="bankIncomeCount">0</span>건)</strong></h3>
|
|
<div class="component-btns bottom-btn-group">
|
|
<div class="btns-row align-right">
|
|
<button type="button" class="btn small btn-secondary" data-remove-type="INCOME" onclick="removeBankConfirm(this);">
|
|
<span class=" btn-txt">삭제</span>
|
|
</button>
|
|
<button type="button" class="btn small btn-primary" onclick="showBankIncomeModal();">
|
|
<span class="btn-txt">추가</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<table id="table-bank-income">
|
|
<thead>
|
|
<tr>
|
|
<th>선택</th>
|
|
<th>재배형태</th>
|
|
<th>수입의 종류</th>
|
|
<th>대상</th>
|
|
<th>수입원</th>
|
|
<th>수량</th>
|
|
<th>단위</th>
|
|
<th>현금(원)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<!-- 지출 -->
|
|
<section class="table-group">
|
|
<div class="table-tit-group">
|
|
<h3>지출 <strong>(<span id="bankExpenseCount">0</span>건)</strong></h3>
|
|
<div class="component-btns bottom-btn-group">
|
|
<div class="btns-row align-right">
|
|
<button type="button" class="btn small btn-secondary" data-remove-type="EXPENSE" onclick="removeBankConfirm(this);">
|
|
<span class=" btn-txt">삭제</span>
|
|
</button>
|
|
<button type="button" class="btn small btn-primary" onclick="showBankExpenseModal();">
|
|
<span class="btn-txt">추가</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<table id="table-bank-expense">
|
|
<thead>
|
|
<tr>
|
|
<th>선택</th>
|
|
<th>지출의 종류</th>
|
|
<th>용도</th>
|
|
<th>수량</th>
|
|
<th>단위</th>
|
|
<th>현금(원)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script th:inline="javascript">
|
|
// 은행자동이체내역 조회
|
|
const getBankAutoTransfer = () => {
|
|
const f = document.reqForm;
|
|
|
|
ajaxUtil._ajaxMethod(
|
|
'/api/household/bankAutoTransfer',
|
|
{
|
|
householdSeq: f.householdSeq.value,
|
|
recordMonth: f.recordMonth.value
|
|
},
|
|
(response) => { // 성공
|
|
console.log("은행자동이체내역 조회 : ", response);
|
|
gridBankIncomeTable(response.incomes);
|
|
gridBankExpenseTable(response.expenses);
|
|
},
|
|
function (code, rstData) { // 실패
|
|
console.log("error : ", code);
|
|
},
|
|
'get',
|
|
'json'
|
|
);
|
|
}
|
|
|
|
// 은행자동이체내역 수입 테이블 그리기
|
|
const gridBankIncomeTable = (data) => {
|
|
const tbody = $('#table-bank-income tbody');
|
|
tbody.empty();
|
|
|
|
$('#bankIncomeCount').text(data.length);
|
|
if(data.length === 0) {
|
|
tbody.append(`<tr><td colspan="8" style="text-align: center;">등록된 내용이 없습니다.</td></tr>`);
|
|
return;
|
|
}
|
|
|
|
let tmpl = '';
|
|
$(data).each((idx, item) => {
|
|
tmpl +=
|
|
`
|
|
<tr>
|
|
<td>
|
|
<div class="component-input">
|
|
<label class="checkbox-inner">
|
|
<input type="checkbox" id="income_removeIds_${item.id}" name="removeIds" value="${item.id}">
|
|
</label>
|
|
</div>
|
|
</td>
|
|
<td>${ifNullHyphen(item.cropText)}</td> <!-- 재배형태 -->
|
|
<td class="underline"><a href="javascript:void(0);" onclick="showBankIncomeModal(${item.id})">${ifNullHyphen(item.categoryText)}</td> <!-- 수입의 종류 -->
|
|
<td>${ifNullHyphen(item.target)}</td><!-- 대상 -->
|
|
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 수입원 -->
|
|
<td class="align-right">${formatNumberWithComma(item.count)}</td><!-- 수량 -->
|
|
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
|
<td class="align-right">${formatNumberWithComma(item.price)}</td><!-- 현금(원) -->
|
|
</tr>
|
|
`;
|
|
});
|
|
|
|
tbody.append(tmpl);
|
|
}
|
|
|
|
// 은행자동이체내역 수출 테이블 그리기
|
|
const gridBankExpenseTable = (data) => {
|
|
const tbody = $('#table-bank-expense tbody');
|
|
tbody.empty();
|
|
|
|
$('#bankExpenseCount').text(data.length);
|
|
if(data.length === 0) {
|
|
tbody.append(`<tr><td colspan="6" style="text-align: center;">등록된 내용이 없습니다.</td></tr>`);
|
|
return;
|
|
}
|
|
|
|
let tmpl = '';
|
|
$(data).each((idx, item) => {
|
|
tmpl +=
|
|
`
|
|
<tr>
|
|
<td>
|
|
<div class="component-input">
|
|
<label class="checkbox-inner">
|
|
<input type="checkbox" id="expense_removeIds_${item.id}" name="removeIds" value="${item.id}">
|
|
</label>
|
|
</div>
|
|
</td>
|
|
<td class="underline"><a href="javascript:void(0);" onclick="showBankExpenseModal(${item.id})">${ifNullHyphen(item.categoryText)}</a></td> <!-- 지출의 종류 -->
|
|
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 용도 -->
|
|
<td class="align-right">${formatNumberWithComma(item.count)}</td><!-- 수량 -->
|
|
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
|
<td class="align-right">${formatNumberWithComma(item.price)}</td><!-- 현금(원) -->
|
|
</tr>
|
|
`;
|
|
});
|
|
|
|
tbody.append(tmpl);
|
|
}
|
|
|
|
// 은행자동이체내역 삭제 Confirm
|
|
const removeBankConfirm = (el) => {
|
|
const section = el.closest('section');
|
|
const checkedInputs = section.querySelectorAll('input[name="removeIds"]:checked');
|
|
const checkedIds = Array.from(checkedInputs).map(input => Number(input.value));
|
|
|
|
const removeType = el.dataset.removeType;
|
|
const removeTypeText = el.dataset.removeType === 'INCOME' ? '수입' : '지출';
|
|
|
|
if(checkedIds.length <= 0) {
|
|
alert(`은행자동이체내역(${removeTypeText})을 선택해주세요.`);
|
|
return;
|
|
}
|
|
|
|
etUI.dialog.confirm({
|
|
title: '삭제 안내',
|
|
message: '선택하신 내용을 삭제하시겠습니까?<br>삭제한 항목은 복구할 수 없습니다.',
|
|
positiveCallback: function () {
|
|
removeBank(checkedIds, removeType, removeTypeText);
|
|
},
|
|
});
|
|
}
|
|
|
|
// 은행자동이체내역 삭제
|
|
const removeBank = (checkedIds, removeType, removeTypeText) => {
|
|
const f = document.reqForm;
|
|
|
|
ajaxUtil._ajaxMethod(
|
|
'/api/household/bank/delete',
|
|
JSON.stringify({
|
|
householdSeq: f.householdSeq.value,
|
|
recordMonth: f.recordMonth.value,
|
|
removeType: removeType,
|
|
removeIds: checkedIds
|
|
}),
|
|
() => { // 성공
|
|
alert(`은행자동이체내역(${removeTypeText})이 삭제되었습니다.`);
|
|
getBankAutoTransfer();
|
|
},
|
|
function (code, rstData) {
|
|
if(code == 422) alert(rstData.responseText);
|
|
if(code == 400) alert(rstData.responseJSON.message);
|
|
},
|
|
'delete',
|
|
'json',
|
|
);
|
|
}
|
|
</script>
|
|
</div>
|
|
</html> |