Files
korea-research/admin/src/main/resources/templates/households/modal/modal-daily-farming.html

219 lines
9.9 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="modalFragment">
<form autocomplete="off" method="get" name="reqFarmingForm" data-modal-id=".modal-daily-farming">
<input type="hidden" name="householdSeq" th:value="${seq}">
<input type="hidden" name="searchMonth">
<input type="hidden" name="groupNo">
<input type="hidden" name="id">
<input type="hidden" name="dailyId">
<div class="component-modal mypage-wrap modal01 modal-daily-farming" 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">
<table class="type-form confirm">
<colgroup>
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
</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="productCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${recordFarming}"
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="productSelf" name="productSelf" maxlength="30" disabled>
</div>
</div>
</div>
</td>
<th>용도</th>
<td>
<div class="component-input">
<div class="input-field">
<input type="text" id="usage" name="usage" maxlength="30">
</div>
</div>
</td>
</tr>
<tr>
<th>수량</th>
<td>
<div class="component-input">
<div class="input-field">
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity" min="1" max="9999999999"
maxlength="10" oninput="limitMaxLength(this);">
</div>
</div>
</td>
<th>단위</th>
<td colspan="2">
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="unitCode" onchange="selectedUnit(this);" required>
<option value="">선택</option>
<option th:each="item : ${recordUnit}"
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="unitSelf" name="unitSelf" maxlength="30" 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" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue" min="1" max="9999999999"
maxlength="10" 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="saveDailyFarming();">
<span class="btn-txt">등록</span>
</button>
</div>
</div>
</div>
</div>
<button type="button" class="modal-close"></button>
</div>
</div>
</div>
</form>
<script th:inline="javascript">
// form 초기화
const resetDailyFarmingForm = () => {
const form = document.reqFarmingForm;
if (!form) return;
form.productCode.value = '';
form.productSelf.value = '';
form.usage.value = '';
form.quantity.value = '';
form.unitCode.value = '';
form.unitSelf.value = '';
form.estimatedValue.value = '';
}
// 일계부 상세 값 set
const setDailyFarmingFormData = (data) => {
const form = document.reqFarmingForm;
if (!form) return;
// 폼에 값 세팅
form.productCode.value = data.productCode || '';
form.productSelf.value = data.productSelf || '';
form.usage.value = data.usage || '';
form.quantity.value = data.quantity || '';
form.unitCode.value = data.unitCode || '';
form.unitSelf.value = data.unitSelf || '';
form.estimatedValue.value = data.estimatedValue || '';
// 기타 UI 처리
selectedUnit(form.productCode);
selectedUnit(form.unitCode);
}
</script>
<script th:inline="javascript">
// 일계부 등록 모달창 띄우기
const showDailyFarmingModal = (id) => {
const mf = document.reqFarmingForm;
mf.searchMonth.value = document.reqForm.recordMonth.value;
mf.groupNo.value = document.reqForm.groupNo.value;
mf.dailyId.value = document.reqForm.dailyId.value;
mf.id.value = (id === undefined) ? '' : id;
resetDailyFarmingForm();
if (id !== null && id !== undefined) {
const obj = $(f).serializeObject();
obj.id = mf.id.value;
obj.searchMonth = obj.recordMonth;
ajaxUtil._ajaxAsyncMethod(
`/api/household/daily/farming/${id}`,
obj,
function (rstData, status) {
setDailyFarmingFormData(rstData);
document.querySelector($(mf).data('modalId')).ui.open();
},
function () {
console.error('Do nothing error.')
},
'get'
);
} else {
document.querySelector($(mf).data('modalId')).ui.open();
}
}
const saveDailyFarming = () => {
const mf = document.reqFarmingForm;
let obj = $(mf).serializeObject();
obj.inputType = 'SELF';
obj.id = (obj.id === '' ? '0' : obj.id);
ajaxUtil._ajaxAsyncNoWaiting(
'/api/household/daily/farming/save',
obj,
function () {
alert('등록이 완료되었습니다.');
document.querySelector($(mf).data('modalId')).ui.close();
getDailyRecordsView(f.dailyId.value, f.groupNo.value, f.dayGroupText.value);
},
function (code, rstData) {
console.error('Do nothing. code: '+ code, rstData);
},
);
}
</script>
</div>
</html>