From 429f9739aade48a74f259d554cd9376cb22bd593 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Mon, 12 Dec 2022 15:00:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EC=97=90?= =?UTF-8?q?=EB=94=94=ED=84=B0=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/biz/cmm/model/CmmFileDTO.java | 4 + .../biz/cmm/web/CmmFileMgtController.java | 2 +- .../jsp/fims/biz/ec/ecCtznSttemntMgtPopup.jsp | 6 +- .../cmm/file/cmmPaintwebImageEditorPopup.jsp | 115 +++--------------- .../resources/framework/js/cmm/XitCmmnUtil.js | 1 + .../framework/js/cmm/cmmDownloadImg.js | 64 ++-------- 6 files changed, 38 insertions(+), 154 deletions(-) diff --git a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java index 28cc85eb..4b841eba 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java +++ b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java @@ -6,6 +6,8 @@ import java.util.List; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.annotation.JsonIgnore; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -142,6 +144,7 @@ public class CmmFileDTO { /** * 업로드 파일 객체 */ + @JsonIgnore private MultipartFile[] files; //private List files; } @@ -171,6 +174,7 @@ public class CmmFileDTO { private String register; + @JsonIgnore private MultipartFile file; //private List files; } diff --git a/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java b/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java index 0627f793..6019352b 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java +++ b/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java @@ -61,7 +61,7 @@ public class CmmFileMgtController { } - @PostMapping(value = "/uploadPaintweb", consumes = "multipart/form-data") + @PostMapping(value = "/uploadPaintweb") public ModelAndView uploadPaintweb(final CmmFileDTO.PaintwebReq dto) { ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); diff --git a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtPopup.jsp b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtPopup.jsp index 2dcdac52..986fee4b 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtPopup.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtPopup.jsp @@ -247,7 +247,11 @@ ,data: {interfaceSeqN: '${reqDTO.interfaceSeqN}'} ,success: (res) => { // 이미지 클릭시 image editor open - imgDownload(res.data?.contents, '#ctznImg', '${reqDTO.ctznSttemntDetailSn}', true); + const pr = { + interfaceSeqN: '${reqDTO.interfaceSeqN}', + ctznSttemntDetailSn: '${reqDTO.ctznSttemntDetailSn}' + } + imgDownload(res.data?.contents, '#ctznImg', pr, true); } }) } diff --git a/src/main/webapp/WEB-INF/jsp/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.jsp b/src/main/webapp/WEB-INF/jsp/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.jsp index af9bd4be..a458a9d1 100644 --- a/src/main/webapp/WEB-INF/jsp/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.jsp +++ b/src/main/webapp/WEB-INF/jsp/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.jsp @@ -41,10 +41,6 @@ pw.config.imageSave = imageSaveTo; pw.config.afterImageSave = () => window.close(); - //var evId = pw.config.saveH('imageSave', saveHandler); - // Later you can remove the event handler - //pw.events.remove('imageSave', evId); - pw.init(); } @@ -61,107 +57,32 @@ console.log(file) //let formData = new FormData(); //formData.append('file', file); - const {interfaceSeqN, ctznSttemntDetailSn, fileMastrId, fileId} = srcImg.dataset; - const param = { - interfaceSeqN, - ctznSttemntDetailSn, - fileMastrId, - fileId: 'kdkdkdk', - orginlFileNm: srcImg.orginlFileNm, - file: file - } + const {interfaceSeqN, ctznSttemntDetailSn, fileMastrId, fileId, fileCours} = srcImg.dataset; + + let formData = new FormData(); + formData.append('interfaceSeqN', interfaceSeqN); + formData.append('ctznSttemntDetailSn', ctznSttemntDetailSn); + formData.append('fileMastrId', fileMastrId); + formData.append('fileId', fileId); + formData.append('orginlFileNm', srcImg.name); + formData.append('fileCours', fileCours); + formData.append('file', file); cmmAjax({ + type: 'post', url: '', - data: $.param(JSON.stringify(param)), - }) - - return; - } - - function imageSaveTo2(idata, width, height, doc, _self){ - debugger - alert('~~~~imageSaveTo~~~'); - console.log(idata) - var ex = /\?filename=([a-z0-9\-]+)\&?/i; - var dashdash = '--'; - var crlf = '\r\n'; - - var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; - var progressBar = doc.createElement("div"); - progressBar.style.left = ((w-200)/2) + "px"; - progressBar.className = "progressBar"; - document.body.appendChild(progressBar); - var progressRate = doc.createElement("div"); - progressRate.innerText = "Saving"; - progressRate.className = "progressRate"; - progressBar.appendChild(progressRate); - - var url = srcImg.src; - var filename = url.match(ex)[1]; - - var boundary = 'multipartformboundary' + (new Date).getTime(); - var xhr = new XMLHttpRequest(); - xhr.open("POST", _self.config.imageSaveURL); - xhr.setRequestHeader('content-type', 'multipart/form-data; boundary='+ boundary); - - var builder = dashdash + boundary + crlf + 'Content-Disposition: form-data; name="imageFile"' + - '; filename="' + filename + '";' + crlf + ' Content-Type: application/octet-stream' + crlf + crlf; - builder += idata; - builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename; - builder += crlf + dashdash + boundary + dashdash + crlf; - - xhr.onload = function () { - var newImg = document.createElement("IMG"); - newImg.onload = function () { - srcImg.src = newImg.src + "#img" + (new Date()).getTime(); - if (_self.config.afterImageSave) _self.config.afterImageSave(); - } - newImg.src = _self.config.imageDownloadURL + "?filename=" + filename+ "#img" + (new Date()).getTime(); - }; - xhr.upload.addEventListener("progress", function(evt){ - if (evt.lengthComputable) { - var p = evt.loaded / evt.total * 100; - progressRate.style.width = p + "%"; - progressRate.innerText = progressRate.style.width; - if (p==100) { - progressRate.innerText = "Saved"; - } + processData: false, + contentType: false, + data: formData, + success: (res) => { + console.log(res) } - }, false); - xhr.send(builder); - } - - function saveHandler (ev) { - // Cancel the default action of the event. - ev.preventDefault(); -alert('saveHandler~~~') - var handlerURL = 'image_save_script.php', send = 'dataURL=' + encodeURIComponent(ev.dataURL), headers = {'Content-Type': 'application/x-www-form-urlencoded'}; - - - // 이미지를 저장하는 서버 측 스크립트로 데이터 URL을 보냅니다. - pwlib.xhrLoad ( handlerURL, saveReady, 'POST', send, header ); - } - - // The XMLHttpRequest onreadystatechange event handler. - function saveReady (xhr) { - alert('saveReady~~~') - - if (!xhr || xhr.readyState !== 4) { - return; - } + }) - if ((xhr.status !== 304 && xhr.status !== 200) || !xhr.responseText || xhr.responseText !== 'OK') { - // Image save failed. - pw.events.dispatch(new appEvent.imageSaveResult(false)); - return; - } - // Image save was successful. - pw.events.dispatch(new appEvent.imageSaveResult(true)); + return; } - $(document).ready(function () { srcImg = window.opener.document.getElementById(''); diff --git a/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js b/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js index ed85dfbb..84c3a9ab 100644 --- a/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js +++ b/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js @@ -219,6 +219,7 @@ const cmmAjax = (param) => { ,data: param.data ,async: nvl(param.async, true) ,dataType: nvl(param.dataType, "json") + ,processData: nvl(param.processData, true) ,contentType: nvl(param.contentType, 'application/x-www-form-urlencoded;charset=UTF-8') ,cache : false ,beforeSend: (jqXhr, settings) => { diff --git a/src/main/webapp/resources/framework/js/cmm/cmmDownloadImg.js b/src/main/webapp/resources/framework/js/cmm/cmmDownloadImg.js index 820626d5..92e4657f 100644 --- a/src/main/webapp/resources/framework/js/cmm/cmmDownloadImg.js +++ b/src/main/webapp/resources/framework/js/cmm/cmmDownloadImg.js @@ -9,12 +9,12 @@ * @param {string} dtlSeq - 시민신고상세순번 * */ -function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) { +function imgDownload(cmmFileDtls, appendElementId, reqDTO, isEditor) { const downloadUrl = '/framework/biz/cmm/file/download.do'; cmmFileDtls.forEach((dtl, idx) => { const params = "?filename=" +dtl.orginlFileNm+ $.param(dtl); - const title = dtlSeq ? dtl.orginlFileNm+'['+dtlSeq+']' : dtl.orginlFileNm; + const title = reqDTO ? dtl.orginlFileNm+'['+reqDTO.ctznSttemntDetailSn+']' : dtl.orginlFileNm; const x = document.createElement("img"); x.setAttribute("src", downloadUrl+params); x.setAttribute("id", dtl.fileId); @@ -24,9 +24,14 @@ function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) { //x.setAttribute("height", "228"); x.setAttribute("title", title); x.setAttribute("alt", dtl.orginlFileNm); - //x.setAttribute("id", dtl.fileMastrId); x.setAttribute("name", dtl.orginlFileNm); - x.setAttribute("ctznSttemntDetailSn", dtlSeq); + x.setAttribute("data-file-mastr-id", dtl.fileMastrId); + x.setAttribute("data-file-id", dtl.fileId); + x.setAttribute("data-file-cours", dtl.fileCours); + if(reqDTO) { + x.setAttribute("data-interface-seq-n", reqDTO.interfaceSeqN); + x.setAttribute("data-ctzn-sttemnt-detail-sn", reqDTO.ctznSttemntDetailSn); + } x.addEventListener('click', (e)=>{ if(isEditor) { fnBiz.pagePopup('imageEditor', {imageTagId: dtl.fileId}); @@ -40,57 +45,6 @@ function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) { }) } -function imageSaveTo(idata, width, height){ - var ex = /\?filename=([a-z0-9\-]+)\&?/i; - var dashdash = '--'; - var crlf = '\r\n'; - - var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; - var progressBar = doc.createElement("div"); - progressBar.style.left = ((w-200)/2) + "px"; - progressBar.className = "progressBar"; - document.body.appendChild(progressBar); - var progressRate = doc.createElement("div"); - progressRate.innerText = "Saving"; - progressRate.className = "progressRate"; - progressBar.appendChild(progressRate); - - var url = srcImg.src; - var filename = url.match(ex)[1]; - - var boundary = 'multipartformboundary' + (new Date).getTime(); - var xhr = new XMLHttpRequest(); - xhr.open("POST", _self.config.imageSaveURL); - xhr.setRequestHeader('content-type', 'multipart/form-data; boundary='+ boundary); - - var builder = dashdash + boundary + crlf + 'Content-Disposition: form-data; name="imageFile"' + - '; filename="' + filename + '";' + crlf + ' Content-Type: application/octet-stream' + crlf + crlf; - builder += idata; - builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename; - builder += crlf + dashdash + boundary + dashdash + crlf; - - xhr.onload = function () { - var newImg = document.createElement("IMG"); - newImg.onload = function () { - srcImg.src = newImg.src + "#img" + (new Date()).getTime(); - if (_self.config.afterImageSave) _self.config.afterImageSave(); - } - newImg.src = _self.config.imageDownloadURL + "?filename=" + filename+ "#img" + (new Date()).getTime(); - }; - xhr.upload.addEventListener("progress", function(evt){ - if (evt.lengthComputable) { - var p = evt.loaded / evt.total * 100; - progressRate.style.width = p + "%"; - progressRate.innerText = progressRate.style.width; - if (p==100) { - progressRate.innerText = "Saved"; - } - } - }, false); - xhr.send(builder); -} - - /** *
  * 첨부파일 정보 목록으로 부터 이미지 download