20260907 :: 김현정 > 260824 PMS 개선 요청_경영문화본부 2차 반영 :: 지출결의서 증빙관리(첩부파일) 기능 수정
This commit is contained in:
@@ -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;
|
||||
}
|
||||
</style>
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<!-- Content Header (Page header) -->
|
||||
@@ -331,7 +386,7 @@
|
||||
<td width="15%" align="center" class="align-middle"><3E><><EFBFBD><EFBFBD>÷<EFBFBD><C3B7></td>
|
||||
<td colspan="3">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="addDocAttach();"><3E>߰<EFBFBD></button>
|
||||
<input type="file" accept="image/*,application/pdf" id="doc_attach" class="d-none"/>
|
||||
<input type="file" accept="image/*,.zip,.pdf,.hwp,.doc,.docx,.xls,.xlsx,.ppt,.pptx" id="doc_attach" multiple="multiple" class="d-none"/>
|
||||
<input type="file" name="doc_attach" multiple="multiple" class="d-none" />
|
||||
</td>
|
||||
</tr>
|
||||
@@ -424,6 +479,10 @@
|
||||
</div>
|
||||
</form>
|
||||
<canvas id="pdf-canvas" width="400" class="d-none"></canvas>
|
||||
<div class="attach_upload_loading" id="attachUploadLoading">
|
||||
<div class="attach_upload_spinner"></div>
|
||||
<div class="attach_upload_text">업로드 중입니다...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 = "<div id='imgPreviewDiv' class='d-flex'></div>";
|
||||
$("#imgPreviews").children("td").html(tmpHTML);
|
||||
$.each(files, function(i, f){
|
||||
$("#imgPreviewDiv").append(
|
||||
"<div class='d-flex p-1 m-1 imgPreviewItem' data-idx='" + i + "'>"+
|
||||
"<img src='' alt='÷<><C3B7>' class='' id='preview_" + (i+1) + "' />"+
|
||||
"</div>"
|
||||
);
|
||||
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 '<img class="imgView" src="' + e.target.result + '" />'; }
|
||||
});
|
||||
var $item = $("<div>", {
|
||||
"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($("<img>", { 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 "<img class='imgView' src='" + e.target.result + "' />"; }
|
||||
});
|
||||
}
|
||||
reader.readAsDataURL(f);
|
||||
}else{
|
||||
var dotIdx = f.name.lastIndexOf(".");
|
||||
var fileExt = dotIdx > -1 ? f.name.substring(dotIdx + 1).toUpperCase() : "FILE";
|
||||
var $filePreview = $("<div>", { "class": "attach_file_preview" });
|
||||
$filePreview.append($("<span>", { "class": "attach_file_ext" }).text(fileExt));
|
||||
$filePreview.append($("<span>", { "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(); }
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user