파일다운로드 수정

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

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

Loading…
Cancel
Save