[BO] 임가현황 - 임산물현황 작업

This commit is contained in:
kangsunlee
2025-06-26 19:02:09 +09:00
parent eda81b0bfa
commit d923c3352f
42 changed files with 663 additions and 24 deletions

View File

@@ -25,6 +25,7 @@
<meta property="og:description" th:content="${currentURI.ogDesc}" th:if="${currentURI != null}"/>
<meta property="og:keywords" th:content="${currentURI.ogKeywords}" th:if="${currentURI != null}"/>
<meta property="og:image" th:content="${currentURI.ogImage}" th:if="${currentURI != null}"/>
<meta name="robots" content="noindex, nofollow" th:if="${@environment.getProperty('spring.profiles.active') != 'prod'}">
<!-- 부트스트랩 css 숨김 처리 -->
<!-- <link rel="stylesheet" th:href="@{/static/library/bootstrap/bootstrap.min.css}"/>-->

View File

@@ -364,7 +364,7 @@
ajaxUtil._ajaxMethod(
'/api/forestProduct/save',
JSON.stringify(dataOj),
(response) => { // 성공
() => { // 성공
alert("등록이 완료되었습니다.");
document.querySelector(".modal-forest-product").ui.close();

View File

@@ -13,12 +13,19 @@
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn small">
<span class="btn-txt">등록여부</span>
<span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">이번달 등록내용 없음</span>
</span>
<input type="checkbox" id="forestProductStatus" data-step="FOREST_PRODUCT" onclick="showForestProductNoneConfirm(this);">
</label>
</span>
</button>
<button type="button" class="btn small btn-secondary">
<button type="button" class="btn small btn-secondary" style="display: none;" onclick="showDeleteForestProductConfirm();">
<span class=" btn-txt">삭제</span>
</button>
<button type="button" class="btn small btn-primary" onclick="showForestProductModal();">
<button type="button" class="btn small btn-primary" style="display: none;" onclick="showForestProductModal();">
<span class="btn-txt">추가</span>
</button>
</div>
@@ -73,8 +80,14 @@
// 임산물 현황 등록 상태 id set
f.monthlyInputStatusId.value = response.monthlyStatus.id;
const tbody = $('.tab-content.forest-product tbody');
// 이번달 등록내용 없음 체크 - 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) {
@@ -90,7 +103,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="forestRemoveIds_${item.id}" name="forestRemoveIds" value="${item.id}">
</label>
</div>
</td>
@@ -123,6 +136,124 @@
'json'
);
}
// 금일 데이터 없음에 따라 버튼 hide/show 처리
const showForestProductNoneBtn = () => {
$('.table-tit-group').each(function(index, item) {
let checkedIndex = false;
$(item).find('[type="button"]').each(function(indexBtn, itemBtn) {
let $chkBox = $(itemBtn).find('input[type="checkbox"]');
if (($chkBox.length !== 0 && $chkBox.is(':disabled'))) {
checkedIndex = true;
}
if (checkedIndex) {
$(itemBtn).hide();
} else {
$(itemBtn).show();
}
if ($chkBox.length !== 0) {
checkedIndex = $chkBox.is(':checked') || $chkBox.is(':disabled');
}
});
});
}
// 데이터 초기화 Confirm
const showForestProductNoneConfirm = (el) => {
const todayNone = $(el).is(':checked') ? 'Y' : 'N';
const obj = $(f).serializeObject();
obj.todayNone = todayNone;
if (todayNone === 'Y') {
etUI.dialog.confirm({
title: '초기화 안내',
message: '등록하신 모든 내용을 삭제하시겠어요?<br>삭제된 내용은 복구할 수 없습니다.',
negativeCallback: function () {
$(el).prop('checked', todayNone !== 'Y');
},
positiveCallback: function () {
updateForestProductNone(obj);
},
});
} else {
updateForestProductNone(obj);
}
}
// 이번달 등록내용 없음 수정 처리
const updateForestProductNone = (obj) => {
console.log(obj);
ajaxUtil._ajaxMethod(
'/api/household/forestProduct/nothing',
JSON.stringify(obj),
() => {
if (obj.todayNone === 'Y') {
alert('데이터 초기화가 완료되었습니다.');
} else {
alert('등록 상태가 변경되었습니다.');
}
getForestProductsStatus();
},
function (code, rstData) {
},
'patch',
'json',
{ handle422Type: 'alert' }
);
}
// 임산물현황 삭제 Confirm
const showDeleteForestProductConfirm = () => {
const checkedIds = Array.from(
document.querySelectorAll('input[name="forestRemoveIds"]:checked')
).map(el => Number(el.value));
if(checkedIds.length <= 0) {
alert("임산물을 선택해주세요.");
return
}
etUI.dialog.confirm({
title: '삭제 안내',
message: '선택하신 내용을 삭제하시겠습니까?<br>삭제한 항목은 복구할 수 없습니다.',
negativeCallback: function () {
},
positiveCallback: function () {
goDeleteForestProduct(checkedIds);
},
});
}
// 임산물현황 삭제
const goDeleteForestProduct = (checkedIds) => {
const f = document.reqForm;
console.log("f.monthlyInputStatusId.value", f.monthlyInputStatusId.value);
ajaxUtil._ajaxMethod(
'/api/household/forestProducts/delete',
JSON.stringify({
monthlyInputStatusId: f.monthlyInputStatusId.value,
forestRemoveIds: checkedIds
}),
() => { // 성공
alert("임산물현황이 삭제되었습니다.");
getForestProductsStatus();
},
function (code, rstData) {
if(code == 422) alert(rstData.responseText);
},
'delete',
'json',
{ handle422Type: 'alert' }
);
}
</script>
</div>
</html>