[BO] 일계부 임업생산물 등록, 수정

This commit is contained in:
김현주
2025-07-01 14:53:10 +09:00
parent 15dd6a4798
commit 5e6365d620
18 changed files with 724 additions and 2 deletions

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.adapters.persistence.SaveDailyForestryMapper">
<select id="getDailyForestry"
resultType="app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.adapters.persistence.modal.GetDailyForestryDto">
select ds.id, ds.daily_record_seq
, ds.product_name, ds.usage
, ds.quantity, ds.unit_code, ds.unit_self, ds.estimated_value
from daily_forestry ds
<include refid="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
and ds.id = #{id}
</select>
<select id="getRecordExistCount" resultType="int">
select count(1)
from daily_forestry ds
<include refid="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
<if test="id != null and id != '0'">
and ds.id = #{id}
</if>
</select>
<insert id="createDailyForestry" useGeneratedKeys="true" keyProperty="id">
insert into daily_forestry (
daily_record_seq, expense_mark
, product_name, usage
, quantity, unit_code, unit_self, estimated_value
, is_deleted
, <include refid="common.fields.CreateUpdateBaseColumns"/>
) values (
#{dailyRecordSeq}, #{expenseMark}
, #{productName}, #{usage}
, #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue}
, false
, <include refid="common.fields.CreateUpdateBaseValues"/>
)
</insert>
<update id="updateDailyForestry">
update daily_forestry set <include refid="common.fields.UpdateBaseSet"/>
, expense_mark = #{expenseMark}
, product_name = #{productName}
, usage = #{usage}
, quantity = #{quantity}
, unit_code = #{unitCode}
, unit_self = #{unitSelf}
, estimated_value = #{estimatedValue}
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
and id = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,207 @@
<!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="reqForestryForm" data-modal-id=".modal-daily-forestry">
<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-forestry" 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="component-input">
<div class="input-field">
<input type="text" id="productName" name="productName" maxlength="30">
</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="saveDailyForestry();">
<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 resetDailyForestryForm = () => {
const form = document.reqForestryForm;
if (!form) return;
form.productName.value = '';
form.usage.value = '';
form.quantity.value = '';
form.unitCode.value = '';
form.unitSelf.value = '';
form.estimatedValue.value = '';
}
// 일계부 상세 값 set
const setDailyForestryFormData = (data) => {
const form = document.reqForestryForm;
if (!form) return;
// 폼에 값 세팅
form.productName.value = data.productName || '';
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.unitCode);
}
</script>
<script th:inline="javascript">
// 일계부 등록 모달창 띄우기
const showDailyForestryModal = (id) => {
const mf = document.reqForestryForm;
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;
resetDailyForestryForm();
if (id !== null && id !== undefined) {
const obj = $(f).serializeObject();
obj.id = mf.id.value;
obj.searchMonth = obj.recordMonth;
ajaxUtil._ajaxAsyncMethod(
`/api/household/daily/forestry/${id}`,
obj,
function (rstData, status) {
setDailyForestryFormData(rstData);
document.querySelector($(mf).data('modalId')).ui.open();
},
function () {
console.error('Do nothing error.')
},
'get'
);
} else {
document.querySelector($(mf).data('modalId')).ui.open();
}
}
const saveDailyForestry = () => {
const mf = document.reqForestryForm;
let obj = $(mf).serializeObject();
obj.inputType = 'SELF';
obj.id = (obj.id === '' ? '0' : obj.id);
ajaxUtil._ajaxAsyncNoWaiting(
'/api/household/daily/forestry/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>

View File

@@ -676,7 +676,7 @@
</label>
</div>
</td>
<td class="underline">${ifNullHyphen(item.productName)}</td> <!-- 생산물 -->
<td class="underline"><a href="javascript:void(0);" onclick="showDailyForestryModal(${item.id});">${ifNullHyphen(item.productName)}</a></td> <!-- 생산물 -->
<td>${ifNullHyphen(item.usage)}</td><!-- 용도 -->
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
@@ -816,6 +816,8 @@
showDailyExpenseModal();
} else if (currentStep === 'POWER') {
showDailyPowerModal();
} else if (currentStep === 'FORESTRY') {
showDailyForestryModal();
} else {
alert('TODO : 추가');
}

View File

@@ -180,6 +180,7 @@
<th:block th:replace="households/modal/modal-daily-work :: modalFragment"/>
<th:block th:replace="households/modal/modal-daily-expense :: modalFragment"/>
<th:block th:replace="households/modal/modal-daily-power :: modalFragment"/>
<th:block th:replace="households/modal/modal-daily-forestry :: modalFragment"/>
<!-- 조사원 매핑 모달 -->
<th:block th:replace="common/modal-researcher-mapping :: modalFragment"/>