[BO] 임가현황 > 은행자동이체 내역 탭 작업

This commit is contained in:
kangsunlee
2025-07-02 16:08:31 +09:00
parent 4b96128b30
commit 529599d40a
55 changed files with 1288 additions and 1415 deletions

View File

@@ -0,0 +1,273 @@
<!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="modalFragment">
<!-- 은행자동이체(지출) 등록 모달 폼 -->
<form autocomplete="off" method="get" name="reqBankExpenseForm">
<input type="hidden" name="bankAutoTransferId">
<input type="hidden" name="householdSeq" th:value="${seq}">
<input type="hidden" name="recordMonth">
<input type="hidden" name="expenseCode">
<div class="component-modal mypage-wrap modal01 modal-bank-expense" data-props-dimm-click="true" data-state="close">
<div class="modal-dimm"></div>
<div class="modal-frame">
<div class="modal-container">
<div class="modal-header">
<h3 class="modal-tit">
은행자동이체(지출)
</h3>
</div>
<div class="modal-content">
<div class="modal-content-inner">
<!-- <i class="ico-required-mark" role="img" aria-label="필수">*</i><p>필수입력</p>-->
<table class="type-form confirm">
<colgroup>
<col width="10%" />
<col width="40%" />
<col width="10%" />
<col width="40%" />
</colgroup>
<tbody>
<tr>
<th>지출의 종류<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td>
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="transferCategoryCode" onchange="selectedExpenseCategory(this);" required>
<option value="">선택</option>
<option th:each="item : ${bankOutputCodes}"
th:value="${item.id}"
th:text="${item.codeText}"
th:data-code-value="${item.codeValue}"
th:data-code-type="${item.codeType}">
</select>
</div>
<!-- 직접입력 항목 -->
<div class="component-input self-input">
<div class="input-field">
<input type="text" class="transfer-category-self" name="transferCategory" disabled>
</div>
</div>
</div>
</td>
<th>용도</th>
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="sourcePurpose" name="sourcePurpose" maxlength="30">
</div>
</div>
</td>
</tr>
<tr>
<th>수량</th>
<td>
<div class="component-input">
<div class="input-field">
<input type="number" id="count" name="count"
maxlength="10" inputmode="decimal" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td>
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="unitCode" onchange="selectedSelf(this);" required>
<option value="">선택</option>
<option th:each="item : ${countUnitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<!-- 직접입력 수량 단위 -->
<div class="component-input self-input">
<div class="input-field">
<input type="text" id="unit" name="unit" disabled>
</div>
</div>
</div>
</td>
</tr>
<tr>
<th>현금(원)<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td >
<div class="component-input">
<div class="input-field">
<input type="number" id="price" name="price"
maxlength="30" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn btn-primary" onclick="saveBankExpense();">
<span class="btn-txt">등록</span>
</button>
</div>
</div>
</div>
</div>
<button type="button" class="modal-close"></button>
</div>
</div>
</div>
</form>
<script>
// 은행자동이체(수입) 모달창 띄우기
const showBankExpenseModal = (id) => {
const f = document.reqBankExpenseForm;
const reqForm = document.reqForm;
f.recordMonth.value = reqForm.recordMonth.value;
// 폼 초기화
resetBankExpenseForm();
if(id != null) {
f.bankAutoTransferId.value = id;
ajaxUtil._ajaxMethod(
`/api/household/bankAutoTransferExpense/${id}`,
{},
(response) => {
console.log("은행자동이체(지출) 상세 응답값 : ", response);
setBankExpenseFormData(response);
document.querySelector(".modal-bank-expense").ui.open();
},
function (code, rstData) {
console.log("error : ", code);
},
'get',
'json'
);
} else {
document.querySelector(".modal-bank-expense").ui.open();
}
}
// 은행이체내역(수입) 상세 값 set
const setBankExpenseFormData = (data) => {
const form = document.reqBankExpenseForm;
if (!form) return;
form.bankAutoTransferId.value = data.id ?? '';
form.householdSeq.value = data.householdSeq ?? '';
form.expenseCode.value = data.expenseCode ?? '';
form.count.value = data.count ?? '';
form.unitCode.value = data.unitCode ?? '';
form.unit.value = data.unit ?? '';
form.price.value = data.price ?? '';
form.sourcePurpose.value = data.sourcePurpose ?? '';
form.transferCategoryCode.value = data.transferCategoryCode ?? '';
toggleSelfInput(form.expenseCode.value, form.transferCategory);
toggleSelfInput(form.unitCode.value, form.unit);
}
</script>
<script>
// form 초기화
const resetBankExpenseForm = () => {
const form = document.reqBankExpenseForm;
if (!form) return;
const skipInputs = [
'householdSeq',
'recordMonth'
];
// input 초기화
form.querySelectorAll('input').forEach((el) => {
if (!skipInputs.includes(el.name)) {
el.value = '';
// 직접입력 영역이면 비활성화 처리
const wrapper = el.closest('.self-input') || el.closest('.target-input');
if (wrapper) {
el.disabled = true;
wrapper.classList.add('input-disabled');
}
}
});
// select 초기화
form.querySelectorAll('select').forEach((el) => {
el.selectedIndex = 0;
});
}
</script>
<script>
// 은행이체내역(수입) 저장 및 수정
const saveBankExpense = () => {
const f = document.reqBankExpenseForm;
if (!f) return;
let dataOj = $(f).serializeObject();
console.log("dataOj", dataOj);
ajaxUtil._ajaxMethod(
'/api/household/bank/expense/save',
JSON.stringify(dataOj),
() => { // 성공
alert("등록이 완료되었습니다.");
document.querySelector(".modal-bank-expense").ui.close();
getBankAutoTransfer();
},
function (code, rstData) {
if(code == 422) alert(rstData.responseJSON[0].defaultMessage);
},
'post',
'json',
{ handle422Type: 'alert' }
);
}
</script>
<script>
// 지출의 종류 선택에 따른 직접입력 input 과 대상 input disabled 처리
const selectedExpenseCategory = (el) => {
const f = document.reqBankExpenseForm;
f.expenseCode.value = '';
const selectedOption = el.options[el.selectedIndex];
const codeValue = selectedOption.dataset.codeValue;
f.expenseCode.value = codeValue;
const tr = el.closest('tr');
const selfArea = tr.querySelector('.self-input');
const selfInput = tr.querySelector('.self-input input');
if (el.value?.endsWith('.self')) {
selfInput.disabled = false;
selfArea.classList.remove('input-disabled');
} else {
selfInput.disabled = true;
selfInput.value = '';
selfArea.classList.add('input-disabled');
}
}
</script>
</div>
</html>

