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

@@ -304,6 +304,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;
}
</style>
</head>
<script src="/js/jquery.min.js"></script>
@@ -311,6 +450,8 @@ if rsc.RecordCount > 0 then
<script src="/js/jquery.form.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/common.js"></script>
<script src="/js/pdf.js"></script>
<script src="/js/pdf.worker.js"></script>
<script language="javascript">
$(function(){
$("#delRewrite_btn").click(function(){
@@ -775,7 +916,27 @@ if rsc.RecordCount > 0 then
</tyr>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Server.Mappath("/") & "/Upload/DOC_ATTACH/" & krc_no & "/" & krc_no & "_1.jpg") = True Then
Dim attachFolderPath, attachFolderObj, attachOneFile, attachUs, attachDt, attachIdxPart, attachExt
Dim attachFileMap(20), attachIsImage(20)
Dim imageExtList : imageExtList = "|jpg|jpeg|png|gif|"
attachFolderPath = Server.Mappath("/") & "/Upload/DOC_ATTACH/" & krc_no
If fso.FolderExists(attachFolderPath) Then
Set attachFolderObj = fso.GetFolder(attachFolderPath)
For Each attachOneFile In attachFolderObj.Files
attachUs = InStrRev(attachOneFile.Name, "_")
attachDt = InStrRev(attachOneFile.Name, ".")
If attachUs > 0 And attachDt > attachUs Then
attachIdxPart = Mid(attachOneFile.Name, attachUs + 1, attachDt - attachUs - 1)
If IsNumeric(attachIdxPart) Then
If CInt(attachIdxPart) >= 1 And CInt(attachIdxPart) <= 20 Then
attachFileMap(CInt(attachIdxPart)) = attachOneFile.Name
attachExt = LCase(Mid(attachOneFile.Name, attachDt + 1))
If InStr(imageExtList, "|" & attachExt & "|") > 0 Then attachIsImage(CInt(attachIdxPart)) = True
End If
End If
End If
Next
End If
%>
<tr>
<td class="tit2" align="center"><3E><><EFBFBD><EFBFBD>÷<EFBFBD><C3B7></td>
@@ -783,19 +944,40 @@ if rsc.RecordCount > 0 then
<div class="attach_div">
<%
For i=1 To 20
if fso.FileExists(Server.Mappath("/") & "/Upload/DOC_ATTACH/" & krc_no & "/" & krc_no & "_" & cstr(i) & ".jpg") = True then
%>
<div class="attach_preview">
<img src="<%="/Upload/DOC_ATTACH/" & krc_no & "/" & krc_no & "_" & cstr(i) & ".jpg"%>" />
</div>
<%
End If
If attachFileMap(i) <> "" Then
If attachIsImage(i) Then
%>
<div class="attach_preview">
<img src="<%="/Upload/DOC_ATTACH/" & krc_no & "/" & attachFileMap(i)%>" />
<% If xadmin = "edit" And Session("N_depart") = "M" And Session("N_team") = "101" Then %>
<span class="attach_del_btn" data-idx="<%=i%>">&times;</span>
<% End If %>
</div>
<%
Else
%>
<div class="attach_file_box">
<a href="<%="/Upload/DOC_ATTACH/" & krc_no & "/" & attachFileMap(i)%>" target="_blank" class="attach_file_link">
<span class="attach_file_ext"><%=Ucase(Mid(attachFileMap(i), InStrRev(attachFileMap(i),".")+1))%></span>
<span class="attach_file_name"><%=attachFileMap(i)%></span>
</a>
<% If xadmin = "edit" And Session("N_depart") = "M" And Session("N_team") = "101" Then %>
<span class="attach_del_btn" data-idx="<%=i%>">&times;</span>
<% End If %>
</div>
<%
End If
End If
Next
%>
<% If xadmin = "edit" And Session("N_depart") = "M" And Session("N_team") = "101" Then %>
<div class="attach_add_btn" id="attachAddBtn">+ <20>߰<EFBFBD></div>
<input type="file" id="attachFileInput" accept="image/*,.zip,.pdf,.hwp,.doc,.docx,.xls,.xlsx,.ppt,.pptx" multiple style="display:none;" />
<% End If %>
</div>
</td>
</tr>
<% End If
<%
Set fso = Nothing
%>
</table>
@@ -912,6 +1094,17 @@ if rsc.RecordCount > 0 then
<% End If %>
</form>
<div class="attach_modal_overlay" id="attachModalOverlay">
<span class="attach_modal_close" id="attachModalClose">&times;</span>
<span class="attach_modal_nav attach_modal_prev" id="attachModalPrev">&lsaquo;</span>
<img class="attach_modal_img" id="attachModalImg" src="" />
<span class="attach_modal_nav attach_modal_next" id="attachModalNext">&rsaquo;</span>
<div class="attach_modal_count" id="attachModalCount"></div>
</div>
<div class="attach_upload_loading" id="attachUploadLoading">
<div class="attach_upload_spinner"></div>
<div class="attach_upload_text"><3E><><EFBFBD>ε<EFBFBD> <20><><EFBFBD>Դϴ<D4B4>...</div>
</div>
<script>
var ntsUrl = "";
$(document).ready(function (){
@@ -936,10 +1129,172 @@ if rsc.RecordCount > 0 then
}
});
$(".attach_preview").on("click", function(){
window.open($(this).children("img").attr("src"), "_blank", "popup=1");
var attachImgs = [];
var attachIdx = 0;
$(".attach_preview img").each(function(){
attachImgs.push($(this).attr("src"));
});
function showAttachModal(idx){
if(attachImgs.length == 0){ return; }
if(idx < 0){ idx = attachImgs.length - 1; }
if(idx >= attachImgs.length){ idx = 0; }
attachIdx = idx;
$("#attachModalImg").attr("src", attachImgs[attachIdx]);
$("#attachModalCount").text((attachIdx+1) + " / " + attachImgs.length);
$("#attachModalOverlay").addClass("active");
}
$(".attach_preview").on("click", function(e){
if($(e.target).hasClass("attach_del_btn")){ return; }
var idx = $(".attach_preview").index(this);
showAttachModal(idx);
});
$("#attachModalPrev").on("click", function(){ showAttachModal(attachIdx - 1); });
$("#attachModalNext").on("click", function(){ showAttachModal(attachIdx + 1); });
$("#attachModalClose").on("click", function(){ $("#attachModalOverlay").removeClass("active"); });
$("#attachModalOverlay").on("click", function(e){
if(e.target.id == "attachModalOverlay"){ $("#attachModalOverlay").removeClass("active"); }
});
$(document).on("keydown", function(e){
if($("#attachModalOverlay").hasClass("active")){
if(e.keyCode == 37){ showAttachModal(attachIdx - 1); }
else if(e.keyCode == 39){ showAttachModal(attachIdx + 1); }
else if(e.keyCode == 27){ $("#attachModalOverlay").removeClass("active"); }
}
})
$("#attachAddBtn").on("click", function(){
$("#attachFileInput").val("").trigger("click");
});
$("#attachFileInput").on("change", function(){
var files = this.files;
if(!files || files.length == 0){ return; }
$("#attachUploadLoading").addClass("active");
expandPdfFiles(files, 0, [], function(expandedFiles){
uploadAttachFiles(expandedFiles, 0);
});
});
function expandPdfFiles(files, idx, result, done){
if(idx >= files.length){
done(result);
return;
}
var f = files[idx];
if(f.type == "application/pdf"){
pdfFileToImages(f, function(imgFiles){
for(var i=0; i<imgFiles.length; i++){ result.push(imgFiles[i]); }
expandPdfFiles(files, idx+1, result, done);
});
}else{
result.push(f);
expandPdfFiles(files, idx+1, result, done);
}
}
function pdfFileToImages(file, callback){
var images = [];
var pdf_url = URL.createObjectURL(file);
var pdfTask = PDFJS.getDocument({ url: pdf_url });
pdfTask.promise.then(function(pdf_doc){
renderPdfPageToImg(pdf_doc, 1, pdf_doc.numPages, images, callback);
}).catch(function(error){
callback([file]);
});
}
function renderPdfPageToImg(pdf_doc, currentPage, maxPage, images, callback){
pdf_doc.getPage(currentPage).then(function(page){
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
canvas.width = Math.floor(viewport.width);
canvas.height = Math.floor(viewport.height);
var renderContext = { canvasContext: context, viewport: viewport };
page.render(renderContext).then(function(){
var imgDataUrl = canvas.toDataURL("image/jpeg", 1.0);
var blobBin = atob(imgDataUrl.split(",")[1]);
var array = [];
for(var i=0; i<blobBin.length; i++){ array.push(blobBin.charCodeAt(i)); }
var imgFile = new File([new Uint8Array(array)], "pdfpage.jpg", {type: "image/jpeg"});
images.push(imgFile);
if(maxPage > currentPage){
renderPdfPageToImg(pdf_doc, currentPage+1, maxPage, images, callback);
}else{
callback(images);
}
});
});
}
function uploadAttachFiles(files, idx){
if(idx >= files.length){
location.reload();
return;
}
var fd = new FormData();
fd.append("attach_file", files[idx]);
fd.append("krc_no", "<%=krc_no%>");
$.ajax({
url: "/ess/doc_attach_add.asp",
type: "POST",
data: fd,
processData: false,
contentType: false,
dataType: "json",
success: function(ret){
if(ret.result == "ok"){
uploadAttachFiles(files, idx+1);
}else if(ret.result == "full"){
$("#attachUploadLoading").removeClass("active");
alert("<22>ִ<EFBFBD> 20<32><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ÷<><C3B7><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.");
}else if(ret.result == "denied"){
$("#attachUploadLoading").removeClass("active");
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.");
}else if(ret.result == "badtype"){
$("#attachUploadLoading").removeClass("active");
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.");
}else{
$("#attachUploadLoading").removeClass("active");
alert("<22><><EFBFBD>ε忡 <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.");
}
},
error: function(){
$("#attachUploadLoading").removeClass("active");
alert("<22><><EFBFBD>ε<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߻<EFBFBD><DFBB>߽<EFBFBD><DFBD>ϴ<EFBFBD>.");
}
});
}
$(document).on("click", ".attach_del_btn", function(e){
e.stopPropagation();
var idx = $(this).data("idx");
if(!confirm("÷<><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?")){ return; }
$.ajax({
url: "/ess/doc_attach_del.asp",
type: "POST",
data: { krc_no: "<%=krc_no%>", idx: idx },
dataType: "json",
success: function(ret){
if(ret.result == "ok"){
location.reload();
}else if(ret.result == "denied"){
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.");
}else{
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.");
}
},
error: function(){
alert("<22><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߻<EFBFBD><DFBB>߽<EFBFBD><DFBD>ϴ<EFBFBD>.");
}
});
});
taxInvoicePopup();
var today = new Date().getMonth()+1 + " / " + new Date().getDate();