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