85 lines
3.3 KiB
HTML
85 lines
3.3 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="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> |