[BO] 임산물현황 작업 중

This commit is contained in:
kangsunlee
2025-06-25 15:06:37 +09:00
parent a57a3e1f3e
commit 0fabd4b920
3 changed files with 139 additions and 92 deletions

View File

@@ -7,7 +7,7 @@
<form autocomplete="off" method="get" name="reqForestProductForm">
<input type="hidden" name="forestProductId">
<input type="hidden" name="householdSeq" th:value="${seq}">
<input type="hidden" name="recordMonth" th:value="${recordMonth}">
<input type="hidden" name="recordMonth">
<div class="component-modal mypage-wrap modal01 modal-forest-product" data-props-dimm-click="true" data-state="close">
<div class="modal-dimm"></div>
@@ -75,7 +75,8 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="landArea" name="landArea">
<input type="number" id="landArea" name="landArea"
maxlength="30" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
@@ -84,7 +85,8 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="availableArea" name="availableArea">
<input type="number" id="availableArea" name="availableArea"
maxlength="30" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
@@ -99,28 +101,27 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="mainYield" name="mainYield">
<input type="number" id="mainYield" name="mainYield"
maxlength="10" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td>
<div class="component-select">
<select class="select-list" name="mainYieldUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
</td>
<th>직접입력 단위</th>
<td>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="mainYieldUnit" name="mainYieldUnit" disabled>
<td colspan="2">
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="mainYieldUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="mainYieldUnit" name="mainYieldUnit" disabled>
</div>
</div>
</div>
</td>
@@ -131,28 +132,27 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="mainSaleAmount" name="mainSaleAmount">
<input type="number" id="mainSaleAmount" name="mainSaleAmount"
maxlength="10" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td>
<div class="component-select">
<select class="select-list" name="mainSaleUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
</td>
<th>직접입력 단위</th>
<td>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="mainSaleUnit" name="mainSaleUnit" disabled>
<td colspan="2">
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="mainSaleUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="mainSaleUnit" name="mainSaleUnit" disabled>
</div>
</div>
</div>
</td>
@@ -167,28 +167,27 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="subYield" name="subYield">
<input type="number" id="subYield" name="subYield"
maxlength="10" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td>
<div class="component-select">
<select class="select-list" name="subYieldUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
</td>
<th>직접입력 단위</th>
<td>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="subYieldUnit" name="subYieldUnit" disabled>
<td colspan="2">
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="subYieldUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="subYieldUnit" name="subYieldUnit" disabled>
</div>
</div>
</div>
</td>
@@ -199,28 +198,27 @@
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="subSaleAmount" name="subSaleAmount">
<input type="number" id="subSaleAmount" name="subSaleAmount"
maxlength="10" inputmode="numeric" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td>
<div class="component-select">
<select class="select-list" name="subSaleUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
</td>
<th>직접입력 단위</th>
<td>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="subSaleUnit" name="subSaleUnit" disabled>
<td colspan="2">
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="subSaleUnitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${unitCodes}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<div class="component-input unit-self-input">
<div class="input-field">
<input type="text" id="subSaleUnit" name="subSaleUnit" disabled>
</div>
</div>
</div>
</td>
@@ -246,10 +244,11 @@
</div>
</form>
<script th:inline="javascript">
<script>
// 임산물현황등록 모달창 띄우기
const showForestProductModal = (id) => {
const f = document.reqForestProductForm;
f.recordMonth.value = document.reqForm.recordMonth.value;
resetForestProductForm();
@@ -261,7 +260,7 @@
{},
(response) => {
console.log("임산물현황 상세 응답값 : ", response);
// setVisitFormData(response);
setForestProductFormData(response);
},
function (code, rstData) {
console.log("error : ", code);
@@ -279,10 +278,55 @@
const form = document.reqForestProductForm;
if (!form) return;
form.forestProductId.value = data.id || '';
form.streetNum.value = data.streetNum || '';
form.landType.value = data.landType || '';
form.town.value = data.town || '';
form.cropName.value = data.cropName || '';
form.landArea.value = data.landArea ?? '';
form.availableArea.value = data.availableArea ?? '';
form.mainYield.value = data.mainYield ?? '';
form.mainSaleAmount.value = data.mainSaleAmount ?? '';
form.subYield.value = data.subYield ?? '';
form.subSaleAmount.value = data.subSaleAmount ?? '';
form.mainYieldUnit.value = data.mainYieldUnit || '';
form.mainSaleUnit.value = data.mainSaleUnit || '';
form.subYieldUnit.value = data.subYieldUnit || '';
form.subSaleUnit.value = data.subSaleUnit || '';
const unitSelectNames = [
'mainYieldUnitCode',
'mainSaleUnitCode',
'subYieldUnitCode',
'subSaleUnitCode'
];
unitSelectNames.forEach((name) => {
const select = form.querySelector(`select[name=${name}]`);
const value = data[name] || '';
if (select) {
select.value = value;
// unit-self-input 처리
const tr = select.closest('tr');
const unitArea = tr?.querySelector('.unit-self-input');
const unitInput = unitArea?.querySelector('input');
if (!unitArea || !unitInput) return;
if (value === 'code.record.unit.self') {
unitInput.disabled = false;
unitArea.classList.remove('input-disabled');
} else {
unitInput.disabled = true;
unitInput.value = '';
unitArea.classList.add('input-disabled');
}
}
});
}
</script>
<script th:inline="javascript">
<script>
// form 초기화
const resetForestProductForm = () => {
const form = document.reqForestProductForm;
@@ -292,7 +336,7 @@
form.querySelectorAll('input').forEach((input) => {
input.value = '';
// 직접입력 단위는 다시 비활성화하고 클래스 추가
// 단위 직접입력는 다시 비활성화하고 클래스 추가
if (input.closest('.unit-self-input')) {
input.disabled = true;
input.closest('.unit-self-input').classList.add('input-disabled');
@@ -305,22 +349,5 @@
});
}
</script>
<script>
const selectedUnit = (el) => {
const tr = el.closest('tr');
const unitArea = tr.querySelector('.unit-self-input');
const unitInput = tr.querySelector('.unit-self-input input');
if (el.value === 'code.record.unit.self') {
unitInput.disabled = false;
unitArea.classList.remove('input-disabled');
} else {
unitInput.disabled = true;
unitInput.value = '';
unitArea.classList.add('input-disabled');
}
};
</script>
</div>
</html>

View File

@@ -308,6 +308,22 @@
$(target).append(`<tr><td colspan="${length}" style="text-align: center;">${noDataText}</td></tr>`);
}
// 단위 선택 (직접입력 선택시 input 활성화)
const selectedUnit = (el) => {
const tr = el.closest('tr');
const unitArea = tr.querySelector('.unit-self-input');
const unitInput = tr.querySelector('.unit-self-input input');
if (el.value === 'code.record.unit.self') {
unitInput.disabled = false;
unitArea.classList.remove('input-disabled');
} else {
unitInput.disabled = true;
unitInput.value = '';
unitArea.classList.add('input-disabled');
}
}
</script>
</section>