임가 등록/ 조사원 매팡 엑셀 파일 업로드
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<mapper
|
||||
namespace="app.module.admin.usecase.household.createHousehold.adapters.persistence.CreateHouseholdMapper">
|
||||
|
||||
<insert id="createHousehold">
|
||||
<update id="createHousehold">
|
||||
/* createHousehold : 임가 등록 */
|
||||
<selectKey keyProperty="seq" resultType="long" order="BEFORE">
|
||||
SELECT nextval('household_seq')
|
||||
@@ -79,7 +79,7 @@
|
||||
</if>
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</update>
|
||||
|
||||
<insert id="createHouseholdHasRole">
|
||||
/* createHouseholdHasRole : 임가 역할 등록 */
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<when test="cmd.searchField eq 'name'">
|
||||
AND a.name ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
|
||||
<when test="cmd.searchField eq 'phone'">
|
||||
AND a.phone ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
|
||||
@@ -357,4 +357,12 @@
|
||||
ORDER BY hvr.householdNum ASC
|
||||
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectResearcherId">
|
||||
select seq
|
||||
from admin a
|
||||
join admin_has_role ahr on ahr.admin_seq = a.seq and ahr.role_id = 'ROLE_RESEARCHER' and ahr.is_deleted = false
|
||||
where a.id = #{id} and a.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -284,6 +284,9 @@
|
||||
|
||||
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn" onclick="showExcelHouseholdModal();">
|
||||
<span class="btn-txt">엑셀 업로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
|
||||
</button>
|
||||
<button type="button" class="btn">
|
||||
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
|
||||
</button>
|
||||
@@ -302,6 +305,7 @@
|
||||
</form>
|
||||
|
||||
<div th:replace="common/modal-researcher-mapping :: modalFragment"></div>
|
||||
<div th:replace="households/modal/modal-excel-household :: modalFragment"></div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<!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="reqHouseholdExcelForm">
|
||||
|
||||
<div class="component-modal mypage-wrap modal01 modal-excel-household" 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">
|
||||
<label for="householdFile" class="input-file-btn">
|
||||
<input type="file" name="file" id="householdFile" accept=".xlsx, .xls">
|
||||
</label>
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="ExcelUploadHousehold();">
|
||||
<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">
|
||||
// 임가방문정보 모달창 띄우기
|
||||
const showExcelHouseholdModal = () => {
|
||||
document.querySelector(".modal-excel-household").ui.open();
|
||||
}
|
||||
|
||||
// 임가방문정보 등록
|
||||
const ExcelUploadHousehold = () => {
|
||||
event.preventDefault();
|
||||
|
||||
const fileInput = document.getElementById('householdFile');
|
||||
if (fileInput.files.length === 0) {
|
||||
alert('업로드할 엑셀 파일을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('file', fileInput.files[0]);
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/api/household/excelUpload',
|
||||
data: formData,
|
||||
contentType: false, // * 중요 *
|
||||
processData: false, // * 중요 *
|
||||
enctype: 'multipart/form-data', // * 중요 *
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
|
||||
},
|
||||
statusCode: {
|
||||
422: (res) => {
|
||||
const resJson = res.responseJSON;
|
||||
$(input).parent().find('.invalid-feedback').text(resJson.message);
|
||||
$(input).addClass('is-invalid');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</html>
|
||||
Reference in New Issue
Block a user