From 249342c5ca22482556411eea18319379aa71a56d Mon Sep 17 00:00:00 2001 From: leebj Date: Mon, 24 Jun 2024 18:14:05 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=90=EA=B8=B0=EC=8B=A0=EC=B2=AD=EC=84=9C?= =?UTF-8?q?=20=EC=A0=91=EC=88=98=20=EC=83=81=EC=84=B8=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=EB=B3=80=EA=B2=BD=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/adds/cmm/model/DsuseReceiptDtl.java | 19 +++++ .../xit/adds/nims/web/AddsNimsController.java | 16 ++++- .../jsp/adds/nims/dsuseMgtReceipt-info.jsp | 70 +++++++++++++++---- .../jsp/adds/nims/dsuseMgtReceipt-main.jsp | 27 ++++++- .../jsp/adds/nims/dsuseMgtRslt-info.jsp | 2 - .../js/adds/cmmn/adds-componentization.js | 24 +++++-- 6 files changed, 134 insertions(+), 24 deletions(-) create mode 100644 src/main/java/cokr/xit/adds/cmm/model/DsuseReceiptDtl.java diff --git a/src/main/java/cokr/xit/adds/cmm/model/DsuseReceiptDtl.java b/src/main/java/cokr/xit/adds/cmm/model/DsuseReceiptDtl.java new file mode 100644 index 0000000..3b37311 --- /dev/null +++ b/src/main/java/cokr/xit/adds/cmm/model/DsuseReceiptDtl.java @@ -0,0 +1,19 @@ +package cokr.xit.adds.cmm.model; + +import lombok.Data; + +@Data +public class DsuseReceiptDtl { + + private String dscdmngSn; + private String prductNm; + private String prductCd; + private String prdValidDe; + private String mnfNo; + private String mnfSeq; + private String minDistbQy; + private String minDistbUnit; + private String pceQy; + private String pceUnit; + private String dsuseQy; +} diff --git a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java index d2ac373..a7215a4 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -16,6 +16,7 @@ import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.adds.cmm.model.DsuseMappingInfo; +import cokr.xit.adds.cmm.model.DsuseReceiptDtl; import cokr.xit.adds.cmm.model.DsuseRsltInfo; import cokr.xit.adds.cmmn.hwp.format.DisposeProcessDetails; import cokr.xit.adds.cmmn.hwp.format.DisposeResultReport; @@ -68,14 +69,27 @@ public class AddsNimsController extends ApplicationController { @RequestMapping(value = "/dsuseMgtReceipt-info.do", name="신청서 접수 상세") - public ModelAndView getDsuseMgtReceiptInfo(DsuseRsltInfo dsuseReceptInfo) { + public ModelAndView getDsuseMgtReceiptInfo(DsuseRsltInfo dsuseReceptInfo, String productList) { ModelAndView mav = new ModelAndView("adds/nims/dsuseMgtReceipt-info"); setCmmCode("ADDS04", mav); + List fileInfo = new ArrayList(); + if(!isEmpty(dsuseReceptInfo) && !isEmpty(dsuseReceptInfo.getDscdmngId())){ mav.addObject("dsuseReceptInfo", toJson(dsuseReceptInfo)); + + FileQuery fileQuery = new FileQuery().setInfoType("100").setInfoKeys(dsuseReceptInfo.getDscdmngId()).setOrderBy("SUB_TYPE"); + fileInfo = fileService.getFileList(fileQuery); + } + + if(productList != null) { + List DsuseReceiptDtls = fromJson(productList, new TypeReference>() {}); + mav.addObject("dsuseReceptDtlInfo", toJson(DsuseReceiptDtls)); + } else { + mav.addObject("dsuseReceptDtlInfo", toJson(new ArrayList())); } + mav.addObject("fileInfo", toJson(fileInfo)); return mav .addObject("pageName", "dsuseMgtReceiptInfo") // View(jsp)에서 사용할 id 뒤에 붙일 suffix .addObject("apiHost", apiHost); diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-info.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-info.jsp index 8f1d1de..5c10fc0 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-info.jsp @@ -330,7 +330,8 @@ $P.productList.onAppend = item => { if (!item) return; - + if (item.length < 1) return; + // 업무별 DataTables(그리드) tr, td let foundContent = document.getElementById("productListRow--productList").content; let foundTr = $(foundContent).find("tr")[0].cloneNode(false); @@ -344,13 +345,20 @@ let replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].productList.setCurrent('" + dataItem.getValue("keyCnt") + "');"); - let di = $P.productList.getData(item[0].keyCnt, "item"); - - let tr = di.inString(foundTr.outerHTML, replacer); - - $("#tbody--productList").append(tr); - fnMakeGridImageViewer($("#tbody--productList").find("td.prdDsuseImg").last()[0], "dsusePrdImgFiles"); + for(let i=0; i { @@ -400,7 +408,7 @@ * 버튼 clickEvent **************************************************************************/ // 저장 - $P.fnSave = () => { + $P.fnSave = async() => { // validate 확인 if (!customValidate($("#frmEdit--${pageName}").find("input, select, textarea"))) return; @@ -420,23 +428,46 @@ return false; } - let fileArr = []; + let fileCount = 0; $("#tbody--productList").find("input[type='file'][name='dsusePrdImgFiles']").each(function() { - fileArr.push(this.files[0]); + if(this.dataset.url != null){ + fileCount++; + } else if(this.files[0] != null){ + fileCount++; + } }); - if(dsProd.length != fileArr.length){ + if(dsProd.length != fileCount){ dialog.alert({ content: "입력되지 않은 폐기 제품 이미지가 있습니다." }); return false; } + dialog.alert({ content: "현재 폐기 신청서 접수 정보를 저장 하시겠습니까?" , init: () => { setDialogZindex(); } , onOK: () => { - $P.control.save(bsshData, dsProd, fileArr); // formFields + + let promiseArr = []; + $("#tbody--productList").find("input[type='file'][name='dsusePrdImgFiles']").each(function() { + if(this.files[0] != null){ + let elementFile = this.files[0]; + promiseArr.push( new Promise(resolve => { resolve(elementFile); }) ); + } else { + let fileInfo = {}; + fileInfo.URL = this.dataset.url; + fileInfo.MIME_TYPE = this.dataset.mimeType; + fileInfo.FILE_NM = this.dataset.fileNm; + fileInfo.FILE_ID = this.dataset.fileId; + promiseArr.push(fnCreateFileFromFileInfo(fileInfo)); + } + }); + + Promise.all(promiseArr).then((values) => { + $P.control.save(bsshData, dsProd, values); + }).catch((error) => {}); } }); } @@ -533,7 +564,20 @@ // 3. Dataset 설정 $P.control.setData([${dsuseReceptInfo}]); - //$P.productControl.setData([${opnnDlbrMbrInfo}]); + + let productInfo = ${dsuseReceptDtlInfo}; + let fileInfo = ${fileInfo}; + + for(let p of productInfo){ + p.keyCnt = (""+prdRowKey++); + for(let f of fileInfo){ + if(p.dscdmngSn == f.SUB_TYPE){ + p.fileInfo = f; + } + } + } + $P.productList.append(productInfo); + }); diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-main.jsp index 659219d..b4ffd4e 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtReceipt-main.jsp @@ -286,7 +286,7 @@ let dialogTitle = "폐기 신청서 접수"; if(dscdmngId) dialogTitle = "폐기 신청서 접수 상세"; - + let formData = new FormData(); let params = {}; if(dscdmngId) { let row = $P.control.dataset.getCurrent(); @@ -297,10 +297,31 @@ rprsntvNm: row.RPRSNTV_NM, prmisnNo: row.PRMISN_NO, bizrno: row.BIZR_NO, - dsusePrvCd: row.DSUSE_PRV_CD, + dsusePrvCd: row.DSUSE_PRV_CD }; + let productDS = $P.detailControl.dataset.getDataset(); + if(productDS.length > 0){ + let newArr = []; + for(let product of productDS){ + let newObj = {}; + newObj.dscdmngSn = product.DSCDMNG_SN; + newObj.prductNm = product.PRDUCT_NM; + newObj.prductCd = product.PRDUCT_CD; + newObj.prdValidDe = product.PRD_VALID_DE; + newObj.mnfNo = product.MNF_NO; + newObj.mnfSeq = product.MNF_SEQ; + newObj.minDistbQy = product.MIN_DISTB_QY; + newObj.minDistbUnit = product.MIN_DISTB_UNIT; + newObj.pceQy = product.PCE_QY; + newObj.pceUnit = product.PCE_UNIT; + newObj.dsuseQy = product.DSUSE_QY; + newArr.push(newObj); + } + params.productList = JSON.stringify(newArr); + + } } - + ajax.get({ url : wctx.url("/adds/nims/dsuseMgtReceipt-info.do") , data : params diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp index 7261731..40b47cf 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp @@ -489,12 +489,10 @@ } try{ - fnCreateFileFromFileInfo(f) promiseArr.push(fnCreateFileFromFileInfo(f)); }catch(e){ console.log(e); } - //promiseArr.push(fnCreateFileFromFileInfo(f)); }); Promise.all(promiseArr).then((values) => { diff --git a/src/main/webapp/resources/js/adds/cmmn/adds-componentization.js b/src/main/webapp/resources/js/adds/cmmn/adds-componentization.js index 632bc4c..61e11b7 100644 --- a/src/main/webapp/resources/js/adds/cmmn/adds-componentization.js +++ b/src/main/webapp/resources/js/adds/cmmn/adds-componentization.js @@ -1,7 +1,7 @@ /************************************************************************** * 그리드 내부 이미지 첨부 **************************************************************************/ -function fnMakeGridImageViewer(tdEl, fileInputElName){ +function fnMakeGridImageViewer(tdEl, fileInputElName, fileInfo){ let fileInputEl = document.createElement("input"); fileInputEl.name = fileInputElName; @@ -10,6 +10,13 @@ function fnMakeGridImageViewer(tdEl, fileInputElName){ fileInputEl.setAttribute("accept","image/*") tdEl.appendChild(fileInputEl); + if(fileInfo != null){ + fileInputEl.dataset.url = fileInfo.URL; + fileInputEl.dataset.fileNm = fileInfo.FILE_NM; + fileInputEl.dataset.mimeType = fileInfo.MIME_TYPE; + fileInputEl.dataset.fileId = fileInfo.FILE_ID; + } + let uploadButtonEl = document.createElement("button"); uploadButtonEl.type = "button"; uploadButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1"); @@ -27,6 +34,9 @@ function fnMakeGridImageViewer(tdEl, fileInputElName){ if(this.files != null && this.files.length > 0){ $(uploadButtonEl).text("수정"); $(viewButtonEl).removeAttr("hidden"); + } else if(this.dataset.url != null){ + $(uploadButtonEl).text("수정"); + $(viewButtonEl).removeAttr("hidden"); } else { $(uploadButtonEl).text("등록"); $(viewButtonEl).attr("hidden","hidden"); @@ -38,11 +48,15 @@ function fnMakeGridImageViewer(tdEl, fileInputElName){ }); $(viewButtonEl).on("click", function(){ - - let viewUrl = (window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0]); - + + let viewUrl = ""; + if(fileInputEl.files.length != 0){ + viewUrl = (window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0]); + } else { + viewUrl = fileInputEl.dataset.url; + } window.open(viewUrl, "이미지", "width=500, height=500"); }); - + $(fileInputEl).trigger("change"); } \ No newline at end of file