diff --git a/approval/doc_expense2_2014.asp b/approval/doc_expense2_2014.asp index c381316..c188dfe 100644 --- a/approval/doc_expense2_2014.asp +++ b/approval/doc_expense2_2014.asp @@ -118,6 +118,61 @@ to {color:#000;} */ } + .attach_file_preview{ + display:flex; + flex-direction:column; + justify-content:center; + align-items:center; + width:100%; + overflow:hidden; + padding:10px; + box-sizing:border-box; + text-align:center; + } + .attach_file_ext{ + font-weight:bold; + color:#666; + font-size:14px; + } + .attach_file_name{ + display:block; + max-width:100%; + overflow:hidden; + text-overflow:ellipsis; + white-space:nowrap; + font-size:11px; + color:#333; + } + .attach_upload_loading{ + display:none; + position:fixed; + top:0;left:0;right:0;bottom:0; + background:rgba(255,255,255,0.7); + z-index:10000; + flex-direction:column; + justify-content:center; + align-items:center; + } + .attach_upload_loading.active{ + display:flex; + } + .attach_upload_spinner{ + width:50px; + height:50px; + border:5px solid #ccc; + border-top:5px solid #333; + border-radius:50%; + animation:attach_spin 1s linear infinite; + } + @keyframes attach_spin{ + 0%{ transform:rotate(0deg); } + 100%{ transform:rotate(360deg); } + } + .attach_upload_text{ + margin-top:10px; + font-size:14px; + color:#333; + }
@@ -237,7 +292,7 @@ 증빙첨부 - + @@ -343,6 +398,10 @@ +
+
+
업로드 중입니다...
+
@@ -377,13 +436,9 @@ $("#doc_attach").on("change", function(e){ if(e.target.files.length > 0){ - if(e.target.files[0].type == "application/pdf"){ - pdfToImg(e.target.files[0]); - }else{ - fileArray.push(e.target.files[0]); - } + $("#attachUploadLoading").addClass("active"); + processDocAttachFiles(e.target.files, 0); } - imgPreviewSetting(fileArray); }); $(document).on("click", ".imgPreviewItem", function(){ @@ -436,37 +491,63 @@ $("#doc_attach").click(); } + function processDocAttachFiles(files, idx){ + if(idx >= files.length){ + imgPreviewSetting(fileArray); + $("#attachUploadLoading").removeClass("active"); + return; + } + if(files[idx].type == "application/pdf"){ + pdfToImg(files[idx], function(){ + processDocAttachFiles(files, idx + 1); + }); + }else{ + fileArray.push(files[idx]); + processDocAttachFiles(files, idx + 1); + } + } + function imgPreviewSetting(files){ if(files.length > 0){ var tmpHTML = ""; tmpHTML = "
"; $("#imgPreviews").children("td").html(tmpHTML); $.each(files, function(i, f){ - $("#imgPreviewDiv").append( - "
"+ - "첨부"+ - "
" - ); - var reader = new FileReader(); - reader.onload = function(e){ - $("#preview_" + (i+1)).attr("src", e.target.result); - $("#preview_" + (i+1)).parent().popover({ - html: true, - trigger: 'hover', - container: 'body', - placement: 'right', - content: function () { return ''; } - }); + var $item = $("
", { + "class": "d-flex p-1 m-1 imgPreviewItem", + "data-idx": i + }); + $("#imgPreviewDiv").append($item); + if(f.type.indexOf("image/") == 0){ + var previewId = "preview_" + (i + 1); + $item.append($("", { src: "", alt: "attach", id: previewId })); + var reader = new FileReader(); + reader.onload = function(e){ + $("#" + previewId).attr("src", e.target.result); + $("#" + previewId).parent().popover({ + html: true, + trigger: "hover", + container: "body", + placement: "right", + content: function () { return ""; } + }); + } + reader.readAsDataURL(f); + }else{ + var dotIdx = f.name.lastIndexOf("."); + var fileExt = dotIdx > -1 ? f.name.substring(dotIdx + 1).toUpperCase() : "FILE"; + var $filePreview = $("
", { "class": "attach_file_preview" }); + $filePreview.append($("", { "class": "attach_file_ext" }).text(fileExt)); + $filePreview.append($("", { "class": "attach_file_name" }).text(f.name)); + $item.append($filePreview); } - reader.readAsDataURL(f); }); - $("#imgPreviews").show(); }else{ $("#imgPreviews").hide(); } } - + function btn_del(index){ //var cnt = parseInt(document.frm_money.contents_cnt.value, 10); $("#addRow_Top_"+index).remove(); @@ -937,14 +1018,15 @@ $("#hangmok").append(ajaxResponse); } - function pdfToImg(file){ + function pdfToImg(file, callback){ var pdf_url = URL.createObjectURL(file); var pdfTask = PDFJS.getDocument({ url: pdf_url }); pdfTask.onPassword = passwordCB; pdfTask.promise.then(function(pdf_doc) { - pdfGetPage(pdf_doc, 1, pdf_doc.numPages); + pdfGetPage(pdf_doc, 1, pdf_doc.numPages, callback); }).catch(function(error) { alert(error.message); + if(callback){ callback(); } }); } @@ -957,7 +1039,7 @@ passwordFunc(new_password); } - function pdfGetPage(pdf_doc, currentPage, pdfMaxPage){ + function pdfGetPage(pdf_doc, currentPage, pdfMaxPage, callback){ pdf_doc.getPage(currentPage).then(function(page){ var scale = 1.5; var viewport = page.getViewport(scale); @@ -981,9 +1063,9 @@ var file = new File([new Uint8Array(array)], "tmpfile.jpg", {type: 'image/jpeg'}); fileArray.push(file); if(pdfMaxPage > currentPage){ - pdfGetPage(pdf_doc, currentPage + 1, pdfMaxPage); + pdfGetPage(pdf_doc, currentPage + 1, pdfMaxPage, callback); }else{ - imgPreviewSetting(fileArray); + if(callback){ callback(); } } }); }); diff --git a/approval/doc_expense_2014.asp b/approval/doc_expense_2014.asp index e80cf8e..d4ffad1 100644 --- a/approval/doc_expense_2014.asp +++ b/approval/doc_expense_2014.asp @@ -183,6 +183,61 @@ to {color:#000;} */ } + .attach_file_preview{ + display:flex; + flex-direction:column; + justify-content:center; + align-items:center; + width:100%; + overflow:hidden; + padding:10px; + box-sizing:border-box; + text-align:center; + } + .attach_file_ext{ + font-weight:bold; + color:#666; + font-size:14px; + } + .attach_file_name{ + display:block; + max-width:100%; + overflow:hidden; + text-overflow:ellipsis; + white-space:nowrap; + font-size:11px; + color:#333; + } + .attach_upload_loading{ + display:none; + position:fixed; + top:0;left:0;right:0;bottom:0; + background:rgba(255,255,255,0.7); + z-index:10000; + flex-direction:column; + justify-content:center; + align-items:center; + } + .attach_upload_loading.active{ + display:flex; + } + .attach_upload_spinner{ + width:50px; + height:50px; + border:5px solid #ccc; + border-top:5px solid #333; + border-radius:50%; + animation:attach_spin 1s linear infinite; + } + @keyframes attach_spin{ + 0%{ transform:rotate(0deg); } + 100%{ transform:rotate(360deg); } + } + .attach_upload_text{ + margin-top:10px; + font-size:14px; + color:#333; + } @@ -331,7 +386,7 @@ 증빙첨부 - + @@ -424,6 +479,10 @@
+
+
+
업로드 중입니다...
+
@@ -893,13 +952,9 @@ $("#doc_attach").on("change", function(e){ if(e.target.files.length > 0){ - if(e.target.files[0].type == "application/pdf"){ - pdfToImg(e.target.files[0]); - }else{ - fileArray.push(e.target.files[0]); - } + $("#attachUploadLoading").addClass("active"); + processDocAttachFiles(e.target.files, 0); } - imgPreviewSetting(fileArray); }); $(document).on("click", ".imgPreviewItem", function(){ @@ -993,45 +1048,72 @@ $("#doc_attach").click(); } + function processDocAttachFiles(files, idx){ + if(idx >= files.length){ + imgPreviewSetting(fileArray); + $("#attachUploadLoading").removeClass("active"); + return; + } + if(files[idx].type == "application/pdf"){ + pdfToImg(files[idx], function(){ + processDocAttachFiles(files, idx + 1); + }); + }else{ + fileArray.push(files[idx]); + processDocAttachFiles(files, idx + 1); + } + } + function imgPreviewSetting(files){ if(files.length > 0){ var tmpHTML = ""; tmpHTML = "
"; $("#imgPreviews").children("td").html(tmpHTML); $.each(files, function(i, f){ - $("#imgPreviewDiv").append( - "
"+ - "첨부"+ - "
" - ); - var reader = new FileReader(); - reader.onload = function(e){ - $("#preview_" + (i+1)).attr("src", e.target.result); - $("#preview_" + (i+1)).parent().popover({ - html: true, - trigger: 'hover', - container: 'body', - placement: 'right', - content: function () { return ''; } - }); + var $item = $("
", { + "class": "d-flex p-1 m-1 imgPreviewItem", + "data-idx": i + }); + $("#imgPreviewDiv").append($item); + if(f.type.indexOf("image/") == 0){ + var previewId = "preview_" + (i + 1); + $item.append($("", { src: "", alt: "attach", id: previewId })); + var reader = new FileReader(); + reader.onload = function(e){ + $("#" + previewId).attr("src", e.target.result); + $("#" + previewId).parent().popover({ + html: true, + trigger: "hover", + container: "body", + placement: "right", + content: function () { return ""; } + }); + } + reader.readAsDataURL(f); + }else{ + var dotIdx = f.name.lastIndexOf("."); + var fileExt = dotIdx > -1 ? f.name.substring(dotIdx + 1).toUpperCase() : "FILE"; + var $filePreview = $("
", { "class": "attach_file_preview" }); + $filePreview.append($("", { "class": "attach_file_ext" }).text(fileExt)); + $filePreview.append($("", { "class": "attach_file_name" }).text(f.name)); + $item.append($filePreview); } - reader.readAsDataURL(f); }); - $("#imgPreviews").show(); }else{ $("#imgPreviews").hide(); } } - function pdfToImg(file){ + function pdfToImg(file, callback){ var pdf_url = URL.createObjectURL(file); var pdfTask = PDFJS.getDocument({ url: pdf_url }); pdfTask.onPassword = passwordCB; pdfTask.promise.then(function(pdf_doc) { - pdfGetPage(pdf_doc, 1, pdf_doc.numPages); + pdfGetPage(pdf_doc, 1, pdf_doc.numPages, callback); }).catch(function(error) { alert(error.message); + if(callback){ callback(); } }); } @@ -1044,7 +1126,7 @@ passwordFunc(new_password); } - function pdfGetPage(pdf_doc, currentPage, pdfMaxPage){ + function pdfGetPage(pdf_doc, currentPage, pdfMaxPage, callback){ pdf_doc.getPage(currentPage).then(function(page){ var scale = 1.5; var viewport = page.getViewport(scale); @@ -1068,9 +1150,9 @@ var file = new File([new Uint8Array(array)], "tmpfile.jpg", {type: 'image/jpeg'}); fileArray.push(file); if(pdfMaxPage > currentPage){ - pdfGetPage(pdf_doc, currentPage + 1, pdfMaxPage); + pdfGetPage(pdf_doc, currentPage + 1, pdfMaxPage, callback); }else{ - imgPreviewSetting(fileArray); + if(callback){ callback(); } } }); }); diff --git a/ess/doc_expense2_print_2014.asp b/ess/doc_expense2_print_2014.asp index 80a1a1f..161dc4f 100644 --- a/ess/doc_expense2_print_2014.asp +++ b/ess/doc_expense2_print_2014.asp @@ -322,6 +322,145 @@ if rsc.RecordCount > 0 then max-width: 100%; max-height: 100%; } + .attach_modal_overlay{ + display:none; + position:fixed; + top:0;left:0;right:0;bottom:0; + background:rgba(0,0,0,0.8); + z-index:9999; + justify-content:center; + align-items:center; + } + .attach_modal_overlay.active{ + display:flex; + } + .attach_modal_img{ + max-width:85%; + max-height:85%; + } + .attach_modal_nav{ + position:absolute; + top:50%; + transform:translateY(-50%); + font-size:40px; + color:#fff; + cursor:pointer; + user-select:none; + padding:10px 20px; + } + .attach_modal_prev{ left:20px; } + .attach_modal_next{ right:20px; } + .attach_modal_close{ + position:absolute; + top:20px; + right:30px; + font-size:30px; + color:#fff; + cursor:pointer; + } + .attach_modal_count{ + position:absolute; + bottom:20px; + left:50%; + transform:translateX(-50%); + color:#fff; + font-size:14px; + } + .attach_preview{ position:relative; } + .attach_add_btn{ + display:flex; + width:15%; + height:70px; + border:1px dashed #ccc; + justify-content:center; + align-items:center; + cursor:pointer; + margin:4px; + color:#888; + font-size:13px; + } + .attach_del_btn{ + position:absolute; + top:-6px; + right:-6px; + width:18px; + height:18px; + line-height:16px; + text-align:center; + background:#e74c3c; + color:#fff; + border-radius:50%; + font-size:13px; + cursor:pointer; + z-index:2; + } + .attach_file_box{ + position:relative; + display:flex; + flex-direction:column; + justify-content:center; + align-items:center; + width:15%; + height:70px; + border:1px solid #ccc; + box-shadow: 1px 1px 2px 1px #b9b9b9; + margin:4px; + overflow:hidden; + text-align:center; + padding:4px; + box-sizing:border-box; + } + .attach_file_link{ + text-decoration:none; + display:flex; + flex-direction:column; + align-items:center; + width:100%; + } + .attach_file_ext{ + font-weight:bold; + color:#666; + font-size:11px; + } + .attach_file_name{ + display:block; + max-width:100%; + overflow:hidden; + text-overflow:ellipsis; + white-space:nowrap; + font-size:10px; + color:#333; + } + .attach_upload_loading{ + display:none; + position:fixed; + top:0;left:0;right:0;bottom:0; + background:rgba(255,255,255,0.7); + z-index:10000; + flex-direction:column; + justify-content:center; + align-items:center; + } + .attach_upload_loading.active{ + display:flex; + } + .attach_upload_spinner{ + width:50px; + height:50px; + border:5px solid #ccc; + border-top:5px solid #333; + border-radius:50%; + animation:attach_spin 1s linear infinite; + } + @keyframes attach_spin{ + 0%{ transform:rotate(0deg); } + 100%{ transform:rotate(360deg); } + } + .attach_upload_text{ + margin-top:10px; + font-size:14px; + color:#333; + } @@ -329,6 +468,8 @@ if rsc.RecordCount > 0 then + + @@ -311,6 +450,8 @@ if rsc.RecordCount > 0 then + +