20260907 :: 김현정 > 260824 PMS 개선 요청_경영문화본부 2차 반영 :: 지출결의서 증빙관리(첩부파일) 기능 수정

This commit is contained in:
2026-09-09 17:12:50 +09:00
parent e46f88d6fb
commit 295e7a6e23
4 changed files with 955 additions and 81 deletions

View File

@@ -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;
}
</style>
<!-- Content Header (Page header) -->
<div class="content-header">
@@ -237,7 +292,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>
@@ -343,6 +398,10 @@
</tr>
</table>
<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">&#50629;&#47196;&#46300; &#51473;&#51077;&#45768;&#45796;...</div>
</div>
</div>
</div>
</div>
@@ -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 = "<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 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(); }
}
});
});