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(); }
}
});
});

View File

@@ -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">&#50629;&#47196;&#46300; &#51473;&#51077;&#45768;&#45796;...</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(); }
}
});
});

View File

@@ -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;
}
</style>
</head>
<script src="/js/jquery.min.js"></script>
@@ -329,6 +468,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 win_close()
@@ -741,7 +882,27 @@ if rsc.RecordCount > 0 then
</tr>
<%
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>
@@ -749,19 +910,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>
@@ -979,6 +1161,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 () {
@@ -998,10 +1191,172 @@ if rsc.RecordCount > 0 then
ajaxCallJson("../approval/doc_expense2_ajax_sebu_2014.asp", { hangmok: $("#hangmok option:selected").val(), d_cost_type: document.ess.d_cost_type.value, cost_type: "2"}, null, "post", "sebureturnFunc()");
});
$(".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();

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();