파일다운로드 수정

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,47 +373,51 @@
return; return;
} }
$.ajax({ let parameter = toQuery({
url: wctx.url("/adds/nims/getHwpForRptDoc.do"), dscdmngIds : dscdmngIds.join(","),
data: { userId : "${currentUser.account}",
dscdmngIds : dscdmngIds, deptCd: "${currentUser.deptCode}",
userId : "${currentUser.account}", adds12: ADDS12
deptCd: "${currentUser.deptCode}", });
adds12: ADDS12 fetch(wctx.url("/adds/nims/getHwpForRptDoc.do") + "?" + parameter)
}, .then((response) => {
xhrFields: { responseType: 'blob' }, var header = response.headers.get('Content-Disposition');
success:(blob, status, xhr) => { if(!header){
let disposition = xhr.getResponseHeader('Content-Disposition'); response.json().then((responseJson)=>{
if(disposition && disposition.indexOf('attachment') !== -1) { dialog.alert({
let filenameRegex = /filename[^;=\n]*=(([']).*?\2|[^;\n]*)/; content: "파일 생성 중 오류가 발생하였습니다."
let matches = filenameRegex.exec(disposition); +"<br/>"
if(matches != null && matches[1]) { +responseJson.description,
filename = matches[1].replace(/[']/g, ''); init: () => { setDialogZindex(); }
} });
} });
filename = decodeURIComponent(filename); new Error("");
if(filename.startsWith("\"")){ }
filename = filename.substring(1); var parts = header.split(';');
} filename = decodeURIComponent(parts[1].split('=')[1]);
if(filename.endsWith("\"")){ if(filename.startsWith("\"")){
filename = filename.substring(0,filename.length - 1); filename = filename.substring(1);
} }
if(filename.endsWith("\"")){
filename = filename.substring(0,filename.length - 1);
}
return response.blob();
})
.then((blob) => {
let URL0 = (window.URL || window.webkitURL);
let downloadUrl = URL0.createObjectURL(blob);
let a = document.createElement("a");
a.href = downloadUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
let URL0 = (window.URL || window.webkitURL); if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){
let downloadUrl = URL0.createObjectURL(blob); $P.control.load($P.control.pageNum);
let a = document.createElement("a");
a.href = downloadUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){
$P.control.load($P.control.pageNum);
}
} }
})
}); .catch(()=>{});
}; };
// 업체 검색 버튼 이벤트 // 업체 검색 버튼 이벤트

Loading…
Cancel
Save