단속사진 파일업로드 수정

main
이범준 1 year ago
parent 0e12052c06
commit 1d177dfb7a

@ -12,6 +12,16 @@ import lombok.Setter;
public class Crdn extends AbstractEntity { public class Crdn extends AbstractEntity {
public static String INF_TYPE = "100"; public static String INF_TYPE = "100";
/**
*
*/
private String[] modifyFileKeyList;
/**
*
*/
private String[] deleteFileKeyList;
/** /**
* *
*/ */

@ -7,6 +7,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.CommonCode; import cokr.xit.base.code.CommonCode;
@ -129,6 +130,8 @@ public class Crdn01Controller extends ApplicationController {
DataObject info = crdn01Service.getCivilComplaintReceiptInitialDataInfo(req); DataObject info = crdn01Service.getCivilComplaintReceiptInitialDataInfo(req);
mav.addObject("crdnInfo", json ? info : toJson(info)); mav.addObject("crdnInfo", json ? info : toJson(info));
mav.addObject("openerPageName", request.getParameter("openerPageName"));
return mav; return mav;
} }
@ -183,6 +186,23 @@ public class Crdn01Controller extends ApplicationController {
.addObject("saved", saved); .addObject("saved", saved);
} }
/** .
* @param crdnId
* @return jsonView
* <pre><code> {
* "affected":
* "saved": true, false
* }</code></pre>
*/
@RequestMapping(name="민원자료 저장", value="/020/save.do")
public ModelAndView saveCivilComplaint(Crdn crdn, MultipartFile[] newFileList, MultipartFile[] modifyFileList) {
boolean saved = true;// TODO : crdn01Service.saveCivilComplaint
return new ModelAndView("jsonView")
.addObject("saved", saved);
}
/** . /** .
* @return hwp * @return hwp
*/ */

