feat: 이미지에디터 진행

main
minuk926 2 years ago
parent c7f15d2134
commit 429f9739aa

@ -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<MultipartFile> files;
}
@ -171,6 +174,7 @@ public class CmmFileDTO {
private String register;
@JsonIgnore
private MultipartFile file;
//private List<MultipartFile> files;
}

@ -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);

@ -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);
}
})
}

@ -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: '<c:out value="/framework/biz/cmm/file/uploadPaintweb.do"/>',
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('<c:out value="${imageTagId}"/>');

@ -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) => {

@ -9,12 +9,12 @@
* @param {string} dtlSeq - 시민신고상세순번
* </pre>
*/
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);
}
/**
* <pre>
* 첨부파일 정보 목록으로 부터 이미지 download

Loading…
Cancel
Save