View File

@@ -66,7 +66,7 @@
<!-- 직접입력 항목 -->
<div class="component-input self-input">
<div class="input-field">
<input type="text" id="transferCategorySelf" name="transferCategory" disabled>
<input type="text" class="transfer-category-self" name="transferCategory" disabled>
</div>
</div>
</div>
@@ -76,7 +76,7 @@
<td>
<div class="component-input target-input">
<div class="input-field">
<input type="text" id="transferCategoryTarget" name="transferCategory" maxlength="30" disabled>
<input type="text" class="transfer-category-target" name="transferCategory" maxlength="30" disabled>
</div>
</div>
</td>
@@ -210,8 +210,8 @@
form.transferCategoryCode.value = data.transferCategoryCode ?? '';
// transferCategory 분기 처리
setTransferCategory(data.transferCategoryCode, data.transferCategory);
toggleSelfInput(form.unitCode.value, '#unit');
setTransferCategory(form, data.transferCategoryCode, data.transferCategory);
toggleSelfInput(form.unitCode.value, form.unit);
}
</script>
@@ -222,7 +222,6 @@
if (!form) return;
const skipInputs = [
'bankAutoTransferId',
'householdSeq',
'recordMonth'
];
@@ -325,11 +324,11 @@
}
// 분기 처리 유틸
const setTransferCategory = (code, value) => {
const selfInput = document.querySelector('#transferCategorySelf');
const targetInput = document.querySelector('#transferCategoryTarget');
const setTransferCategory = (form, code, value) => {
const selfInput = form.querySelector('.transfer-category-self');
const targetInput = form.querySelector('.transfer-category-target');
const isSelf = code === 'code.bank.input.self';
const isSelf = code.endsWith('.self');
if (isSelf) {
selfInput.value = value ?? '';
@@ -339,12 +338,11 @@
targetInput.value = value ?? '';
}
toggleSelfInput(code, '#transferCategorySelf');
toggleTargetInput(code, '#transferCategoryTarget');
toggleSelfInput(code, selfInput);
toggleTargetInput(code, targetInput);
};
const toggleSelfInput = (code, inputSelector) => {
const el = document.querySelector(inputSelector);
const toggleSelfInput = (code, el) => {
const wrapper = el.closest('.self-input');
const isSelf = code.endsWith('.self');
@@ -353,8 +351,7 @@
if (!isSelf) el.value = '';
};
const toggleTargetInput = (code, inputSelector) => {
const el = document.querySelector(inputSelector);
const toggleTargetInput = (code, el) => {
const wrapper = el.closest('.target-input');
const needTarget = !['code.bank.input.10', 'code.bank.input.12', 'code.bank.input.13', 'code.bank.input.self', ''].includes(code);

View File

@@ -12,7 +12,7 @@
<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">
<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();">
@@ -46,10 +46,10 @@
<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">
<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">
<button type="button" class="btn small btn-primary" onclick="showBankExpenseModal();">
<span class="btn-txt">추가</span>
</button>
</div>
@@ -118,7 +118,7 @@
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
<input type="checkbox" id="income_removeIds_${item.id}" name="removeIds" value="${item.id}">
</label>
</div>
</td>
@@ -155,11 +155,11 @@
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
<input type="checkbox" id="expense_removeIds_${item.id}" name="removeIds" value="${item.id}">
</label>
</div>
</td>
<td class="underline">${ifNullHyphen(item.categoryText)}</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">${ifNullHyphen(item.count)}</td><!-- 수량 -->
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
@@ -170,6 +170,54 @@
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>

View File

@@ -22,7 +22,7 @@
</label>
</span>
</button>
<button type="button" class="btn small btn-secondary" style="display: none;" onclick="showDeleteForestProductConfirm();">
<button type="button" class="btn small btn-secondary" style="display: none;" onclick="removeForestProductConfirm();">
<span class=" btn-txt">삭제</span>
</button>
<button type="button" class="btn small btn-primary" style="display: none;" onclick="showForestProductModal();">
@@ -78,23 +78,27 @@
(response) => { // 성공
console.log("임산물 현황 리스트 조회 : ", response);
// 임산물 현황 등록 상태 id set
f.monthlyInputStatusId.value = response.monthlyStatus.id;
// 이번달 등록내용 없음 체크 - NONE : 미등록, NOTHING : 이번달 등록내용 없음 , REGISTERED : 등록완료
$('#forestProductStatus').attr('checked', response.monthlyStatus.forestStatus === 'NOTHING');
// 이번달 등록내용 없음 에 따라 버튼 hide 처리
showForestProductNoneBtn();
const tbody = $('.tab-content.forest-product tbody');
tbody.empty();
if(response.forestProducts.length === 0) {
// TODO(ks) : monthlyStatus 없을 경우 처리 추가... 일단 .. 이렇게 처리 하지만.. 또 다른 방안이 있을지...
if (!response.monthlyStatus || !response.monthlyStatus.status) {
noDataMonthly(tbody, null, 15);
return;
}
if (!response.forestProducts || response.forestProducts.length === 0) {
noDataMonthly(tbody, response.monthlyStatus.status, 15);
return;
}
// 임산물 현황 등록 상태 id set
f.monthlyInputStatusId.value = response.monthlyStatus.id;
// 이번달 등록내용 없음 체크 - NONE : 미등록, NOTHING : 이번달 등록내용 없음 , REGISTERED : 등록완료
$('#forestProductStatus').attr('checked', response.monthlyStatus.forestStatus === 'NOTHING');
// 이번달 등록내용 없음 에 따라 버튼 hide 처리
showForestProductNoneBtn();
let tmpl = '';
$(response.forestProducts).each((idx, item) => {
tmpl +=
@@ -209,7 +213,7 @@
}
// 임산물현황 삭제 Confirm
const showDeleteForestProductConfirm = () => {
const removeForestProductConfirm = () => {
const checkedIds = Array.from(
document.querySelectorAll('input[name="forestRemoveIds"]:checked')
).map(el => Number(el.value));
@@ -223,13 +227,13 @@
title: '삭제 안내',
message: '선택하신 내용을 삭제하시겠습니까?<br>삭제한 항목은 복구할 수 없습니다.',
positiveCallback: function () {
goDeleteForestProduct(checkedIds);
removeForestProduct(checkedIds);
},
});
}
// 임산물현황 삭제
const goDeleteForestProduct = (checkedIds) => {
const removeForestProduct = (checkedIds) => {
const f = document.reqForm;
ajaxUtil._ajaxMethod(

File diff suppressed because it is too large Load Diff

View File

@@ -187,8 +187,11 @@
<!-- 임산물현황등록 모달 -->
<th:block th:replace="households/modal/modal-forest-product :: modalFragment"/>
<!-- 은행자동이체 모달 -->
<!-- 은행자동이체(수입) 모달 -->
<th:block th:replace="households/modal/modal-bank-auto-transfer-income :: modalFragment"/>
<!-- 은행자동이체(지출) 모달 -->
<th:block th:replace="households/modal/modal-bank-auto-transfer-expense :: modalFragment"/>
</section>
<section layout:fragment="script">