[BO] 일계부 동력 사용시간등록, 수정

This commit is contained in:
김현주
2025-07-01 13:59:53 +09:00
parent f540b842f4
commit 15dd6a4798
16 changed files with 639 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
<?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.saveDailyPower.adapters.persistence.SaveDailyPowerMapper">
<select id="getDailyPower"
resultType="app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapters.persistence.modal.GetDailyPowerDto">
select ds.id, ds.daily_record_seq
, ds.equipment_name, ds.owned_hours, ds.leased_hours
from daily_power 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_power 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="createDailyPower" useGeneratedKeys="true" keyProperty="id">
insert into daily_power (
daily_record_seq
, equipment_name, owned_hours, leased_hours
, is_deleted
, <include refid="common.fields.CreateUpdateBaseColumns"/>
) values (
#{dailyRecordSeq}
, #{equipmentName}, #{ownedHours}, #{leasedHours}
, false
, <include refid="common.fields.CreateUpdateBaseValues"/>
)
</insert>
<update id="updateDailyPower">
update daily_power set <include refid="common.fields.UpdateBaseSet"/>
, equipment_name = #{equipmentName}
, owned_hours = #{ownedHours}
, leased_hours = #{leasedHours}
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
and id = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,177 @@
<!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="reqPowerForm" data-modal-id=".modal-daily-power">
<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-power" 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 colspan="4">
<div class="component-input">
<div class="input-field">
<input type="text" id="equipmentName" name="equipmentName" maxlength="30">
</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="decimal" pattern="[0-9]*" id="ownedHours" name="ownedHours" min="1" max="9999999999"
maxlength="10" oninput="limitMaxLength(this); priceDisabled(this, this.form.leasedHours)">
</div>
</div>
</td>
<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="decimal" pattern="[0-9]*" id="leasedHours" name="leasedHours" min="1" max="9999999999"
maxlength="10" oninput="limitMaxLength(this); priceDisabled(this, this.form.ownedHours)">
</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="saveDailyPower();">
<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 resetDailyPowerForm = () => {
const form = document.reqPowerForm;
if (!form) return;
form.equipmentName.value = '';
form.ownedHours.value = '';
form.leasedHours.value = '';
priceDisabledReset(form.ownedHours, form.leasedHours);
}
// 일계부 상세 값 set
const setDailyPowerFormData = (data) => {
const form = document.reqPowerForm;
if (!form) return;
// 폼에 값 세팅
form.equipmentName.value = data.equipmentName || '';
form.ownedHours.value = data.ownedHours || '';
form.leasedHours.value = data.leasedHours || '';
// 기타 UI 처리
if (form.ownedHours.value !== '') {
priceDisabled(form.ownedHours, form.leasedHours)
} else {
priceDisabled(form.leasedHours, form.ownedHours)
}
}
</script>
<script th:inline="javascript">
// 일계부 등록 모달창 띄우기
const showDailyPowerModal = (id) => {
const mf = document.reqPowerForm;
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;
resetDailyPowerForm();
if (id !== null && id !== undefined) {
const obj = $(f).serializeObject();
obj.id = mf.id.value;
obj.searchMonth = obj.recordMonth;
ajaxUtil._ajaxAsyncMethod(
`/api/household/daily/power/${id}`,
obj,
function (rstData, status) {
setDailyPowerFormData(rstData);
document.querySelector($(mf).data('modalId')).ui.open();
},
function () {
console.error('Do nothing error.')
},
'get'
);
} else {
document.querySelector($(mf).data('modalId')).ui.open();
}
}
const saveDailyPower = () => {
const mf = document.reqPowerForm;
let obj = $(mf).serializeObject();
obj.inputType = 'SELF';
obj.id = (obj.id === '' ? '0' : obj.id);
ajaxUtil._ajaxAsyncNoWaiting(
'/api/household/daily/power/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

@@ -639,7 +639,7 @@
</label>
</div>
</td>
<td class="underline">${ifNullHyphen(item.equipmentName)}</td> <!-- 명칭 -->
<td class="underline"><a href="javascript:void(0);" onclick="showDailyPowerModal(${item.id});">${ifNullHyphen(item.equipmentName)}</a></td> <!-- 명칭 -->
<td>${ifNullHyphen(item.ownedHours)}</td><!-- 자가 사용시간 -->
<td>${ifNullHyphen(item.leasedHours)}</td><!-- 임가 사용시간 -->
<td>
@@ -814,6 +814,8 @@
showDailyWorkModal();
} else if (currentStep === 'EXPENSE') {
showDailyExpenseModal();
} else if (currentStep === 'POWER') {
showDailyPowerModal();
} else {
alert('TODO : 추가');
}

View File

@@ -179,6 +179,7 @@
<th:block th:replace="households/modal/modal-daily-income :: modalFragment"/>
<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="common/modal-researcher-mapping :: modalFragment"/>