diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn01020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn01020-info.jsp index 8d757f06..6511f94f 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn01020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn01020-info.jsp @@ -269,8 +269,8 @@
등록된 사진
- +
@@ -281,8 +281,11 @@
추가한 사진
- - +
+ + + +
@@ -348,6 +351,8 @@ $(document).ready(function(){ $P.captureFileArr.forEach(item => formData.append("uploadFileList",item)); } + //TODO : 편집된 파일, 삭제 사진 키값 + ajax.post({ url:!create ? $P.crdnControl.urls.update : $P.crdnControl.urls.create, data: formData, contentType : false, processData : false, @@ -379,29 +384,56 @@ $(document).ready(function(){ /************************************************************************** * pageObject.function **************************************************************************/ - - $P.fnDisplay = () => { - var displayArea = document.querySelector("#display--${pageName}"); - - var imgTagsFromUploadSet = $P.localUploadArr.map(function(item){ - return ""; - }).join("\n"); + $P.fnMakeImgForExistFile = (fileArr) => { + var tagsText = ""; - var imgTagsFromNumberPlate = ""; - if($P.numberPlateArr.length > 0){ - $P.numberPlateArr.forEach(function(item, index){ - imgTagsFromNumberPlate += ""; - }); + for(var index = 0; index < fileArr.length; index++){ + var item = fileArr[index]; + + tagsText += ""; + + if(index % 2 == 1){ + tagsText += "
" + } } + + return tagsText; + } + + + $P.fnMakeImgForNewFile = (fileArr) => { + var tagsText = ""; - var imgTagsFromVideo = ""; - if($P.captureFileArr.length > 0){ - $P.captureFileArr.forEach(function(item, index){ - imgTagsFromVideo += ""; - }); + for(var index = 0; index < fileArr.length; index++){ + var item = fileArr[index]; + + tagsText += ""; + + if(index % 2 == 1){ + tagsText += "
" + } } - displayArea.innerHTML = imgTagsFromUploadSet + imgTagsFromNumberPlate + imgTagsFromVideo; + return tagsText; + } + + $P.fnDisplay = () => { + var displayArea = document.querySelector("#display--${pageName}"); + + var concatArr = $P.localUploadArr.concat($P.numberPlateArr).concat($P.captureFileArr); + var tagsText = $P.fnMakeImgForNewFile(concatArr); + displayArea.innerHTML = tagsText; }; $P.fnSave = () => { @@ -447,9 +479,19 @@ $(document).ready(function(){ } $P.editPhotoCallback = (modifiedFile, originalFileInfo, isNumberPlate) => { - console.log(modifiedFile); + + modifiedFile.id = "file-" + new Date().getTime() + "-" + "0"; + modifiedFile.url = (window.URL || window.webkitURL).createObjectURL(modifiedFile); + + if(isNumberPlate){ + $P.numberPlateArr.push(modifiedFile); + $P.fnDisplay(); + } else { + // TODO : 편집된사진 표시 + } + console.log(originalFileInfo); - console.log(isNumberPlate); + } /************************************************************************** @@ -469,14 +511,42 @@ $(document).ready(function(){ ); }); $("#btnEditPhoto--${pageName}").on('click', () => { - var fileId = $("#display0--${pageName}").find("[name='editTarget']:checked").val(); + var checked = $("#display0--${pageName}").find("[name='existPhoto']:checked"); + if(checked.length < 1){ + alert("선택된 사진이 없습니다."); + return; + } + + var fileId = checked.val(); window.open(wctx.url("/sprt/sprt03/020/main.do?openerPageName=${pageName}&fileId="+fileId) ,"editPhoto" ,"width=1400,height=750" ); }); + + $("#btnDeleteExistPhoto--${pageName}").on('click', () => { + //기 등록 사진 삭제 + }); + $("#btnCancelAddFile--${pageName}").on('click', () => { + var checked = $("#display--${pageName}").find("[name='newPhoto']:checked"); + if(checked.length < 1){ + alert("선택된 사진이 없습니다."); + return; + } + + var checkedArr = []; + for(var i=0; i < checked.length; i++){ + checkedArr.push(checked[i].value); + } + + $P.captureFileArr = $P.captureFileArr.filter(item => checkedArr.indexOf(item.id) == -1); + $P.localUploadArr = $P.localUploadArr.filter(item => checkedArr.indexOf(item.id) == -1); + $P.numberPlateArr = $P.numberPlateArr.filter(item => checkedArr.indexOf(item.id) == -1); + + $P.fnDisplay(); + }); /************************************************************************** * 초기화 @@ -525,24 +595,8 @@ $(document).ready(function(){ } if(crdnInfo.fileList){ - var editPhotoArea = ""; - - crdnInfo.fileList.forEach(function(item, index){ - editPhotoArea += ""; - - if(index % 2 == 1){ - editPhotoArea += "
" - } - }); - - $("#display0--${pageName}").append(editPhotoArea); + var tagsText = $P.fnMakeImgForExistFile(crdnInfo.fileList); + $("#display0--${pageName}").append(tagsText); } else { $("#display0--${pageName}").append("등록된 사진이 없습니다."); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05030-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05030-info.jsp index 13362d0e..aa641cae 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05030-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05030-info.jsp @@ -246,6 +246,7 @@
+
@@ -335,24 +336,32 @@ $(document).ready(function(){ /************************************************************************** * pageObject.function **************************************************************************/ + $P.fnMakeImgForNewFile = (fileArr) => { + var tagsText = ""; + + for(var index = 0; index < fileArr.length; index++){ + var item = fileArr[index]; + + tagsText += ""; + + if(index % 2 == 1){ + tagsText += "
" + } + } + return tagsText; + } + $P.fnDisplay = () => { var displayArea = document.querySelector("#display--${pageName}"); - - var imgTagsFromUploadSet = $P.localUploadArr.map(function(item){ - return ""; - }).join("\n"); - - var imgTagsFromVideo = ""; - if($P.captureFileArr.length > 0){ - $P.captureFileArr.forEach(function(item, index){ - imgTagsFromVideo += ""; - }); - } - - displayArea.innerHTML = imgTagsFromUploadSet + imgTagsFromVideo; - + var concatArr = $P.localUploadArr.concat($P.captureFileArr); + var tagsText = $P.fnMakeImgForNewFile(concatArr); + displayArea.innerHTML = tagsText; }; $P.fnSave = () => { @@ -411,6 +420,23 @@ $(document).ready(function(){ ); }); + $("#btnCancelAddFile--${pageName}").on('click', () => { + var checked = $("#display--${pageName}").find("[name='newPhoto']:checked"); + if(checked.length < 1){ + alert("선택된 사진이 없습니다."); + return; + } + + var checkedArr = []; + for(var i=0; i < checked.length; i++){ + checkedArr.push(checked[i].value); + } + + $P.captureFileArr = $P.captureFileArr.filter(item => checkedArr.indexOf(item.id) == -1); + $P.localUploadArr = $P.localUploadArr.filter(item => checkedArr.indexOf(item.id) == -1); + + $P.fnDisplay(); + }); /************************************************************************** * 초기화