You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB
JavaScript

var woopyonMoa = {
urls: {
warning: "warning.do",
prenotice: "prenotice.do",
notice: "notice.do"
},
preview: (type, sndngId) => {
let url = woopyonMoa.urls[type];
if (!url)
throw "Url not found for " + type;
url = wctx.url("/preview/" + url);
let params = {
sggCd: MY_INFO.info.sggCd,
taskSeCd: currentTask(),
sndngId: sndngId
};
let filenameInHeader = "";
fetch(url + "?" + toQuery(params))
.then((resp) => {
let header = resp.headers.get('Content-Disposition');
if(!header){
resp.json().then((json)=>{
dialog.alert({
content: "파일생성 중 오류가 발생하였습니다."
+"<br/>"
+json.description,
init: () => { AppSupport.setDialogZindex(); }
});
});
throw new Error("");
}
let parts = header.split(';');
filenameInHeader = decodeURIComponent(parts[1].split('=')[1]);
return resp.blob();
})
.then((blob) => {
AppSupport.openPDF(blob, filenameInHeader);
})
},
downloadRequest: (params) => {
params.template = "woopyonmoa-upload.xls";
download.post({
url: wctx.url("/woopyonmoa/download.do"),
data: params
});
},
updateStatus: (file) => upload({
url: wctx.url("/woopyonmoa/update.do"),
data: {upload: file},
success: resp => dialog.alert(resp.saved ? "저장됐습니다." : "저장하지 못했습니다.")
})
};