Merge branch 'susu' into dev

This commit is contained in:
주수현
2025-07-23 14:28:10 +09:00
10 changed files with 104 additions and 72 deletions

View File

@@ -128,9 +128,6 @@
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button class="btn" onclick="showAdminExcelUploadModal();" type="button">
<span class="btn-txt">엑셀 업로드</span>
</button>
<!-- <button class="btn" onclick="goExcel();" type="button"><span class="btn-txt" th:unless="${activeProfile != 'local'}">엑셀 다운로드</span></button>-->
<button class="btn" onclick="location.href='/settings/admins/create';" type="button"><span class="btn-txt">등록</span></button>
<button class="btn" onclick="goRemove();" type="button"><span class="btn-txt">삭제</span></button>
@@ -138,7 +135,6 @@
</div>
</section>
<div th:replace="admin/modal/modal-admin-excel:: modalFragment"></div>
</form>
</section>
@@ -214,61 +210,6 @@
// f.submit();
// }
function showAdminExcelUploadModal() {
const modal = document.querySelector(".modal-admin-excel");
const fileInput = document.getElementById("file");
if (fileInput) {
fileInput.value = '';
}
modal.ui.open();
}
const uploadAdminExcel = () => {
event.preventDefault();
const fileInput = document.getElementById('file');
if (fileInput.files.length === 0) {
alert('업로드할 엑셀 파일을 선택해주세요.');
return;
}
let formData = new FormData();
formData.append('file', fileInput.files[0]);
$.ajax({
method: 'POST',
url: '/api/settings/admin/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: {
400:() => {
ajaxUtil._hideWaiting();
alert("잘못된 엑셀파일입니다.");
document.querySelector(".modal-admin-excel").ui.close();
},
500: () => {
ajaxUtil._hideWaiting();
alert("엑셀 업로드에 실패하였습니다.");
document.querySelector(".modal-admin-excel").ui.close();
}
}
});
};
const closeModal = () => {
document.querySelector(".modal-admin-excel").ui.close();
};
</script>
</section>

View File

@@ -3,12 +3,12 @@
layout:decorate="~{layout/layout}">
<div class="layer-wrap" th:fragment="modalFragment">
<div class="component-modal modal01 modal-admin-excel" id="test" data-props-dimm-click="true" data-state="close">
<div class="component-modal modal01 modal-researcher-excel" id="test" data-props-dimm-click="true" data-state="close">
<div class="modal-dimm"></div>
<div class="modal-frame">
<div class="modal-container type-small">
<div class="modal-header">
<h3 class="modal-tit" >관리자 등록 엑셀업로드</h3>
<h3 class="modal-tit">조사원 등록 엑셀업로드</h3>
</div>
<div class="modal-content">
<div class="modal-content-inner">
@@ -19,7 +19,7 @@
</label>
<div class="component-btns bottom-btn-group" th:fragment="modalButtons">
<div class="btns-row align-right">
<button type="button" class="btn btn-primary" onclick="uploadAdminExcel()">
<button type="button" class="btn btn-primary" onclick="uploadExcel()">
<span class="btn-txt">등록</span>
</button>
</div>

View File

@@ -97,11 +97,15 @@
<div class="component-btns bottom-btn-group" >
<div class="btns-row align-right">
<button class="btn" onclick="showExcelUploadModal();" type="button">
<span class="btn-txt">엑셀 업로드</span>
</button>
<button type="button" class="btn" onclick="goExcel();">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
</button>
</div>
</div>
<div th:replace="researcher/modal/modal-researcher-excel:: modalFragment"></div>
</form>
</section>
@@ -238,6 +242,61 @@
});
}
}
function showExcelUploadModal() {
const modal = document.querySelector(".modal-researcher-excel");
const fileInput = document.getElementById("file");
if (fileInput) {
fileInput.value = '';
}
modal.ui.open();
}
const uploadExcel = () => {
event.preventDefault();
const fileInput = document.getElementById('file');
if (fileInput.files.length === 0) {
alert('업로드할 엑셀 파일을 선택해주세요.');
return;
}
let formData = new FormData();
formData.append('file', fileInput.files[0]);
$.ajax({
method: 'POST',
url: '/api/settings/admin/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: {
400:() => {
ajaxUtil._hideWaiting();
alert("잘못된 엑셀파일입니다.");
document.querySelector(".modal-researcher-excel").ui.close();
},
500: () => {
ajaxUtil._hideWaiting();
alert("엑셀 업로드에 실패하였습니다.");
document.querySelector(".modal-researcher-excel").ui.close();
}
}
});
};
const closeModal = () => {
document.querySelector(".modal-researcher-excel").ui.close();
};
</script>
</section>