@ -121,14 +121,14 @@ public class Crdn05Controller extends ApplicationController {
* }</code></pre> * }</code></pre>
*/ */
@PostMapping(name="단속자료 수기 등록", value="/030/create.do") @PostMapping(name="단속자료 수기 등록", value="/030/create.do")
public ModelAndView createCrdnDataByManual(Crdn crdn, MultipartFile[] uploadFileList) { public ModelAndView createCrdnDataByManual(Crdn crdn, MultipartFile[] newFileList) {
boolean saved = false; boolean saved = false;
crdn.setCrdnRegSeCd("01"); crdn.setCrdnRegSeCd("01");
crdn.setCrdnInptSeCd("03");//TODO : 사용자 기관의 시청,구청 구분 crdn.setCrdnInptSeCd("03");//TODO : 사용자 기관의 시청,구청 구분
if(uploadFileList != null) { if(newFileList != null) {
List<FileInfo> fileInfoList = new FileInfoFactory().makeFileInfos(null, uploadFileList); List<FileInfo> fileInfoList = new FileInfoFactory().makeFileInfos(null, newFileList);
saved = crdn05Service.create(crdn, fileInfoList); saved = crdn05Service.create(crdn, fileInfoList);
} else { } else {
saved = crdn05Service.create(crdn); saved = crdn05Service.create(crdn);

@ -296,7 +296,10 @@ $(document).ready(function(){
ajax.get({ ajax.get({
url : $P.crdnControl.urls.getInfo, url : $P.crdnControl.urls.getInfo,
data : {"crdnId" : dataKey}, data : {
"crdnId" : dataKey,
"openerPageName" : "${pageName}"
},
success : resp => { success : resp => {
dialog.open({ dialog.open({
id : dialogId, id : dialogId,

@ -253,7 +253,7 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="row justify-content-end"> <div class="row justify-content-end">
<div class="col-sm-3"> <div class="col-sm-3">
<button type="button" id="btnInst--${pageName}" class="btn btn-primary">등록</button> <button type="button" id="btnInst--${pageName}" class="btn btn-primary">저장</button>
</div> </div>
</div> </div>
</div> </div>
@ -263,7 +263,8 @@
</div> </div>
<div class="card" style="width:500px;"> <div class="card" style="width:500px;">
<form id="frmFile--${pageName}" method="post" enctype="multipart/form-data"> <form id="frmFile--${pageName}" method="post" enctype="multipart/form-data">
<input type="file" id="uploadFileList--${pageName}" name="uploadFileList" multiple accept="image/*" hidden /> <input type="file" id="newFileList--${pageName}" name="newFileList" multiple accept="image/*" hidden />
<input type="file" id="modifyFileList--${pageName}" name="modifyFileList" multiple accept="image/*" hidden />
</form> </form>
<div class="col-md-12 d-flex justify-content-between"> <div class="col-md-12 d-flex justify-content-between">
@ -273,7 +274,7 @@
<button type="button" id="btnDeleteExistPhoto--${pageName}" class="btn btn-blue">선택 사진 삭제</button> <button type="button" id="btnDeleteExistPhoto--${pageName}" class="btn btn-blue">선택 사진 삭제</button>
</div> </div>
</div> </div>
<div id="display0--${pageName}" style="overflow-y: scroll;min-height: 40px;max-height: 340px;border-style: solid;"> <div id="displayForExist--${pageName}" style="overflow-y: scroll;min-height: 40px;max-height: 340px;border-style: solid;">
</div> </div>
<form id="frmUploadSet--${pageName}" method="post" enctype="multipart/form-data"> <form id="frmUploadSet--${pageName}" method="post" enctype="multipart/form-data">
@ -287,7 +288,7 @@
<button type="button" id="btnCancelAddFile--${pageName}" class="btn btn-blue">선택 사진 삭제</button> <button type="button" id="btnCancelAddFile--${pageName}" class="btn btn-blue">선택 사진 삭제</button>
</div> </div>
</div> </div>
<div id="display--${pageName}" style="overflow-y: scroll;min-height: 40px;max-height: 340px;border-style: solid;"> <div id="displayForNew--${pageName}" style="overflow-y: scroll;min-height: 40px;max-height: 340px;border-style: solid;">
</div> </div>
@ -305,6 +306,8 @@ $(document).ready(function(){
var $P = pageObject["${pageName}"]; var $P = pageObject["${pageName}"];
$P.existFileArr = [];
$P.captureFileArr = []; $P.captureFileArr = [];
$P.localUploadArr = []; $P.localUploadArr = [];
$P.numberPlateArr = []; $P.numberPlateArr = [];
@ -317,7 +320,7 @@ $(document).ready(function(){
$P.uploadSet = uploadSupport("#inputUploadSet--${pageName}"); $P.uploadSet = uploadSupport("#inputUploadSet--${pageName}");
$P.crdnControl = new DatasetControl({ $P.crdnControl = new DatasetControl({
urls : { load : "", create : wctx.url("/${taskSeCd}/crdn/crdn01/020/save.do") }, urls : { load : "", update : wctx.url("/${taskSeCd}/crdn/crdn01/020/save.do") },
keymapper:info => info ? info.CRDN_ID : "", keymapper:info => info ? info.CRDN_ID : "",
dataGetter:obj => obj.crdnInfo, dataGetter:obj => obj.crdnInfo,
formats: { formats: {
@ -337,21 +340,31 @@ $(document).ready(function(){
formData.append(key,value); formData.append(key,value);
} }
if(formData.get("uploadFileList").size == 0){ formData.delete("newFileList");
formData.delete("uploadFileList"); formData.delete("modifyFileList");
}
if($P.localUploadArr.length > 0){ if($P.localUploadArr.length > 0){
$P.localUploadArr.forEach(item => formData.append("uploadFileList",item)); $P.localUploadArr.forEach(item => formData.append("newFileList",item));
} }
if($P.numberPlateArr.length > 0){ if($P.numberPlateArr.length > 0){
$P.numberPlateArr.forEach(item => formData.append("uploadFileList",item)); $P.numberPlateArr.forEach(item => formData.append("newFileList",item));
} }
if($P.captureFileArr.length > 0){ if($P.captureFileArr.length > 0){
$P.captureFileArr.forEach(item => formData.append("uploadFileList",item)); $P.captureFileArr.forEach(item => formData.append("newFileList",item));
} }
//TODO : 편집된 파일, 삭제 사진 키값
if($P.existFileArr.length > 0){
for(var i=0; i < $P.existFileArr.length; i++){
if($P.existFileArr[i].status == "delete"){
formData.append("deleteFileKeyList", $P.existFileArr[i].FILE_ID);
} else if($P.existFileArr[i].status == "modified"){
formData.append("modifyFileKeyList", $P.existFileArr[i].FILE_ID);
formData.append("modifyFileList", $P.existFileArr[i]);
}
}
}
ajax.post({ ajax.post({
url:!create ? $P.crdnControl.urls.update : $P.crdnControl.urls.create, url:!create ? $P.crdnControl.urls.update : $P.crdnControl.urls.create,
@ -371,14 +384,14 @@ $(document).ready(function(){
var files = $P.uploadSet.getDataset(); var files = $P.uploadSet.getDataset();
files.forEach(item => $P.localUploadArr.push(item)); files.forEach(item => $P.localUploadArr.push(item));
$P.fnDisplay(); $P.fnDisplay(false);
}; };
$P.uploadSet.onRemove = () => { }; $P.uploadSet.onRemove = () => { };
$P.crdnControl.onSave = (resp) => { $P.crdnControl.onSave = (resp) => {
if (resp.saved) { if (resp.saved) {
dialog.alert("저장됐습니다."); dialog.alert("저장됐습니다.");
dialog.close("manualdialog"); dialog.close("cvlcptInitialDataEditDialog--${openerPageName}");
} }
}; };
/************************************************************************** /**************************************************************************
@ -387,9 +400,13 @@ $(document).ready(function(){
$P.fnMakeImgForExistFile = (fileArr) => { $P.fnMakeImgForExistFile = (fileArr) => {
var tagsText = ""; var tagsText = "";
for(var index = 0; index < fileArr.length; index++){ for(var index = 0, j = 0; index < fileArr.length; index++){
var item = fileArr[index]; var item = fileArr[index];
if(item.status == "delete"){
continue;
}
tagsText += "<label class='mx-2'>"; tagsText += "<label class='mx-2'>";
tagsText += "<input type='radio' name='existPhoto' class='form-check-input' value='"+item.FILE_ID +"' "; tagsText += "<input type='radio' name='existPhoto' class='form-check-input' value='"+item.FILE_ID +"' ";
if(index == 0){ if(index == 0){
@ -399,9 +416,11 @@ $(document).ready(function(){
tagsText += "<img src='"+ item.URL +"' width='200' height='200' />"; tagsText += "<img src='"+ item.URL +"' width='200' height='200' />";
tagsText += "</label>"; tagsText += "</label>";
if(index % 2 == 1){ if(j % 2 == 1){
tagsText += "<br />" tagsText += "<br />";
} }
j++;
} }
return tagsText; return tagsText;
@ -421,19 +440,31 @@ $(document).ready(function(){
tagsText += "</label>"; tagsText += "</label>";
if(index % 2 == 1){ if(index % 2 == 1){
tagsText += "<br />" tagsText += "<br />";
} }
} }
return tagsText; return tagsText;
} }
$P.fnDisplay = () => { $P.fnDisplay = (isExist) => {
var displayArea = document.querySelector("#display--${pageName}"); if(isExist){
var displayArea = document.querySelector("#displayForExist--${pageName}");
var tagsText = $P.fnMakeImgForExistFile($P.existFileArr);
if(tagsText == ""){
displayArea.innerHTML = "등록된 사진이 없습니다.";
$("#btnEditPhoto--crdn01020-info").hide();
} else {
displayArea.innerHTML = tagsText;
$("#btnEditPhoto--crdn01020-info").show();
}
} else {
var displayArea = document.querySelector("#displayForNew--${pageName}");
var concatArr = $P.localUploadArr.concat($P.numberPlateArr).concat($P.captureFileArr); var concatArr = $P.localUploadArr.concat($P.numberPlateArr).concat($P.captureFileArr);
var tagsText = $P.fnMakeImgForNewFile(concatArr); var tagsText = $P.fnMakeImgForNewFile(concatArr);
displayArea.innerHTML = tagsText; displayArea.innerHTML = tagsText;
}
}; };
$P.fnSave = () => { $P.fnSave = () => {
@ -471,7 +502,7 @@ $(document).ready(function(){
file.url = (window.URL || window.webkitURL).createObjectURL(file); file.url = (window.URL || window.webkitURL).createObjectURL(file);
$P.captureFileArr.push(file); $P.captureFileArr.push(file);
if(index === array.length - 1){ if(index === array.length - 1){
$P.fnDisplay(); $P.fnDisplay(false);
} }
}); });
}); });
@ -485,14 +516,19 @@ $(document).ready(function(){
if(isNumberPlate){ if(isNumberPlate){
$P.numberPlateArr.push(modifiedFile); $P.numberPlateArr.push(modifiedFile);
$P.fnDisplay(); $P.fnDisplay(false);
} else { } else {
// TODO : 편집된사진 표시 $P.existFileArr.forEach(function(item,index){
} if(item.FILE_ID == originalFileInfo.FILE_ID){
modifiedFile.URL = modifiedFile.url;
console.log(originalFileInfo); modifiedFile.FILE_ID = originalFileInfo.FILE_ID;
modifiedFile.status = "modified";
$P.existFileArr.splice(index, 1, modifiedFile);
};
});
$P.fnDisplay(true);
}
} }
/************************************************************************** /**************************************************************************
* element.on * element.on
@ -511,7 +547,7 @@ $(document).ready(function(){
); );
}); });
$("#btnEditPhoto--${pageName}").on('click', () => { $("#btnEditPhoto--${pageName}").on('click', () => {
var checked = $("#display0--${pageName}").find("[name='existPhoto']:checked"); var checked = $("#displayForExist--${pageName}").find("[name='existPhoto']:checked");
if(checked.length < 1){ if(checked.length < 1){
alert("선택된 사진이 없습니다."); alert("선택된 사진이 없습니다.");
return; return;
@ -526,11 +562,26 @@ $(document).ready(function(){
}); });
$("#btnDeleteExistPhoto--${pageName}").on('click', () => { $("#btnDeleteExistPhoto--${pageName}").on('click', () => {
//기 등록 사진 삭제
var checked = $("#displayForExist--${pageName}").find("[name='existPhoto']:checked");
if(checked.length < 1){
alert("선택된 사진이 없습니다.");
return;
}
var target = checked[0].value;
$P.existFileArr.forEach(function(item){
if(item.FILE_ID == target){
item.status = "delete";
}
});
$P.fnDisplay(true);
}); });
$("#btnCancelAddFile--${pageName}").on('click', () => { $("#btnCancelAddFile--${pageName}").on('click', () => {
var checked = $("#display--${pageName}").find("[name='newPhoto']:checked"); var checked = $("#displayForNew--${pageName}").find("[name='newPhoto']:checked");
if(checked.length < 1){ if(checked.length < 1){
alert("선택된 사진이 없습니다."); alert("선택된 사진이 없습니다.");
return; return;
@ -545,7 +596,7 @@ $(document).ready(function(){
$P.localUploadArr = $P.localUploadArr.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.numberPlateArr = $P.numberPlateArr.filter(item => checkedArr.indexOf(item.id) == -1);
$P.fnDisplay(); $P.fnDisplay(false);
}); });
/************************************************************************** /**************************************************************************
@ -586,6 +637,8 @@ $(document).ready(function(){
//보안모드 //보안모드
fn_securityModeToggle($("#securityMode--top").is(":checked")); fn_securityModeToggle($("#securityMode--top").is(":checked"));
var crdnInfo = ${crdnInfo}; var crdnInfo = ${crdnInfo};
crdnInfo.CVLCPT_APLY_CN = escapeHTMLEntity(crdnInfo.CVLCPT_APLY_CN); crdnInfo.CVLCPT_APLY_CN = escapeHTMLEntity(crdnInfo.CVLCPT_APLY_CN);
$P.crdnControl.setData([crdnInfo]); $P.crdnControl.setData([crdnInfo]);
@ -595,14 +648,13 @@ $(document).ready(function(){
} }
if(crdnInfo.fileList){ if(crdnInfo.fileList){
var tagsText = $P.fnMakeImgForExistFile(crdnInfo.fileList); crdnInfo.fileList.forEach(function(item){
$("#display0--${pageName}").append(tagsText); item.status = "";
} else { $P.existFileArr.push(item);
});
$("#display0--${pageName}").append("등록된 사진이 없습니다.");
$("#btnEditPhoto--crdn01020-info").hide();
} }
$P.fnDisplay(true);
}); });

@ -237,7 +237,7 @@
</div> </div>
<div class="card" style="width:400px;"> <div class="card" style="width:400px;">
<form id="frmFile--${pageName}" method="post" enctype="multipart/form-data"> <form id="frmFile--${pageName}" method="post" enctype="multipart/form-data">
<input type="file" id="uploadFileList--${pageName}" name="uploadFileList" multiple accept="image/*" hidden /> <input type="file" id="newFileList--${pageName}" name="newFileList" multiple accept="image/*" hidden />
</form> </form>
<form id="frmUploadSet--${pageName}" method="post" enctype="multipart/form-data"> <form id="frmUploadSet--${pageName}" method="post" enctype="multipart/form-data">
@ -297,16 +297,14 @@ $(document).ready(function(){
formData.append(key,value); formData.append(key,value);
} }
if(formData.get("uploadFileList").size == 0){ formData.delete("newFileList");
formData.delete("uploadFileList");
}
if($P.localUploadArr.length > 0){ if($P.localUploadArr.length > 0){
$P.localUploadArr.forEach(item => formData.append("uploadFileList",item)); $P.localUploadArr.forEach(item => formData.append("newFileList",item));
} }
if($P.captureFileArr.length > 0){ if($P.captureFileArr.length > 0){
$P.captureFileArr.forEach(item => formData.append("uploadFileList",item)); $P.captureFileArr.forEach(item => formData.append("newFileList",item));
} }
ajax.post({ ajax.post({
@ -349,7 +347,7 @@ $(document).ready(function(){
tagsText += "</label>"; tagsText += "</label>";
if(index % 2 == 1){ if(index % 2 == 1){
tagsText += "<br />" tagsText += "<br />";
} }
} }

@ -40,7 +40,7 @@
</label> </label>
</div> </div>
<button type="button" class="btn btn-outline-dark"> <button type="button" class="btn btn-outline-dark">
민원관리 종합민원관리
</button> </button>
<button type="button" class="btn btn-outline-dark"> <button type="button" class="btn btn-outline-dark">
일정관리 일정관리

Loading…
Cancel
Save