단속사진 파일업로드 수정

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

@ -12,6 +12,16 @@ import lombok.Setter;
public class Crdn extends AbstractEntity {
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 org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.CommonCode;
@ -129,6 +130,8 @@ public class Crdn01Controller extends ApplicationController {
DataObject info = crdn01Service.getCivilComplaintReceiptInitialDataInfo(req);
mav.addObject("crdnInfo", json ? info : toJson(info));
mav.addObject("openerPageName", request.getParameter("openerPageName"));
return mav;
}
@ -183,6 +186,23 @@ public class Crdn01Controller extends ApplicationController {
.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
*/

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

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

@ -253,7 +253,7 @@
<div class="col-md-6">
<div class="row justify-content-end">
<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>
@ -263,7 +263,8 @@
</div>
<div class="card" style="width:500px;">
<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>
<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>
</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>
<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>
</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>
@ -305,6 +306,8 @@ $(document).ready(function(){
var $P = pageObject["${pageName}"];
$P.existFileArr = [];
$P.captureFileArr = [];
$P.localUploadArr = [];
$P.numberPlateArr = [];
@ -317,7 +320,7 @@ $(document).ready(function(){
$P.uploadSet = uploadSupport("#inputUploadSet--${pageName}");
$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 : "",
dataGetter:obj => obj.crdnInfo,
formats: {
@ -337,21 +340,31 @@ $(document).ready(function(){
formData.append(key,value);
}
if(formData.get("uploadFileList").size == 0){
formData.delete("uploadFileList");
}
formData.delete("newFileList");
formData.delete("modifyFileList");
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){
$P.numberPlateArr.forEach(item => formData.append("uploadFileList",item));
$P.numberPlateArr.forEach(item => formData.append("newFileList",item));
}
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({
url:!create ? $P.crdnControl.urls.update : $P.crdnControl.urls.create,
@ -371,14 +384,14 @@ $(document).ready(function(){
var files = $P.uploadSet.getDataset();
files.forEach(item => $P.localUploadArr.push(item));
$P.fnDisplay();
$P.fnDisplay(false);
};
$P.uploadSet.onRemove = () => { };
$P.crdnControl.onSave = (resp) => {
if (resp.saved) {
dialog.alert("저장됐습니다.");
dialog.close("manualdialog");
dialog.close("cvlcptInitialDataEditDialog--${openerPageName}");
}
};
/**************************************************************************
@ -387,9 +400,13 @@ $(document).ready(function(){
$P.fnMakeImgForExistFile = (fileArr) => {
var tagsText = "";
for(var index = 0; index < fileArr.length; index++){
for(var index = 0, j = 0; index < fileArr.length; index++){
var item = fileArr[index];
if(item.status == "delete"){
continue;
}
tagsText += "<label class='mx-2'>";
tagsText += "<input type='radio' name='existPhoto' class='form-check-input' value='"+item.FILE_ID +"' ";
if(index == 0){
@ -399,9 +416,11 @@ $(document).ready(function(){
tagsText += "<img src='"+ item.URL +"' width='200' height='200' />";
tagsText += "</label>";
if(index % 2 == 1){
tagsText += "<br />"
if(j % 2 == 1){
tagsText += "<br />";
}
j++;
}
return tagsText;
@ -421,19 +440,31 @@ $(document).ready(function(){
tagsText += "</label>";
if(index % 2 == 1){
tagsText += "<br />"
tagsText += "<br />";
}
}
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.fnDisplay = (isExist) => {
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 tagsText = $P.fnMakeImgForNewFile(concatArr);
displayArea.innerHTML = tagsText;
}
};
$P.fnSave = () => {
@ -471,7 +502,7 @@ $(document).ready(function(){
file.url = (window.URL || window.webkitURL).createObjectURL(file);
$P.captureFileArr.push(file);
if(index === array.length - 1){
$P.fnDisplay();
$P.fnDisplay(false);
}
});
});
@ -485,14 +516,19 @@ $(document).ready(function(){
if(isNumberPlate){
$P.numberPlateArr.push(modifiedFile);
$P.fnDisplay();
$P.fnDisplay(false);
} else {
// TODO : 편집된사진 표시
}
console.log(originalFileInfo);
$P.existFileArr.forEach(function(item,index){
if(item.FILE_ID == originalFileInfo.FILE_ID){
modifiedFile.URL = modifiedFile.url;
modifiedFile.FILE_ID = originalFileInfo.FILE_ID;
modifiedFile.status = "modified";
$P.existFileArr.splice(index, 1, modifiedFile);
};
});
$P.fnDisplay(true);
}
}
/**************************************************************************
* element.on
@ -511,7 +547,7 @@ $(document).ready(function(){
);
});
$("#btnEditPhoto--${pageName}").on('click', () => {
var checked = $("#display0--${pageName}").find("[name='existPhoto']:checked");
var checked = $("#displayForExist--${pageName}").find("[name='existPhoto']:checked");
if(checked.length < 1){
alert("선택된 사진이 없습니다.");
return;
@ -526,11 +562,26 @@ $(document).ready(function(){
});
$("#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', () => {
var checked = $("#display--${pageName}").find("[name='newPhoto']:checked");
var checked = $("#displayForNew--${pageName}").find("[name='newPhoto']:checked");
if(checked.length < 1){
alert("선택된 사진이 없습니다.");
return;
@ -545,7 +596,7 @@ $(document).ready(function(){
$P.localUploadArr = $P.localUploadArr.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"));
var crdnInfo = ${crdnInfo};
crdnInfo.CVLCPT_APLY_CN = escapeHTMLEntity(crdnInfo.CVLCPT_APLY_CN);
$P.crdnControl.setData([crdnInfo]);
@ -595,14 +648,13 @@ $(document).ready(function(){
}
if(crdnInfo.fileList){
var tagsText = $P.fnMakeImgForExistFile(crdnInfo.fileList);
$("#display0--${pageName}").append(tagsText);
} else {
$("#display0--${pageName}").append("등록된 사진이 없습니다.");
$("#btnEditPhoto--crdn01020-info").hide();
crdnInfo.fileList.forEach(function(item){
item.status = "";
$P.existFileArr.push(item);
});
}
$P.fnDisplay(true);
});

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

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

Loading…
Cancel
Save