From 3e3e01494f32f5815c3dc476a7a33a74f63213dd Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 18 Jul 2024 16:25:08 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EB=8B=A4=EC=9A=B4=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp | 86 ++++++++++--------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp index cbeace9..53e7626 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp @@ -104,8 +104,8 @@ 폐기방법 업체명 폐기건수 - 폐기결과보고서 - 처리내역및사진 + 폐기결과보고서 + 처리내역및사진 처리상태 폐기사유 폐기구분 @@ -373,47 +373,51 @@ return; } - $.ajax({ - url: wctx.url("/adds/nims/getHwpForRptDoc.do"), - data: { - dscdmngIds : dscdmngIds, - 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, ''); - } - } - filename = decodeURIComponent(filename); - if(filename.startsWith("\"")){ - filename = filename.substring(1); - } - if(filename.endsWith("\"")){ - filename = filename.substring(0,filename.length - 1); - } + let parameter = toQuery({ + dscdmngIds : dscdmngIds.join(","), + userId : "${currentUser.account}", + deptCd: "${currentUser.deptCode}", + adds12: ADDS12 + }); + 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: "파일 생성 중 오류가 발생하였습니다." + +"
" + +responseJson.description, + init: () => { setDialogZindex(); } + }); + }); + new Error(""); + } + 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"); + a.href = downloadUrl; + a.download = filename; + document.body.appendChild(a); + a.click(); + a.remove(); - 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(); - - if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){ - $P.control.load($P.control.pageNum); - } + if($("#tbody--${pageName}").find("td input[type='checkbox']:checked").length == 1){ + $P.control.load($P.control.pageNum); } - - }); + }) + .catch(()=>{}); }; // 업체 검색 버튼 이벤트