diff --git a/admin/src/main/resources/static/assets/images/common/ico_loading.svg b/admin/src/main/resources/static/assets/images/common/ico_loading.svg
new file mode 100644
index 00000000..fcd23ed8
--- /dev/null
+++ b/admin/src/main/resources/static/assets/images/common/ico_loading.svg
@@ -0,0 +1,8 @@
+
diff --git a/admin/src/main/resources/static/scripts/ajaxUtils.js b/admin/src/main/resources/static/scripts/ajaxUtils.js
index d37cfd02..eeb269e6 100644
--- a/admin/src/main/resources/static/scripts/ajaxUtils.js
+++ b/admin/src/main/resources/static/scripts/ajaxUtils.js
@@ -192,6 +192,48 @@ var ajaxUtil = {
},
});
},
+ /**
+ * 엑셀 다운로드 (로딩바 포함)
+ */
+ _excelDownload: function(url, data, errorCallback) {
+ ajaxUtil._showWaiting();
+
+ $.ajax({
+ url: url,
+ method: 'GET',
+ data: data,
+ xhrFields: {
+ responseType: 'blob'
+ },
+ beforeSend: function(xhr) {
+ if (ajaxUtil._csrfHeader != undefined) {
+ xhr.setRequestHeader(ajaxUtil._csrfHeader, ajaxUtil._csrfToken);
+ }
+ },
+ success: function(blob, status, xhr) {
+ const disposition = xhr.getResponseHeader('Content-Disposition');
+ const filenameMatch = disposition?.match(/filename\*?=UTF-8''(.+)/);
+ const filename = filenameMatch ? decodeURIComponent(filenameMatch[1]) : 'download.xlsx';
+
+ const blobUrl = window.URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = blobUrl;
+ a.download = filename;
+ a.click();
+ window.URL.revokeObjectURL(blobUrl);
+ },
+ error: function(rstData) {
+ if (typeof errorCallback !== 'undefined') {
+ errorCallback(rstData.status, rstData);
+ } else {
+ alert('엑셀 다운로드 실패');
+ }
+ },
+ complete: function() {
+ ajaxUtil._hideWaiting();
+ }
+ });
+ },
_jsonParse : function parse(jsonStr) {
@@ -220,11 +262,17 @@ var ajaxUtil = {
_hideWaiting:function(){
if (ajaxUtil.loadingStatus) {
ajaxUtil.loadingStatus = false;
- // TODO : 로딩바 숨김
+ $('#loading').hide();
}
},
_showWaiting:function(){
ajaxUtil.loadingStatus = true;
- // TODO : 로딩바 활성화
+ $('#loading').show();
},
+};
+
+const excelDownload = (url, data) => {
+ ajaxUtil._excelDownload(url, data, (status, error) => {
+ console.error('엑셀 다운로드 실패:', status, error);
+ });
};
\ No newline at end of file
diff --git a/admin/src/main/resources/templates/households/households.html b/admin/src/main/resources/templates/households/households.html
index 0c1a3ceb..28fa56c1 100644
--- a/admin/src/main/resources/templates/households/households.html
+++ b/admin/src/main/resources/templates/households/households.html
@@ -491,13 +491,10 @@
const f = document.reqForm;
const data = $(f).serializeObject();
- // size 를 제거하면 전체 목록을 가져온다.
- delete data.size;
-
if (url !== '') {
- location.href = url + '?' + new URLSearchParams(data).toString();
+ excelDownload(url, data);
} else {
- console.warn('엑셀 다운르도 경로 없음.')
+ console.warn('엑셀 다운르도 경로 없음.');
}
}
diff --git a/admin/src/main/resources/templates/households/modal/modal-excel-household.html b/admin/src/main/resources/templates/households/modal/modal-excel-household.html
index 99117318..cf487ebd 100644
--- a/admin/src/main/resources/templates/households/modal/modal-excel-household.html
+++ b/admin/src/main/resources/templates/households/modal/modal-excel-household.html
@@ -52,6 +52,9 @@
return;
}
+ // 로딩바 show
+ ajaxUtil._showWaiting();
+
let formData = new FormData();
formData.append('file', fileInput.files[0]);
@@ -68,6 +71,8 @@
$("meta[name='_csrf']").attr("content"));
},
success(res) {
+ ajaxUtil._hideWaiting(); // 로딩바 hide
+
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
},
statusCode: {
diff --git a/admin/src/main/resources/templates/layout/layout.html b/admin/src/main/resources/templates/layout/layout.html
index db11e28d..533f4846 100644
--- a/admin/src/main/resources/templates/layout/layout.html
+++ b/admin/src/main/resources/templates/layout/layout.html
@@ -9,6 +9,8 @@