파일다운로드 수정

dev
이범준 4 months ago
parent 3d27e6effc
commit 3e3e01494f

@ -104,8 +104,8 @@
<th class="cmn" style="width: 150px;">폐기방법</th> <th class="cmn" style="width: 150px;">폐기방법</th>
<th class="cmn" style="width: 250.469px;">업체명</th> <th class="cmn" style="width: 250.469px;">업체명</th>
<th class="cmn" style="width: 90px;">폐기건수</th> <th class="cmn" style="width: 90px;">폐기건수</th>
<th class="cmn" style="width: 140.469px;">폐기결과보고서</th> <th class="cmn" style="width: 145px;">폐기결과보고서</th>
<th class="cmn" style="width: 140.469px;">처리내역및사진</th> <th class="cmn" style="width: 145px;">처리내역및사진</th>
<th class="cmn" style="width: 160.469px;">처리상태</th> <th class="cmn" style="width: 160.469px;">처리상태</th>
<th class="cmn" style="width: 180.469px;">폐기사유</th> <th class="cmn" style="width: 180.469px;">폐기사유</th>
<th class="cmn" style="width: 140px;">폐기구분</th> <th class="cmn" style="width: 140px;">폐기구분</th>
@ -373,32 +373,37 @@
return; return;
} }
$.ajax({ let parameter = toQuery({
url: wctx.url("/adds/nims/getHwpForRptDoc.do"), dscdmngIds : dscdmngIds.join(","),
data: {
dscdmngIds : dscdmngIds,
userId : "${currentUser.account}", userId : "${currentUser.account}",
deptCd: "${currentUser.deptCode}", deptCd: "${currentUser.deptCode}",
adds12: ADDS12 adds12: ADDS12
}, });
xhrFields: { responseType: 'blob' }, fetch(wctx.url("/adds/nims/getHwpForRptDoc.do") + "?" + parameter)
success:(blob, status, xhr) => { .then((response) => {
let disposition = xhr.getResponseHeader('Content-Disposition'); var header = response.headers.get('Content-Disposition');
if(disposition && disposition.indexOf('attachment') !== -1) { if(!header){
let filenameRegex = /filename[^;=\n]*=(([']).*?\2|[^;\n]*)/; response.json().then((responseJson)=>{
let matches = filenameRegex.exec(disposition); dialog.alert({
if(matches != null && matches[1]) { content: "파일 생성 중 오류가 발생하였습니다."
filename = matches[1].replace(/[']/g, ''); +"<br/>"
} +responseJson.description,
init: () => { setDialogZindex(); }
});
});
new Error("");
} }
filename = decodeURIComponent(filename); var parts = header.split(';');
filename = decodeURIComponent(parts[1].split('=')[1]);
if(filename.startsWith("\"")){ if(filename.startsWith("\"")){
filename = filename.substring(1); filename = filename.substring(1);
} }
if(filename.endsWith("\"")){ if(filename.endsWith("\"")){
filename = filename.substring(0,filename.length - 1); filename = filename.substring(0,filename.length - 1);
} }
return response.blob();
})
.then((blob) => {
let URL0 = (window.URL || window.webkitURL); let URL0 = (window.URL || window.webkitURL);
let downloadUrl = URL0.createObjectURL(blob); let downloadUrl = URL0.createObjectURL(blob);
let a = document.createElement("a"); let a = document.createElement("a");
@ -411,9 +416,8 @@
if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){ if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){
$P.control.load($P.control.pageNum); $P.control.load($P.control.pageNum);
} }
} })
.catch(()=>{});
});
}; };
// 업체 검색 버튼 이벤트 // 업체 검색 버튼 이벤트

Loading…
Cancel
Save