[BO] 엑셀다운로드 로딩바 추가 - 로딩바가 필요한 엑셀 다운로드일 경우 excelDownload(url, data); 함수 사용하면 됩니다.

This commit is contained in:
kangsunlee
2025-07-07 10:52:52 +09:00
parent c04e89fae9
commit c171cfc3c7
5 changed files with 67 additions and 7 deletions

View File

@@ -0,0 +1,8 @@
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="path-1-inside-1_24355_18053" fill="white">
<path d="M48 24C48 37.2548 37.2548 48 24 48C10.7452 48 0 37.2548 0 24C0 10.7452 10.7452 0 24 0C37.2548 0 48 10.7452 48 24Z"/>
</mask>
<g clip-path="url(#paint0_angular_24355_18053_clip_path)" data-figma-skip-parse="true" mask="url(#path-1-inside-1_24355_18053)"><g transform="matrix(0 -0.024 0.024 0 24 24)"><foreignObject x="-1291.67" y="-1291.67" width="2583.33" height="2583.33"><div xmlns="http://www.w3.org/1999/xhtml" style="background:conic-gradient(from 90deg,rgba(75, 188, 67, 0) 0deg,rgba(75, 188, 67, 0.8462) 304.615deg,rgba(75, 188, 67, 1) 360deg);height:100%;width:100%;opacity:1"></div></foreignObject></g></g><path d="M48 24H41C41 33.3888 33.3888 41 24 41V48V55C41.1208 55 55 41.1208 55 24H48ZM24 48V41C14.6112 41 7 33.3888 7 24H0H-7C-7 41.1208 6.87917 55 24 55V48ZM0 24H7C7 14.6112 14.6112 7 24 7V0V-7C6.87917 -7 -7 6.87917 -7 24H0ZM24 0V7C33.3888 7 41 14.6112 41 24H48H55C55 6.87917 41.1208 -7 24 -7V0Z" data-figma-gradient-fill="{&#34;type&#34;:&#34;GRADIENT_ANGULAR&#34;,&#34;stops&#34;:[{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:0.0},&#34;position&#34;:0.0},{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:0.84615385532379150},&#34;position&#34;:0.84615385532379150},{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:1.0},&#34;position&#34;:1.0}],&#34;stopsVar&#34;:[{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:0.0},&#34;position&#34;:0.0},{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:0.84615385532379150},&#34;position&#34;:0.84615385532379150},{&#34;color&#34;:{&#34;r&#34;:0.29411765933036804,&#34;g&#34;:0.73725491762161255,&#34;b&#34;:0.26274511218070984,&#34;a&#34;:1.0},&#34;position&#34;:1.0}],&#34;transform&#34;:{&#34;m00&#34;:-5.6229855298871312e-14,&#34;m01&#34;:48.0,&#34;m02&#34;:5.6229855298871312e-14,&#34;m10&#34;:-48.0,&#34;m11&#34;:-6.1558925817072063e-14,&#34;m12&#34;:48.0},&#34;opacity&#34;:1.0,&#34;blendMode&#34;:&#34;NORMAL&#34;,&#34;visible&#34;:true}" mask="url(#path-1-inside-1_24355_18053)"/>
<defs>
<clipPath id="paint0_angular_24355_18053_clip_path"><path d="M48 24H41C41 33.3888 33.3888 41 24 41V48V55C41.1208 55 55 41.1208 55 24H48ZM24 48V41C14.6112 41 7 33.3888 7 24H0H-7C-7 41.1208 6.87917 55 24 55V48ZM0 24H7C7 14.6112 14.6112 7 24 7V0V-7C6.87917 -7 -7 6.87917 -7 24H0ZM24 0V7C33.3888 7 41 14.6112 41 24H48H55C55 6.87917 41.1208 -7 24 -7V0Z" mask="url(#path-1-inside-1_24355_18053)"/></clipPath></defs>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -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);
});
};