diff --git a/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp index ef70f3f6..0714c489 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp @@ -77,7 +77,7 @@ function executeBatch(batch){ ajax.get({ url : wctx.url("/admin/executeBatch.do"), data : { batch : batch}, - success : resp => { + success : (resp) => { dialog.alert("실행되었습니다."); } }); @@ -100,7 +100,7 @@ function exceuteAlert(alertName){ alertName : alertName, interfaceKey : interfaceKey }, - success : resp => { + success : (resp) => { dialog.alert("실행되었습니다."); } }); @@ -131,7 +131,7 @@ function customContextMenu(node){ data : { directories : pathArray }, - success : resp => { + success : (resp) => { if(resp.saved){ getFileTree(); } else { @@ -166,7 +166,7 @@ function customContextMenu(node){ data : { directories : pathArray }, - success : resp => { + success : (resp) => { $("#viewCn").val(resp.fileCn); } }); @@ -220,7 +220,7 @@ function getFileTree(){ url : wctx.url("/admin/getFileTree.do"), data : {}, headers: { Accept: "application/json; charset=utf-8" }, - success : resp => { + success : (resp) => { $('#fileTree').jstree(true).settings.core.data = resp.tree; $('#fileTree').jstree(true).refresh(); @@ -246,7 +246,7 @@ function fnImportFile(obj){ data : form, processData : false, contentType : false, - success : resp => { + success : (resp) => { if(resp.saved){ getFileTree(); } else { diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02010-main.jsp index 01c1ee59..04eaef64 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02010-main.jsp @@ -406,17 +406,23 @@ $(document).ready(function(){ $P.photoInspectionControl.defaultFetchSize = FETCH_XS; $P.photoInspectionControl.untilPageNum = 0; $P.photoInspectionControl.beforeCurrent = null; - $P.photoInspectionControl.tableRenderComplete = false; //동일차량검사 datasetControl 인스턴스 - $P.sameVehicleControl = new InspectionControl({ + $P.sameVehicleMainControl = new DatasetControl({ urls : { load : "", getInfo : "" }, dataGetter : obj => obj["List"], appendData:true, keymapper : info => info ? info.CRDN_ID_LIST : "", - formats: { CRDN_CNT : numberFormat, FFNLG_CRDN_AMT : numberFormat } - }, - { + formats: { + CRDN_CNT : numberFormat, + FFNLG_CRDN_AMT : numberFormat + } + }); + $P.sameVehicleMainControl.defaultFetchSize = FETCH_XS; + $P.sameVehicleMainControl.untilPageNum = 0; + $P.sameVehicleMainControl.beforeCurrent = null; + + $P.sameVehicleSubControl = new DatasetControl({ urls : { load : "", getInfo : "" }, dataGetter : obj => obj["List"], keymapper : info => info ? info.CRDN_ID : "", @@ -426,14 +432,8 @@ $(document).ready(function(){ CRDN_STTS_CD : FIM010, FFNLG_CRDN_AMT : numberFormat } - } - ); - $P.sameVehicleControl.defaultFetchSize = FETCH_XS; - $P.sameVehicleControl.untilPageNum = 0; - $P.sameVehicleControl.main.beforeCurrent = null; - $P.sameVehicleControl.main.tableRenderComplete = false; - $P.sameVehicleControl.sub.tableRenderComplete = false; - + }); + $P.photoInspectionControl.getNext = (key) => { var ds = $P.photoInspectionControl.dataset.getDataset(); @@ -446,126 +446,61 @@ $(document).ready(function(){ } } /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.photoInspectionControl.onDatasetChange = (obj) => { - - $P.renderInspectionDataList(obj["Total"], "photoInspection"); + $P.photoInspectionControl.dataset.onDatasetChange = (obj) => { - $("#photoInspectionPaging--${pageName}").setPagingInfo({ - list : $P.photoInspectionControl.dataset, - prefix : "photoInspectionPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.photoInspectionControl.tableRenderComplete = true; + var t = $P.getGridTemplate("photoInspection"); + var trs = Apply.fromDataset.getTbody($P.photoInspectionControl.dataset, t.found, t.notFound, t.replacer); + $P.renderInspectionDataList(obj["Total"], $P.photoInspectionControl.dataset.length, trs, "photoInspection"); + + Apply.fromDataset.paging($P.photoInspectionControl.dataset, obj, "photoInspectionPaging--${pageName}"); }; - $P.photoInspectionControl.onCurrentChange = (DI) => { - - if(!$P.photoInspectionControl.tableRenderComplete){ - return; - } - - if($P.photoInspectionControl.beforeCurrent != null){ - var beforeCurrentKey = $P.photoInspectionControl.beforeCurrent.key; - var beforeCurrentIndex = $P.photoInspectionControl.beforeCurrent.index; - $P.photoInspectionControl.beforeCurrent = null; - - if(!$P.photoInspectionControl.dataset.empty){ - var info = $P.photoInspectionControl.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.photoInspectionControl.dataset.setCurrent(beforeCurrentKey, true); - return; - } - - if(beforeCurrentIndex > ($P.photoInspectionControl.dataset.length - 1)){ - info = $P.photoInspectionControl.dataset.getDataset()[$P.photoInspectionControl.dataset.length - 1]; - } else { - info = $P.photoInspectionControl.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.photoInspectionControl.dataset.setCurrent(info["CRDN_ID"], true); - return; - } - } - - $P.photoInspectionControl.tableRenderComplete = false; - if(!DI){ - $P.clickInspectionDataList("","photoInspection", true); - } else { - $P.clickInspectionDataList($P.photoInspectionControl.getCurrent()["CRDN_ID"],"photoInspection", true); + $P.photoInspectionControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.photoInspectionControl.dataset, dataItem, $("#photoInspectionTbody--${pageName}")[0]); + + var dataKey = ""; + var curDataVhrno = ""; + var nextDataKey = ""; + var nextDataVhrno = ""; + if(!$P.photoInspectionControl.dataset.empty){ + dataKey = $P.photoInspectionControl.dataset.getKey(dataItem); + curDataVhrno = $P.photoInspectionControl.dataset.getData(dataKey)["VHRNO"]; + var nextData = $P.photoInspectionControl.getNext(dataKey); + nextDataKey = nextData != null ? nextData.CRDN_ID : ""; + nextDataVhrno = nextData != null ? nextData.VHRNO : ""; } + + $P.showPhoto(dataKey,nextDataKey,curDataVhrno,nextDataVhrno); } - $P.sameVehicleControl.main.onDatasetChange = (obj) => { + $P.sameVehicleMainControl.dataset.onDatasetChange = (obj) => { - $P.renderInspectionDataList(obj["Total"], "sameVehicleInspectionMain"); - - $("#sameVehicleInspectionMainPaging--${pageName}").setPagingInfo({ - list : $P.sameVehicleControl.main.dataset, - prefix : "sameVehicleInspectionMainPaging--${pageName}", - totalSize : obj["Total"] - }); - - - $P.sameVehicleControl.main.tableRenderComplete = true; + var t = $P.getGridTemplate("sameVehicleInspectionMain"); + var trs = Apply.fromDataset.getTbody($P.sameVehicleMainControl.dataset, t.found, t.notFound, t.replacer); + $P.renderInspectionDataList(obj["Total"], $P.sameVehicleMainControl.dataset.length, trs, "sameVehicleInspectionMain"); + + Apply.fromDataset.paging($P.sameVehicleMainControl.dataset, obj, "sameVehicleInspectionMainPaging--${pageName}"); }; - $P.sameVehicleControl.main.onCurrentChange = (DI) => { - if(!$P.sameVehicleControl.main.tableRenderComplete){ - return; - } - - if($P.sameVehicleControl.main.beforeCurrent != null){ - var beforeCurrentKey = $P.sameVehicleControl.main.beforeCurrent.key; - var beforeCurrentIndex = $P.sameVehicleControl.main.beforeCurrent.index; - $P.sameVehicleControl.main.beforeCurrent = null; - - if(!$P.sameVehicleControl.main.dataset.empty){ - var info = $P.sameVehicleControl.main.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.sameVehicleControl.main.dataset.setCurrent(beforeCurrentKey,true); - return; - } - - if(beforeCurrentIndex > ($P.sameVehicleControl.main.dataset.length - 1)){ - info = $P.sameVehicleControl.main.dataset.getDataset()[$P.sameVehicleControl.main.dataset.length - 1]; - } else { - info = $P.sameVehicleControl.main.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.sameVehicleControl.main.dataset.setCurrent(info["CRDN_ID_LIST"],true); - return; - } - } - - $P.sameVehicleControl.main.tableRenderComplete = false; - if(!DI){ - $P.clickInspectionDataList("","sameVehicleInspectionMain", true); + $P.sameVehicleMainControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.sameVehicleMainControl.dataset, dataItem, $("#sameVehicleInspectionMainTbody--${pageName}")[0]); + if(dataItem){ + $P.searchDetailInspectionDataList(dataItem.data["CRDN_ID_LIST"]); } else { - $P.clickInspectionDataList($P.sameVehicleControl.main.getCurrent()["CRDN_ID_LIST"],"sameVehicleInspectionMain", true); + $("#sameVehicleInspectionSubTbody--${pageName}").html(""); } } - $P.sameVehicleControl.sub.onDatasetChange = (obj) => { - $P.renderInspectionDataList(obj["Total"], "sameVehicleInspectionSub"); - $P.sameVehicleControl.sub.tableRenderComplete = true; + $P.sameVehicleSubControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate("sameVehicleInspectionSub"); + var trs = Apply.fromDataset.getTbody($P.sameVehicleSubControl.dataset, t.found, t.notFound, t.replacer); + $P.renderInspectionDataList(obj["Total"], $P.sameVehicleSubControl.dataset.length, trs, "sameVehicleInspectionSub"); }; - $P.sameVehicleControl.sub.onCurrentChange = (DI) => { - if(!$P.sameVehicleControl.sub.tableRenderComplete){ - return; - } - - $P.sameVehicleControl.sub.tableRenderComplete = false; - if(!DI){ - $P.clickInspectionDataList("","sameVehicleInspectionSub", true); - } else { - $P.clickInspectionDataList($P.sameVehicleControl.sub.getCurrent()["CRDN_ID"],"sameVehicleInspectionSub", true); - } + $P.sameVehicleSubControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.sameVehicleSubControl.dataset, dataItem, $("#sameVehicleInspectionSubTbody--${pageName}")[0]); }; /************************************************************************** @@ -583,17 +518,17 @@ $(document).ready(function(){ $('#schCrdnYmdFrom--${pageName}').datepicker('setDate', DateUtil.getDateDay(-7).date); $('#schCrdnYmdTo--${pageName}').datepicker('setDate', new Date()); $P.photoInspectionControl.setData([]); - $P.sameVehicleControl.main.setData([]); + $P.sameVehicleMainControl.setData([]); }; - + $P.fnResetAndChangeBiz = (taskSeCd) => { $P.fnReset(); $P.photoInspectionControl.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn02/020/list.do"); $P.photoInspectionControl.urls.getInfo = ""; - $P.sameVehicleControl.main.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn02/020/list.do"); - $P.sameVehicleControl.main.urls.getInfo = ""; - $P.sameVehicleControl.sub.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn02/020/list.do"); - $P.sameVehicleControl.sub.urls.getInfo = ""; + $P.sameVehicleMainControl.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn02/020/list.do"); + $P.sameVehicleMainControl.urls.getInfo = ""; + $P.sameVehicleSubControl.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn02/020/list.do"); + $P.sameVehicleSubControl.urls.getInfo = ""; var clsForTask = taskSeCd.toLowerCase(); //업무별 조회조건 @@ -607,31 +542,19 @@ $(document).ready(function(){ $('#btnPhotoInspection--${pageName}').trigger("click"); } + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); - $P.refreshInspectionList = () => { - switch ($P.currentDisplay) { - case "photoInspection": - $P.photoInspectionControl.untilPageNum = $P.photoInspectionControl.query.pageNum; - $P.photoInspectionControl.query.fetchSize = $P.photoInspectionControl.defaultFetchSize * $P.photoInspectionControl.query.pageNum; - $P.photoInspectionControl.beforeCurrent = { - key : $P.photoInspectionControl.getCurrent()["CRDN_ID"], - index : $P.photoInspectionControl.getCurrent()["ROW_NUM"] - 1 - }; - $P.photoInspectionControl.load(1); - break; - case "sameVehicleInspection": - $P.sameVehicleControl.untilPageNum = $P.sameVehicleControl.main.query.pageNum; - $P.sameVehicleControl.main.query.fetchSize = $P.sameVehicleControl.defaultFetchSize * $P.sameVehicleControl.main.query.pageNum; - $P.sameVehicleControl.main.beforeCurrent = { - key : $P.sameVehicleControl.main.getCurrent()["CRDN_ID_LIST"], - index : $P.sameVehicleControl.main.getCurrent()["ROW_NUM"] - 1 - }; - $P.sameVehicleControl.main.load(1); - break; - default: break; + if($P.currentDisplay == "photoInspection"){ + data.fetchSize = $P.photoInspectionControl.defaultFetchSize; + } else if($P.currentDisplay == "sameVehicleInspection"){ + data.fetchSize = $P.sameVehicleMainControl.defaultFetchSize; } - } + return data; + } + $P.searchInspectionList = () => { switch ($P.currentDisplay) { case "photoInspection": @@ -640,19 +563,20 @@ $(document).ready(function(){ $P.photoInspectionControl.load(1); break; case "sameVehicleInspection": - $P.sameVehicleControl.main.query = $P.getParams(); - $P.sameVehicleControl.main.query.inspectionDataType = "sameVehicleMain"; - $P.sameVehicleControl.main.load(1); + $P.sameVehicleMainControl.query = $P.getParams(); + $P.sameVehicleMainControl.query.inspectionDataType = "sameVehicleMain"; + $P.sameVehicleMainControl.load(1); break; default: break; } } + $P.searchDetailInspectionDataList = (dataKey) => { - $P.sameVehicleControl.sub.query = {}; - $P.sameVehicleControl.sub.query.inspectionDataType = "sameVehicleSub"; - $P.sameVehicleControl.sub.query.crdnIDs = dataKey; - $P.sameVehicleControl.sub.query.taskSeCd = $P.sameVehicleControl.main.query.taskSeCd; - $P.sameVehicleControl.sub.load(0); + $P.sameVehicleSubControl.query = {}; + $P.sameVehicleSubControl.query.inspectionDataType = "sameVehicleSub"; + $P.sameVehicleSubControl.query.crdnIDs = dataKey; + $P.sameVehicleSubControl.query.taskSeCd = $P.sameVehicleMainControl.query.taskSeCd; + $P.sameVehicleSubControl.load(0); } $P.scrollInspectionDataList = () => { @@ -661,91 +585,252 @@ $(document).ready(function(){ $P.photoInspectionControl.load($P.photoInspectionControl.query.pageNum + 1); break; case "sameVehicleInspection": - $P.sameVehicleControl.main.load($P.sameVehicleControl.main.query.pageNum + 1); + $P.sameVehicleMainControl.load($P.sameVehicleMainControl.query.pageNum + 1); break; default: break; } } - $P.clickInspectionDataList = (dataKey, gridType, auto) => { - switch (gridType) { + + $P.refreshInspectionList = () => { + switch ($P.currentDisplay) { case "photoInspection": + $P.photoInspectionControl.untilPageNum = $P.photoInspectionControl.query.pageNum; + $P.photoInspectionControl.query.fetchSize = $P.photoInspectionControl.defaultFetchSize * $P.photoInspectionControl.query.pageNum; + $P.photoInspectionControl.beforeCurrent = { + key : $P.photoInspectionControl.getCurrent()["CRDN_ID"], + index : $P.photoInspectionControl.getCurrent()["ROW_NUM"] - 1 + }; + + Apply.fromDatasetControl.load($P.photoInspectionControl, 1).then((resp)=>{ + Apply.toDataset.set($P.photoInspectionControl.dataset, resp); + $P.photoInspectionControl.dataset.onDatasetChange(resp); + + if($P.photoInspectionControl.untilPageNum != 0){ + $P.photoInspectionControl.query.fetchSize = $P.photoInspectionControl.defaultFetchSize; + $P.photoInspectionControl.query.pageNum = $P.photoInspectionControl.untilPageNum; + $P.photoInspectionControl.untilPageNum = 0; + } + + if($P.photoInspectionControl.beforeCurrent != null){ + var beforeCurrentKey = $P.photoInspectionControl.beforeCurrent.key; + var beforeCurrentIndex = $P.photoInspectionControl.beforeCurrent.index; + $P.photoInspectionControl.beforeCurrent = null; + + if(!$P.photoInspectionControl.dataset.empty){ + var info = $P.photoInspectionControl.dataset.getData(beforeCurrentKey); - if(dataKey == ""){ - $("#curDataVhrno--${pageName}").html(""); - $("#nextDataVhrno--${pageName}").html(""); - $("#curDataFiles--${pageName}").html(""); - $("#nextDataFiles--${pageName}").html(""); - return; - } + if(info != null){ + $P.photoInspectionControl.dataset.setCurrent(beforeCurrentKey, true); - $("#photoInspectionTbody--${pageName}").setCurrentRow(dataKey); + } else { - var curDataVhrno = $P.photoInspectionControl.dataset.getData(dataKey)["VHRNO"]; - var nextData = $P.photoInspectionControl.getNext(dataKey); - var nextDataKey = nextData != null ? nextData.CRDN_ID : ""; - var nextDataVhrno = nextData != null ? nextData.VHRNO : ""; - - $("#curDataVhrno--${pageName}").html(curDataVhrno); - $("#nextDataVhrno--${pageName}").html(nextDataVhrno); - - ajax.get({ - url:"file/list.do", - data: { - infoType : "100", - infoKeys : [dataKey, nextDataKey], - fetchSize : 0 - }, - success : resp => { + if(beforeCurrentIndex > ($P.photoInspectionControl.dataset.length - 1)){ + info = $P.photoInspectionControl.dataset.getDataset()[$P.photoInspectionControl.dataset.length - 1]; + } else { + info = $P.photoInspectionControl.dataset.getDataset()[beforeCurrentIndex]; + } + + $P.photoInspectionControl.dataset.setCurrent(info["CRDN_ID"], true); + + } + } + } + }); + break; + case "sameVehicleInspection": + $P.sameVehicleMainControl.untilPageNum = $P.sameVehicleMainControl.query.pageNum; + $P.sameVehicleMainControl.query.fetchSize = $P.sameVehicleMainControl.defaultFetchSize * $P.sameVehicleMainControl.query.pageNum; + $P.sameVehicleMainControl.beforeCurrent = { + key : $P.sameVehicleMainControl.getCurrent()["CRDN_ID_LIST"], + index : $P.sameVehicleMainControl.getCurrent()["ROW_NUM"] - 1 + }; + + Apply.fromDatasetControl.load($P.sameVehicleMainControl, 1).then((resp)=>{ + Apply.toDataset.set($P.sameVehicleMainControl.dataset, resp); + $P.sameVehicleMainControl.dataset.onDatasetChange(resp); + + if($P.sameVehicleMainControl.untilPageNum != 0){ + $P.sameVehicleMainControl.query.fetchSize = $P.sameVehicleMainControl.defaultFetchSize; + $P.sameVehicleMainControl.query.pageNum = $P.sameVehicleMainControl.untilPageNum; + $P.sameVehicleMainControl.untilPageNum = 0; + } + + if($P.sameVehicleMainControl.beforeCurrent != null){ + var beforeCurrentKey = $P.sameVehicleMainControl.beforeCurrent.key; + var beforeCurrentIndex = $P.sameVehicleMainControl.beforeCurrent.index; + $P.sameVehicleMainControl.beforeCurrent = null; - var fileList = resp.fileList; + if(!$P.sameVehicleMainControl.dataset.empty){ + var info = $P.sameVehicleMainControl.dataset.getData(beforeCurrentKey); - var currentDataFileList = fileList.filter(x => x.INF_KEY == dataKey); - var nextDataFileList = fileList.filter(x => x.INF_KEY == nextDataKey); + if(info != null){ + $P.sameVehicleMainControl.dataset.setCurrent(beforeCurrentKey,true); - $("#curDataFiles--${pageName}").html(""); - $("#nextDataFiles--${pageName}").html(""); + } else { + if(beforeCurrentIndex > ($P.sameVehicleMainControl.dataset.length - 1)){ + info = $P.sameVehicleMainControl.dataset.getDataset()[$P.sameVehicleMainControl.dataset.length - 1]; + } else { + info = $P.sameVehicleMainControl.dataset.getDataset()[beforeCurrentIndex]; + } - currentDataFileList.forEach(function(item, index, array){ - var output = fnMakeImgTagForInspection(item.URL, item.FILE_NM,"cur"+item.FILE_ID+'${pageName}',item.MOSAIC); - $("#curDataFiles--${pageName}").append(output); - }); - nextDataFileList.forEach(function(item, index, array){ - var output = fnMakeImgTagForInspection(item.URL, item.FILE_NM,"next"+item.FILE_ID+'${pageName}',item.MOSAIC); - $("#nextDataFiles--${pageName}").append(output); - }); + $P.sameVehicleMainControl.dataset.setCurrent(info["CRDN_ID_LIST"],true); + } + } } + }); + + break; + default: break; + } + } + + $P.fnExcelDown = () => { + if($P.currentDisplay == "photoInspection"){ + if($P.photoInspectionControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } - if(!auto){ - $P.photoInspectionControl.setCurrent(dataKey); - } + var cellDefs = getCellDefs($("#photoInspection_Table_0--${pageName} thead th").not(".dummy-th").not(":eq(0)"), + $($("#photoInspectionRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); + $P.photoInspectionControl.query.cellDefs = cellDefs; + + $P.photoInspectionControl.download(); + + } else { + + if($P.sameVehicleMainControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + if(confirm("단속건수 엑셀저장은 확인버튼, 상세내역 엑셀저장시 취소버튼을 누르세요.")){ + + var cellDefs = getCellDefs($("#sameVehicleInspectionMain_Table_0--${pageName} thead th").not(".dummy-th"), + $($("#sameVehicleInspectionMainRow--${pageName}")[0].content).find("td").not(".dummy-td")); + $P.sameVehicleMainControl.query.cellDefs = cellDefs; + + $P.sameVehicleMainControl.download(); + } else { + + var cellDefs = getCellDefs($("#sameVehicleInspectionSub_Table_0--${pageName} thead th").not(".dummy-th").not(":hidden"), + $($("#sameVehicleInspectionSubRow--${pageName}")[0].content).find("td").not(".dummy-td").not(".privacy-mask")); + $P.sameVehicleSubControl.query.cellDefs = cellDefs; + + $P.sameVehicleSubControl.download(); + } + + } + } + + $P.getGridTemplate = (gridType) => { + var notFound; + var found; + var replacer; + + switch (gridType) { + case "photoInspection": + notFound = [document.getElementById("photoInspectionNotFound--${pageName}").innerHTML] + found = document.getElementById("photoInspectionRow--${pageName}").innerHTML; + replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','photoInspection');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','photoInspection');"); + + break; + case "sameVehicleInspectionMain": + notFound = [document.getElementById("sameVehicleInspectionMainNotFound--${pageName}").innerHTML]; + found = document.getElementById("sameVehicleInspectionMainRow--${pageName}").innerHTML; + replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID_LIST") + "','sameVehicleInspectionMain');"); + + break; + case "sameVehicleInspectionSub": + notFound = [document.getElementById("sameVehicleInspectionSubNotFound--${pageName}").innerHTML] + found = document.getElementById("sameVehicleInspectionSubRow--${pageName}").innerHTML; + replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','sameVehicleInspectionSub');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','sameVehicleInspectionSub');"); + + break; + } + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderInspectionDataList = (total, listLength, trs, renderDataType) => { + + switch (renderDataType) { + case "photoInspection": + var noMore = (total == listLength); + var initScroll = ($P.photoInspectionControl.query.pageNum < 2) && ($P.photoInspectionControl.untilPageNum == 0); + + $("#photoInspection-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + break; + case "sameVehicleInspectionMain": + + var noMore = (total == listLength); + var initScroll = ($P.sameVehicleMainControl.query.pageNum < 2) && ($P.sameVehicleMainControl.untilPageNum == 0); + + $("#sameVehicleInspectionMain-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + + break; + case "sameVehicleInspectionSub": + + $("#sameVehicleInspectionSubTbody--${pageName}").html(trs); + break; + default: break; + } + + //보안모드 + fn_securityModeToggle($("#securityMode--top").is(":checked")); + } + + $P.clickInspectionDataList = (dataKey, gridType) => { + + switch (gridType) { + case "photoInspection": + + if(dataKey != ""){ + $("#photoInspectionTbody--${pageName}").setCurrentRow(dataKey); + Apply.toDataset.current($P.photoInspectionControl.dataset, dataKey); + } + + var curDataVhrno = $P.photoInspectionControl.dataset.getData(dataKey)["VHRNO"]; + var nextData = $P.photoInspectionControl.getNext(dataKey); + var nextDataKey = nextData != null ? nextData.CRDN_ID : ""; + var nextDataVhrno = nextData != null ? nextData.VHRNO : ""; + $P.showPhoto(dataKey,nextDataKey,curDataVhrno,nextDataVhrno); break; case "sameVehicleInspectionMain": if(dataKey == ""){ - $P.sameVehicleControl.sub.setData([]); return; } $("#sameVehicleInspectionMainTbody--${pageName}").setCurrentRow(dataKey); + + Apply.toDataset.current($P.sameVehicleMainControl.dataset, dataKey); + $P.searchDetailInspectionDataList(dataKey); - if(!auto){ - $P.sameVehicleControl.main.setCurrent(dataKey); - } + break; case "sameVehicleInspectionSub": if(dataKey == ""){ return; } $("#sameVehicleInspectionSubTbody--${pageName}").setCurrentRow(dataKey); - if(!auto){ - $P.sameVehicleControl.sub.setCurrent(dataKey); - } + + Apply.toDataset.current($P.sameVehicleSubControl.dataset, dataKey); break; } } - $P.dblclickInspectionDataList = (dataKey, gridType) => { + $P.dblclickInspectionDataList = (dataKey) => { var taskSeCd = $("#frmSearch--${pageName} input[name='taskSeCd']:checked").val(); @@ -759,7 +844,7 @@ $(document).ready(function(){ ajax.get({ url : dialogUrl, data : params, - success : resp => { + success : (resp) => { dialog.open({ id : "totalInfoMainDialog", @@ -771,13 +856,56 @@ $(document).ready(function(){ }); } + $P.showPhoto = (dataKey, nextDataKey, curDataVhrno, nextDataVhrno) => { + + if(dataKey == ""){ + $("#curDataVhrno--${pageName}").html(""); + $("#nextDataVhrno--${pageName}").html(""); + $("#curDataFiles--${pageName}").html(""); + $("#nextDataFiles--${pageName}").html(""); + return; + } + + $("#curDataVhrno--${pageName}").html(curDataVhrno); + $("#nextDataVhrno--${pageName}").html(nextDataVhrno); + + ajax.get({ + url:"file/list.do", + data: { + infoType : "100", + infoKeys : [dataKey, nextDataKey], + fetchSize : 0 + }, + success : (resp) => { + + var fileList = resp.fileList; + + var currentDataFileList = fileList.filter(x => x.INF_KEY == dataKey); + var nextDataFileList = fileList.filter(x => x.INF_KEY == nextDataKey); + + $("#curDataFiles--${pageName}").html(""); + $("#nextDataFiles--${pageName}").html(""); + + currentDataFileList.forEach(function(item, index, array){ + var output = fnMakeImgTagForInspection(item.URL, item.FILE_NM,"cur"+item.FILE_ID+'${pageName}',item.MOSAIC); + $("#curDataFiles--${pageName}").append(output); + }); + nextDataFileList.forEach(function(item, index, array){ + var output = fnMakeImgTagForInspection(item.URL, item.FILE_NM,"next"+item.FILE_ID+'${pageName}',item.MOSAIC); + $("#nextDataFiles--${pageName}").append(output); + }); + + } + }); + } + $P.openLevyExclPop = (levyExclSeCd) => { var info = ""; if ($P.currentDisplay == "photoInspection") { info = $P.photoInspectionControl.dataset.getCurrent("item"); } else if ($P.currentDisplay == "sameVehicleInspection") { - info = $P.sameVehicleControl.sub.dataset.getCurrent("item"); + info = $P.sameVehicleSubControl.dataset.getCurrent("item"); } else { return; } @@ -798,7 +926,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url(taskSeCd + "/excl/excl01/020/info.do"), data : params, - success : resp => { + success : (resp) => { if((typeof resp) != "string"){ dialog.alert({ @@ -844,7 +972,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/PVS/crdn/crdn02/050/info.do"), data : params, - success : resp => { + success : (resp) => { if((typeof resp) != "string"){ dialog.alert({ @@ -874,81 +1002,6 @@ $(document).ready(function(){ } } - $P.renderInspectionDataList = (total, renderDataType) => { - - switch (renderDataType) { - case "photoInspection": - var DS = $P.photoInspectionControl.dataset; - var empty = DS.empty; - var notFound = [document.getElementById("photoInspectionNotFound--${pageName}").innerHTML] - var found = document.getElementById("photoInspectionRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','photoInspection');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','photoInspection');"); - - var trs = empty ? notFound : DS.inStrings(found, replacer); - var noMore = (total == DS.length); - var initScroll = ($P.photoInspectionControl.query.pageNum < 2) && ($P.photoInspectionControl.untilPageNum == 0); - - $("#photoInspection-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - if($P.photoInspectionControl.untilPageNum != 0){ - $P.photoInspectionControl.query.fetchSize = $P.photoInspectionControl.defaultFetchSize; - $P.photoInspectionControl.query.pageNum = $P.photoInspectionControl.untilPageNum; - $P.photoInspectionControl.untilPageNum = 0; - } - break; - case "sameVehicleInspectionMain": - var DS = $P.sameVehicleControl.main.dataset; - var empty = DS.empty; - var notFound = [document.getElementById("sameVehicleInspectionMainNotFound--${pageName}").innerHTML]; - var found = document.getElementById("sameVehicleInspectionMainRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID_LIST") + "','sameVehicleInspectionMain');"); - - var trs = empty ? notFound : DS.inStrings(found, replacer); - var noMore = (total == DS.length); - var initScroll = ($P.sameVehicleControl.main.query.pageNum < 2) && ($P.sameVehicleControl.untilPageNum == 0); - - $("#sameVehicleInspectionMain-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - - if($P.sameVehicleControl.untilPageNum != 0){ - $P.sameVehicleControl.main.query.fetchSize = $P.sameVehicleControl.defaultFetchSize; - $P.sameVehicleControl.main.query.pageNum = $P.sameVehicleControl.untilPageNum; - $P.sameVehicleControl.untilPageNum = 0; - } - break; - case "sameVehicleInspectionSub": - var DS = $P.sameVehicleControl.sub.dataset; - var empty = DS.empty; - var notFound = [document.getElementById("sameVehicleInspectionSubNotFound--${pageName}").innerHTML] - var found = document.getElementById("sameVehicleInspectionSubRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','sameVehicleInspectionSub');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickInspectionDataList('" + dataItem.getValue("CRDN_ID") + "','sameVehicleInspectionSub');"); - var trs = empty ? notFound : DS.inStrings(found, replacer); - $("#sameVehicleInspectionSubTbody--${pageName}").html(trs.join()); - break; - default: break; - } - - //보안모드 - fn_securityModeToggle($("#securityMode--top").is(":checked")); - } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - - if($P.currentDisplay == "photoInspection"){ - data.fetchSize = $P.photoInspectionControl.defaultFetchSize; - } else if($P.currentDisplay == "sameVehicleInspection"){ - data.fetchSize = $P.sameVehicleControl.defaultFetchSize; - } - - return data; - } /************************************************************************** * element.on @@ -974,48 +1027,7 @@ $(document).ready(function(){ }); $('#btnSearch--${pageName}').on('click', () => $P.searchInspectionList()); //검색버튼 - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.currentDisplay == "photoInspection"){ - if($P.photoInspectionControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#photoInspection_Table_0--${pageName} thead th").not(".dummy-th").not(":eq(0)"), - $($("#photoInspectionRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); - $P.photoInspectionControl.query.cellDefs = cellDefs; - - $P.photoInspectionControl.download(); - - } else { - - if($P.sameVehicleControl.main.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - if(confirm("단속건수 엑셀저장은 확인버튼, 상세내역 엑셀저장시 취소버튼을 누르세요.")){ - - var cellDefs = getCellDefs($("#sameVehicleInspectionMain_Table_0--${pageName} thead th").not(".dummy-th"), - $($("#sameVehicleInspectionMainRow--${pageName}")[0].content).find("td").not(".dummy-td")); - $P.sameVehicleControl.main.query.cellDefs = cellDefs; - - $P.sameVehicleControl.main.download(); - } else { - - var cellDefs = getCellDefs($("#sameVehicleInspectionSub_Table_0--${pageName} thead th").not(".dummy-th").not(":hidden"), - $($("#sameVehicleInspectionSubRow--${pageName}")[0].content).find("td").not(".dummy-td").not(".privacy-mask")); - $P.sameVehicleControl.sub.query.cellDefs = cellDefs; - - $P.sameVehicleControl.sub.download(); - } - - } - - - - }); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown()); $("#btnInstLevyExcl--${pageName}").on("click", () => $P.openLevyExclPop("1")); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02050-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02050-info.jsp index eb8f533a..fd43bafa 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02050-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn02050-info.jsp @@ -48,45 +48,24 @@ $(document).ready(function(){ $P.formFields = new FimsFormFields("#frmEdit--${pageName}"); $P.crdnControl = new DatasetControl({ - urls : { update : wctx.url("/PVS/crdn/crdn02/050/update.do") }, + urls : { + update : wctx.url("/PVS/crdn/crdn02/050/update.do") + }, keymapper : info => info ? info.CRDN_ID : "", dataGetter : obj => obj.crdnInfo, formats: {} }); - $P.crdnControl.save = (info) => { - if (!info) return; - ajax.post({ - url : $P.crdnControl.urls.update, - data : info, - success : resp => { $P.crdnControl.onSave(resp); } - }); - }; /************************************************************************** - * DatasetControl.on, Dataset.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onCurrentChange = (DI) => { - $P.formFields.set(DI); + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + $P.formFields.set(dataItem); } - $P.crdnControl.onSave = (resp) => { - if (resp.saved) { - dialog.alert({ - content : "저장됐습니다.", - init : function(){ - setDialogZindex(); - focusClose(); - } - }); - dialog.close("overTimeProcessDialog--${openerPageName}"); - - if ("${savedCallbackFuncName}" != "") { - ${savedCallbackFuncName}(resp.saved); - } - } - }; + /************************************************************************** * pageObject.function **************************************************************************/ @@ -121,7 +100,19 @@ $(document).ready(function(){ } if(confirm(alertMessage)){ - $P.crdnControl.save($P.formFields.get()); + var info = $P.formFields.get(); + if (!info) { + return; + } + + ajax.post({ + url : $P.crdnControl.urls.update, + data : info, + success : (resp) => { + $P.saveCallback(resp); + } + }); + } } @@ -141,10 +132,33 @@ $(document).ready(function(){ if(confirm("원금 복원하시겠습니까?")){ var info = $P.formFields.get(); info.chgAmtSe = "0"; - $P.crdnControl.save(info); + + ajax.post({ + url : $P.crdnControl.urls.update, + data : info, + success : (resp) => { + $P.saveCallback(resp); + } + }); } } + $P.saveCallback = (resp) => { + if (resp.saved) { + dialog.alert({ + content : "저장됐습니다.", + init : function(){ + setDialogZindex(); + focusClose(); + } + }); + dialog.close("overTimeProcessDialog--${openerPageName}"); + + if ("${savedCallbackFuncName}" != "") { + ${savedCallbackFuncName}(resp.saved); + } + } + }; /************************************************************************** * element.on **************************************************************************/ diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp index 3d2b3ece..883d4f70 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp @@ -158,48 +158,50 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { - - $P.renderCrdnList(obj["Total"]); - - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.crdnControl.tableRenderComplete = true; + $P.crdnControl.dataset.onDatasetChange = (obj) => { + + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); + + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); }; - $P.crdnControl.onCurrentChange = (DI) => { - - if(!$P.crdnControl.tableRenderComplete){ - return; - } - - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); - } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); }; /************************************************************************** * pageObject.function **************************************************************************/ - $P.refreshCrdnList = () => { - $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; - $P.crdnControl.load(1); + $P.fnReset = () => { + var searchForm = $("#frmSearch--${pageName}"); + searchForm.find("input[type='radio']").not("[name='taskSeCd']").prop("checked", false); + searchForm.find("input[type='checkbox']").prop("checked", false); + searchForm.find("input[type='text']").val(""); + searchForm.find("input[type='hidden']").val(""); + searchForm.find("select").each(function(){ $(this).find("option:eq(0)").prop("selected", true); }); + + $("#byOutput--${pageName}").val("동적 검색"); + $('#schCrdnYmdFrom--${pageName}').datepicker('setDate', DateUtil.getDateDay(-5475).date); + $('#schCrdnYmdTo--${pageName}').datepicker('setDate', new Date()); + $P.crdnControl.setData([]); } + + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.taskSeCd = "DPV"; + data.fetchSize = $P.crdnControl.defaultFetchSize; - $P.searchCrdnList = () => { + return data; + } + + $P.searchCrdnList = () => { $P.crdnControl.query = $P.getParams(); $P.crdnControl.load(1); } @@ -207,56 +209,82 @@ $(document).ready(function(){ $P.scrollCrdnList = () => { $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } - - $P.clickCrdnList = (dataKey, auto) => { - if(dataKey == ""){ - return; - } - - $("#crdnTbody--${pageName}").setCurrentRow(dataKey); - - if(!auto){ - $P.crdnControl.setCurrent(dataKey); - } - } - - $P.dblclickCrdnList = (dataKey) => { - let params = { - callControlName : "pageObject['${pageName}'].crdnControl" - , crdnId : dataKey - } - - ajax.get({ - url : $P.crdnControl.urls.getInfo, - data : params, - success : resp => { - - dialog.open({ - id : "totalInfoMainDialog", - title : "개별총정보", size : "xxl", content : resp, - init : () => {} - }); - + + $P.refreshCrdnList = () => { + $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; + + Apply.fromDatasetControl.load($P.crdnControl, 1).then((resp)=>{ + Apply.toDataset.set($P.crdnControl.dataset, resp); + $P.crdnControl.dataset.onDatasetChange(resp); + + if($P.crdnControl.untilPageNum != 0){ + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize; + $P.crdnControl.query.pageNum = $P.crdnControl.untilPageNum; + $P.crdnControl.untilPageNum = 0; + } + + if($P.crdnControl.beforeCurrent != null){ + var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; + var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; + $P.crdnControl.beforeCurrent = null; + + if(!$P.crdnControl.dataset.empty){ + var info = $P.crdnControl.dataset.getData(beforeCurrentKey); + + if(info != null){ + $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); + } else { + + if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ + info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; + } else { + info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; + } + + $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); + } + } } + }); - } + + $P.fnExcelDown = () => { - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + var cellDefs = getCellDefs($("#crdnTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)"), + $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); + $P.crdnControl.query.cellDefs = cellDefs; + + $P.crdnControl.download(); + } + + $P.getGridTemplate = () => { + var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; var found = document.getElementById("crdnRow--${pageName}").innerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { - var trs = empty ? notFound : crdnDS.inStrings(found,replacer); - var noMore = (total == crdnDS.length); + var noMore = (total == listLength); var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); //보안모드 fn_securityModeToggle($("#securityMode--top").is(":checked")); @@ -268,53 +296,39 @@ $(document).ready(function(){ $P.crdnControl.untilPageNum = 0; } } + + $P.clickCrdnList = (dataKey) => { + if(dataKey == ""){ + return; + } - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.taskSeCd = "DPV"; - data.fetchSize = $P.crdnControl.defaultFetchSize; + $("#crdnTbody--${pageName}").setCurrentRow(dataKey); + Apply.toDataset.current($P.crdnControl.dataset, dataKey); - return data; } - $P.fnReset = () => { - var searchForm = $("#frmSearch--${pageName}"); - searchForm.find("input[type='radio']").not("[name='taskSeCd']").prop("checked", false); - searchForm.find("input[type='checkbox']").prop("checked", false); - searchForm.find("input[type='text']").val(""); - searchForm.find("input[type='hidden']").val(""); - searchForm.find("select").each(function(){ $(this).find("option:eq(0)").prop("selected", true); }); + $P.dblclickCrdnList = (dataKey) => { + let params = { + callControlName : "pageObject['${pageName}'].crdnControl" + , crdnId : dataKey + } - $("#byOutput--${pageName}").val("동적 검색"); - $('#schCrdnYmdFrom--${pageName}').datepicker('setDate', DateUtil.getDateDay(-5475).date); - $('#schCrdnYmdTo--${pageName}').datepicker('setDate', new Date()); - $P.crdnControl.setData([]); - } + ajax.get({ + url : $P.crdnControl.urls.getInfo, + data : params, + success : (resp) => { - /************************************************************************** - * element.on - **************************************************************************/ - $('#btnReset--${pageName}').on('click', () => $P.fnReset()); - $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.crdnControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#crdnTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)"), - $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); - $P.crdnControl.query.cellDefs = cellDefs; - - $P.crdnControl.download(); - }); - - fnMakeResizableTable($("#table-responsive--${pageName}")[0]); - fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollCrdnList); - - $('#btnUpdateToConfirmData--${pageName}').on('click', () => { + dialog.open({ + id : "totalInfoMainDialog", + title : "개별총정보", size : "xxl", content : resp, + init : () => {} + }); + + } + }); + + } + $P.save = () => { if(!$P.crdnControl.getCurrent()) { dialog.alert({ @@ -329,13 +343,43 @@ $(document).ready(function(){ dialog.alert({ content : "현 자료를 장애차량 확인된 자료로 변경하시겠습니까?", init : function(){ - focusOK(); + focusOK(); }, - onOK:() => { - $P.crdnControl.save({ 'crdnId' : $P.crdnControl.getCurrent()["CRDN_ID"] }); + onOK : () => { + var info = { 'crdnId' : $P.crdnControl.getCurrent()["CRDN_ID"] }; + ajax.post({ + url : $P.crdnControl.urls.update, + data : info, + success : (resp) => { + $P.saveCallback(resp); + } + }); } }); - }); + } + + $P.saveCallback = (resp) => { + if (resp.saved) { + dialog.alert({ + content : "저장됐습니다.", + onClose : () => { + $P.refreshCrdnList(); + } + }); + } + } + + /************************************************************************** + * element.on + **************************************************************************/ + $('#btnReset--${pageName}').on('click', () => $P.fnReset()); + $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown()); + + fnMakeResizableTable($("#table-responsive--${pageName}")[0]); + fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollCrdnList); + + $('#btnUpdateToConfirmData--${pageName}').on('click', () => $P.save()); /************************************************************************** * 초기화 diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05010-main.jsp index 5d198998..4c0a3aec 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05010-main.jsp @@ -135,7 +135,6 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; $P.crdnControl.urls.newInfoByFile = ""; $P.crdnControl.urls.newInfoByHand = ""; @@ -156,8 +155,8 @@ $(document).ready(function(){ ajax.get({ url : url, - data: {}, - success:resp => { + data : {}, + success : (resp) => { dialog.open({ id: dialogId, title: title, @@ -170,34 +169,19 @@ $(document).ready(function(){ }; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { - - $P.renderCrdnList(obj["Total"]); + $P.crdnControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.crdnControl.tableRenderComplete = true; + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); }; - $P.crdnControl.onCurrentChange = (DI) => { - - if(!$P.crdnControl.tableRenderComplete){ - return; - } - - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); - } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); } /************************************************************************** @@ -229,12 +213,13 @@ $(document).ready(function(){ } } - $P.refreshCrdnList = () => { - $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; - $P.crdnControl.load(1); - } - + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.crdnControl.defaultFetchSize; + return data; + } + $P.searchCrdnList = () => { $P.crdnControl.query = $P.getParams(); $P.crdnControl.load(1); @@ -243,33 +228,34 @@ $(document).ready(function(){ $P.scrollCrdnList = () => { $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } + + $P.refreshCrdnList = () => { + $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; + $P.crdnControl.load(1); + } + - $P.clickCrdnList = (dataKey, auto) => { - if(dataKey == ""){ - return; - } - $("#crdnTbody--${pageName}").setCurrentRow(dataKey); - - if(!auto) { - $P.crdnControl.setCurrent(dataKey); - } - } - - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; + $P.getGridTemplate = () => { var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; var found = document.getElementById("crdnRow--${pageName}").innerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, ""); - var trs = empty ? notFound : crdnDS.inStrings(found,replacer); - var noMore = (total == crdnDS.length); + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { + + var noMore = (total == listLength); var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); //보안모드 fn_securityModeToggle($("#securityMode--top").is(":checked")); @@ -281,13 +267,16 @@ $(document).ready(function(){ } } - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.crdnControl.defaultFetchSize; - return data; - } + $P.clickCrdnList = (dataKey) => { + if(dataKey == ""){ + return; + } + $("#crdnTbody--${pageName}").setCurrentRow(dataKey); + $P.crdnControl.setCurrent(dataKey); + Apply.toDataset.current($P.crdnControl.dataset, dataKey); + } + /************************************************************************** * element.on **************************************************************************/ diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp index ec7fdb3b..d748474a 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp @@ -189,38 +189,36 @@ $(document).ready(function(){ }); /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.parsedInfoControl.onDatasetChange = (obj) => { + $P.parsedInfoControl.dataset.onDatasetChange = (obj) => { - $P.renderParsedInfoList(obj["Total"]); + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.parsedInfoControl.dataset, t.found, t.notFound, t.replacer); + $P.renderParsedInfoList(obj["Total"], $P.parsedInfoControl.dataset.length, trs); - $("#parsedInfoPaging--${pageName}").setPagingInfo({ - list : $P.parsedInfoControl.dataset, - prefix : "parsedInfoPaging--${pageName}", - totalSize : obj["Total"] - }); + Apply.fromDataset.paging($P.parsedInfoControl.dataset, obj, "parsedInfoPaging--${pageName}"); }; - $P.parsedInfoControl.onCurrentChange = (DI) => { + $P.parsedInfoControl.dataset.onCurrentChange = (dataItem) => { $("#imageArea--${pageName}").html(""); - if(DI && DI.data){ - var dataKey = DI.data.FILE_NAME; + if(dataItem && dataItem.data){ + var dataKey = dataItem.data.FILE_NAME; $("#table-responsive--${pageName}").find("tbody").setCurrentRow(dataKey); - if(DI.data.FILE_GROUP_TYPE == "BIN"){ + if(dataItem.data.FILE_GROUP_TYPE == "BIN"){ var srcArr = []; - for(var i=1; i <= DI.data.PHOTO_CNT; i++){ - srcArr.push("data:image/jpg;base64," + DI.data["B64IMAGE"+i]) + for(var i=1; i <= dataItem.data.PHOTO_CNT; i++){ + srcArr.push("data:image/jpg;base64," + dataItem.data["B64IMAGE"+i]) } $P.renderImage(srcArr); } else { if(!dataKey.endsWith(".txt") && !dataKey.endsWith(".TXT")){ - var src = DI.data.FILE_PATH; + var src = dataItem.data.FILE_PATH; $P.renderImage(src); } } @@ -313,21 +311,24 @@ $(document).ready(function(){ }); } + $P.getGridTemplate = () => { + var notFound = [$("#table-responsive--${pageName}").find("template.notFound")[0].innerHTML]; + var found = $("#table-responsive--${pageName}").find("template.found")[0].innerHTML; + var replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickParsedInfoList('" + dataItem.getValue("FILE_NAME") + "');"); + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } //테이블 렌더링 - $P.renderParsedInfoList = (total) => { - - var parsedInfoDS = $P.parsedInfoControl.dataset; - var empty = parsedInfoDS.empty; - var notFound = [$("#table-responsive--${pageName}").find("template.notFound")[0].innerHTML]; - var found = $("#table-responsive--${pageName}").find("template.found")[0].innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickParsedInfoList('" + dataItem.getValue("FILE_NAME") + "');"); + $P.renderParsedInfoList = (total, listLength, trs) => { - var trs = empty ? notFound : parsedInfoDS.inStrings(found,replacer); - - $("#table-responsive--${pageName}").find("tbody").html(trs.join()); + $("#table-responsive--${pageName}").find("tbody").html(trs); - if(!empty){ + if(listLength != 0){ fnDownsizeCheck($("#table-responsive--${pageName}").find("table")[0]); } 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 a110dd8c..450ca1ec 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 @@ -1,6 +1,6 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%> <%@ include file="/WEB-INF/jsp/include/taglib.jsp"%> - +단속자료 수기 등록
@@ -382,7 +382,10 @@ $(document).ready(function(){ $P.uploadSet = uploadSupport("#inputUploadSet--${pageName}"); $P.crdnControl = new DatasetControl({ - urls : { load : "", create : wctx.url("/${taskSeCd}/crdn/crdn05/030/create.do") }, + urls : { + load : "", + create : wctx.url("/${taskSeCd}/crdn/crdn05/030/create.do") + }, keymapper : info => info ? info.CRDN_ID : "", dataGetter : obj => obj["List"], appendData : true, formats: { @@ -390,37 +393,8 @@ $(document).ready(function(){ } }); - - $P.crdnControl.save = (info) => { - if (!info) return; - var item = $P.crdnControl.getCurrent("item"), - create = "added" == item.state; - - var formData = new FormData(document.getElementById("frmFile--${pageName}")); - for(var key in info) { - var value = info[key]; - formData.append(key,value); - } - - formData.delete("newFileList"); - - if($P.localUploadArr.length > 0){ - $P.localUploadArr.forEach(item => formData.append("newFileList",item)); - } - - if($P.captureFileArr.length > 0){ - $P.captureFileArr.forEach(item => formData.append("newFileList",item)); - } - - ajax.post({ - url:!create ? $P.crdnControl.urls.update : $P.crdnControl.urls.create, - data: formData, contentType : false, processData : false, - success:resp => $P.crdnControl.onSave(resp) - }); - }; - /************************************************************************** - * DatasetControl.on, Dataset.on + * Dataset.on **************************************************************************/ $P.uploadSet.onDatasetChange = () => { var files = $P.uploadSet.getDataset(); @@ -430,18 +404,6 @@ $(document).ready(function(){ }; $P.uploadSet.onRemove = () => { }; - $P.crdnControl.onSave = (resp) => { - if (resp.saved) { - dialog.alert({ - content : "저장됐습니다.", - init : function(){ - setDialogZindex(); - focusClose(); - } - }); - dialog.close("manualdialog"); - } - }; /************************************************************************** * pageObject.function **************************************************************************/ @@ -494,11 +456,52 @@ $(document).ready(function(){ } if(confirm("현재 단속 정보를 저장하시겠습니까?")){ - $P.crdnControl.save($P.formFields.get()); + var info = $P.formFields.get(); + + if (!info) { + return; + } + + var formData = new FormData(document.getElementById("frmFile--${pageName}")); + for(var key in info) { + var value = info[key]; + formData.append(key,value); + } + + formData.delete("newFileList"); + + if($P.localUploadArr.length > 0){ + $P.localUploadArr.forEach(item => formData.append("newFileList",item)); + } + + if($P.captureFileArr.length > 0){ + $P.captureFileArr.forEach(item => formData.append("newFileList",item)); + } + + ajax.post({ + url : $P.crdnControl.urls.create, + data : formData, contentType : false, processData : false, + success : (resp) => { + $P.saveCallback(resp); + } + }); } }; + $P.saveCallback = (resp) => { + if (resp.saved) { + dialog.alert({ + content : "저장됐습니다.", + init : function(){ + setDialogZindex(); + focusClose(); + } + }); + dialog.close("manualdialog"); + } + } + $P.videoCallback = (snapshots) => { snapshots.forEach(function(canvas, index, array){ canvas.toBlob(function(blob){ @@ -592,7 +595,7 @@ $(document).ready(function(){ vhrno : vhrno, levy_stdde : crdnYmd }, - success:resp => { + success : (resp) => { if(!resp.found){ dialog.alert({ content : "차량정보가 없습니다.", @@ -673,7 +676,7 @@ $(document).ready(function(){ ajax.get({ url: wctx.url("/${taskSeCd}/crdn/crdn07/010/info.do"), data: { "teamId" : this.value}, - success:resp => { + success : (resp) => { if(resp.teamInfo != null){ var teamInfo = resp.teamInfo; $("#teamer1--${pageName}").val(teamInfo.TEAMER_1); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn06010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn06010-main.jsp index a64cf89e..1ac0243f 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn06010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn06010-main.jsp @@ -176,7 +176,7 @@ No. + onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);" /> 자료출처 @@ -207,7 +207,7 @@ {ROW_NUM} + onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);"> {CRDN_INPT_SE_CD} {VHRNO} @@ -314,49 +314,25 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { - - $P.renderCrdnList(obj["Total"]); - - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.crdnControl.tableRenderComplete = true; - }; - - $P.crdnControl.onCurrentChange = (DI) => { + $P.crdnControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); - if(!$P.crdnControl.tableRenderComplete){ - return; - } + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); + }; - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); - } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); } - $P.crdnControl.onSelectionChange = (selectedArr) => { - - var crdnDS = $P.crdnControl.dataset; - var keys = selectedArr.map(item => crdnDS.getKey(item)); - - $("#crdnTbody--${pageName} input[type='checkbox']").each(function() { - var checkbox = $(this); - checkbox.prop("checked", keys.includes(checkbox.val())); - }); - - $("#btnSendCrdn--${pageName}").prop("disabled", keys.length < 1); + $P.crdnControl.dataset.onSelectionChange = (selectedArr) => { + Apply.fromDataset.gridCheckbox($P.crdnControl.dataset, document.getElementById("crdnTbody--${pageName}"), 1, selectedArr); + Apply.fromDataset.gridButton($P.crdnControl.dataset, $("#btnSendCrdn--${pageName}")[0], selectedArr); }; /************************************************************************** @@ -375,7 +351,7 @@ $(document).ready(function(){ $('#schCrdnYmdTo--${pageName}').datepicker('setDate', new Date()); $P.crdnControl.setData([]); } - + $P.fnResetAndChangeBiz = (taskSeCd) => { $P.fnReset(); $P.crdnControl.urls.load = wctx.url("/"+taskSeCd+"/crdn/crdn06/010/list.do"); @@ -407,12 +383,14 @@ $(document).ready(function(){ } } - $P.refreshCrdnList = () => { - $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; - $P.crdnControl.load(1); - } + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.crdnControl.defaultFetchSize; + return data; + } + $P.searchCrdnList = () => { $P.crdnControl.query = $P.getParams(); $P.crdnControl.load(1); @@ -422,65 +400,70 @@ $(document).ready(function(){ $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } - $P.clickCrdnList = (dataKey, auto) => { - if(dataKey == ""){ - return; - } - - $("#crdnTbody--${pageName}").setCurrentRow(dataKey); + $P.refreshCrdnList = () => { + $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; + $P.crdnControl.load(1); + } + + $P.fnExcelDown = (forApproval) => { + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } - if(!auto){ - $P.crdnControl.setCurrent(dataKey); + var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)").not(":eq(0)"), + $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(":eq(0)")); + $P.crdnControl.query.cellDefs = cellDefs; + + if(forApproval){ + $P.crdnControl.query.includePhoto = "Y"; + } else { + $P.crdnControl.query.includePhoto = "N"; } + + $P.crdnControl.download(); + + $P.crdnControl.query.includePhoto = null; + }; + + $P.checkCrdnList = (element, bool) => { + Grid.checkbox.sync(element, bool); + + var atLeastOne = Grid.checkbox.countChecked(element) > 0; + $("#btnSendCrdn--${pageName}").prop("disabled", !atLeastOne); + + Apply.toDataset.selection($P.crdnControl.dataset, element, bool); } - $P.dblclickCrdnList = (dataKey) => { - var params = { - callControlName : "pageObject['${pageName}'].crdnControl", - crdnId : dataKey - }; - - ajax.get({ - url : $P.crdnControl.urls.getInfo, - data : params, - success : resp => { - - dialog.open({ - id : "totalInfoMainDialog", - title : "개별총정보", size : "xxl", content : resp, - init : () => {} - }); - - } - }); - - } - - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; + $P.getGridTemplate = () => { var clsForTask = $("#frmSearch--${pageName} [name='taskSeCd']:checked").val().toLowerCase(); var notFound = [document.getElementById("crdnNotFound--${pageName}").content.querySelector("."+clsForTask+",.cmn").outerHTML]; var foundContent = document.getElementById("crdnRow--${pageName}").content; var foundTr = $(foundContent).find("tr")[0].cloneNode(false); var foundTds = $(foundContent).find("."+clsForTask+",.cmn"); - foundTds.each(function(){ foundTr.appendChild(this.cloneNode(true)); }); - var found = foundTr.outerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); - var trs = empty ? notFound : crdnDS.inStrings(found, replacer); - var noMore = (total == crdnDS.length); + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { + + var noMore = (total == listLength); var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); fn_securityModeToggle($("#securityMode--top").is(":checked")); //보안모드 @@ -490,15 +473,38 @@ $(document).ready(function(){ $P.crdnControl.untilPageNum = 0; } } + + $P.clickCrdnList = (dataKey) => { + if(dataKey == ""){ + return; + } - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.crdnControl.defaultFetchSize; - - return data; + $("#crdnTbody--${pageName}").setCurrentRow(dataKey); + Apply.toDataset.current($P.crdnControl.dataset, dataKey); } + $P.dblclickCrdnList = (dataKey) => { + var params = { + callControlName : "pageObject['${pageName}'].crdnControl", + crdnId : dataKey + }; + + ajax.get({ + url : $P.crdnControl.urls.getInfo, + data : params, + success : (resp) => { + + dialog.open({ + id : "totalInfoMainDialog", + title : "개별총정보", size : "xxl", content : resp, + init : () => {} + }); + + } + }); + + } + $P.fnSendCrdn = () => { var datas = $P.crdnControl.dataset.getDataset("selected"); var taskSeCd = datas[0].TASK_SE_CD; @@ -508,7 +514,7 @@ $(document).ready(function(){ ajax.post({ url : wctx.url("/"+taskSeCd+"/crdn/crdn06/010/sendCrdn.do"), data : { "crdnIDs" : keys.join(",") }, - success : resp => { + success : (resp) => { if(resp.saved){ dialog.alert({ content : "처리되었습니다.", @@ -526,26 +532,7 @@ $(document).ready(function(){ } }); } - $P.fnExcelDown = (forApproval) => { - if($P.crdnControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)").not(":eq(0)"), - $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(":eq(0)")); - $P.crdnControl.query.cellDefs = cellDefs; - - if(forApproval){ - $P.crdnControl.query.includePhoto = "Y"; - } else { - $P.crdnControl.query.includePhoto = "N"; - } - - $P.crdnControl.download(); - - $P.crdnControl.query.includePhoto = null; - }; + /************************************************************************** * element.on diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn07010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn07010-main.jsp index 8acdaa0c..bd8e545a 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn07010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn07010-main.jsp @@ -288,22 +288,27 @@ $(document).ready(function(){ }); /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.useTeamControl.onDatasetChange = (obj) => { + $P.useTeamControl.dataset.onDatasetChange = (obj) => { - $P.renderUseTeamList(obj["Total"]); + var t = $P.getGridTemplate("useTeam"); + var trs = Apply.fromDataset.getTbody($P.useTeamControl.dataset, t.found, t.notFound, t.replacer); + $P.renderUseTeamList(obj["Total"], $P.useTeamControl.dataset.length, trs); - $("#useTeamPaging--${pageName}").setPagingInfo({ - list : $P.useTeamControl.dataset, - prefix : "useTeamPaging--${pageName}", - totalSize : obj["Total"] - }); + Apply.fromDataset.paging($P.useTeamControl.dataset, obj, "useTeamPaging--${pageName}"); + }; + + $P.delTeamControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate("delTeam"); + var trs = Apply.fromDataset.getTbody($P.delTeamControl.dataset, t.found, t.notFound, t.replacer); + $P.renderDelTeamList(obj["Total"], $P.delTeamControl.dataset.length, trs); + }; - - $P.useTeamControl.onCurrentChange = (DI) => { - if(!DI){ + + $P.useTeamControl.dataset.onCurrentChange = (dataItem) => { + if(!dataItem){ $("#teamNm--${pageName}").val(""); $("#crdnSeCd--${pageName}").val(""); $("#teamer1--${pageName}").val(""); @@ -314,35 +319,20 @@ $(document).ready(function(){ return; } - $("#useTeamTbody--${pageName}").setCurrentRow(DI.data.TEAM_ID); - - $("#teamNm--${pageName}").val(DI.data.TEAM_NM); - $("#crdnSeCd--${pageName}").val(DI.data.CRDN_SE_CD); - $("#teamer1--${pageName}").val(DI.data.TEAMER_1); - $("#teamer2--${pageName}").val(DI.data.TEAMER_2); - $("#teamer3--${pageName}").val(DI.data.TEAMER_3); - $("#teamer4--${pageName}").val(DI.data.TEAMER_4); - $("#etcCn--${pageName}").val(DI.data.ETC_CN); + Apply.fromDataset.currentRow($P.useTeamControl.dataset, dataItem, $("#useTeamTbody--${pageName}")[0]); + + $("#teamNm--${pageName}").val(dataItem.data.TEAM_NM); + $("#crdnSeCd--${pageName}").val(dataItem.data.CRDN_SE_CD); + $("#teamer1--${pageName}").val(dataItem.data.TEAMER_1); + $("#teamer2--${pageName}").val(dataItem.data.TEAMER_2); + $("#teamer3--${pageName}").val(dataItem.data.TEAMER_3); + $("#teamer4--${pageName}").val(dataItem.data.TEAMER_4); + $("#etcCn--${pageName}").val(dataItem.data.ETC_CN); - $("#deletedTeamNm--${pageName}").val(DI.data.TEAM_NM); + $("#deletedTeamNm--${pageName}").val(dataItem.data.TEAM_NM); } - - $P.delTeamControl.onDatasetChange = (obj) => { - - var delTeamDS = $P.delTeamControl.dataset; - var empty = delTeamDS.empty; - var notFound = [document.getElementById("delTeamNotFound--${pageName}").innerHTML]; - var found = document.getElementById("delTeamRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "") - .replace(/{ondblclick}/gi, ""); - - var trs = empty ? notFound : delTeamDS.inStrings(found,replacer); - $("#delTeamTbody--${pageName}").html(trs.join()); - }; - /************************************************************************** * pageObject.function **************************************************************************/ @@ -369,43 +359,63 @@ $(document).ready(function(){ $P.useTeamControl.urls.save = wctx.url("/"+taskSeCd+"/crdn/crdn07/010/save.do"); } - $P.refreshUseTeamList = () => { + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + + return data; + } + + + $P.searchUseTeamList = () => { + $P.useTeamControl.query = $P.getParams(); + $P.useTeamControl.load(1); + } + + $P.refreshUseTeamList = () => { if($P.useTeamControl.query.pageNum == null){ $P.useTeamControl.query.pageNum = 1; } $P.useTeamControl.load(1); } - - $P.searchUseTeamList = () => { - $P.useTeamControl.query = $P.getParams(); - $P.useTeamControl.load(1); + + $P.getGridTemplate = (gridType) => { + var found; + var notFound; + var replacer; + + if(gridType == "useTeam"){ + notFound = [document.getElementById("useTeamNotFound--${pageName}").innerHTML]; + found = document.getElementById("useTeamRow--${pageName}").innerHTML; + replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickUseTeamList('" + dataItem.getValue("TEAM_ID") + "');") + .replace(/{ondblclick}/gi, ""); + } else { + notFound = [document.getElementById("delTeamNotFound--${pageName}").innerHTML]; + found = document.getElementById("delTeamRow--${pageName}").innerHTML; + replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "") + .replace(/{ondblclick}/gi, ""); + } + + return { + found : found, + notFound : notFound, + replacer : replacer + }; } - - $P.clickUseTeamList = (dataKey) => { - $P.useTeamControl.setCurrent(dataKey); + + $P.renderUseTeamList = (total, listLength, trs) => { + $("#useTeamTbody--${pageName}").html(trs); } - $P.renderUseTeamList = (total) => { - - var useTeamDS = $P.useTeamControl.dataset; - var empty = useTeamDS.empty; - var notFound = [document.getElementById("useTeamNotFound--${pageName}").innerHTML]; - var found = document.getElementById("useTeamRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickUseTeamList('" + dataItem.getValue("TEAM_ID") + "');") - .replace(/{ondblclick}/gi, ""); - - var trs = empty ? notFound : useTeamDS.inStrings(found,replacer); - - $("#useTeamTbody--${pageName}").html(trs.join()); + $P.renderDelTeamList = (total, listLength, trs) => { + $("#delTeamTbody--${pageName}").html(trs); } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - - return data; + + $P.clickUseTeamList = (dataKey) => { + $P.useTeamControl.setCurrent(dataKey); } $P.fnSave = () => { @@ -417,7 +427,7 @@ $(document).ready(function(){ ajax.get({ url : $P.useTeamControl.urls.save, data : data, - success : resp => { + success : (resp) => { if(resp.saved){ $P.refreshUseTeamList(); } @@ -432,7 +442,7 @@ $(document).ready(function(){ data : { "teamId" : dataKey }, - success : resp => { + success : (resp) => { if(resp.saved){ $P.refreshUseTeamList(); } @@ -452,7 +462,7 @@ $(document).ready(function(){ "teamNm" : teamNm, "taskSeCd" : taskSeCd }, - success:resp => { + success:(resp) => { $P.delTeamControl.setData(resp); } diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08010-main.jsp index 5f6d03e1..c8cdeb88 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08010-main.jsp @@ -179,14 +179,12 @@ $(document).ready(function(){ $P.exmptnVhclControl.defaultFetchSize = FETCH_XS; $P.exmptnVhclControl.untilPageNum = 0; $P.exmptnVhclControl.beforeCurrent = null; - $P.exmptnVhclControl.tableRenderComplete = false; - $P.exmptnVhclControl.newInfo = () => { ajax.get({ url : $P.exmptnVhclControl.urls.newInfo, data: {}, - success:resp => { + success:(resp) => { dialog.open({ id: "exmptnvhcldialog", title: "면제차량 등록", @@ -215,7 +213,7 @@ $(document).ready(function(){ ajax.get({ url : $P.exmptnVhclControl.urls.getInfo, data: param, - success:resp => { + success:(resp) => { dialog.open({ id: "exmptnvhcldialog", title: "면제차량 수정", @@ -241,35 +239,18 @@ $(document).ready(function(){ }; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.exmptnVhclControl.onDatasetChange = (obj) => { - - $P.renderExmptnVhclList(obj["Total"]); + $P.exmptnVhclControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.exmptnVhclControl.dataset, t.found, t.notFound, t.replacer); + $P.renderExmptnVhclList(obj["Total"], $P.exmptnVhclControl.dataset.length, trs); - $("#exmptnVhclPaging--${pageName}").setPagingInfo({ - list : $P.exmptnVhclControl.dataset, - prefix : "exmptnVhclPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.exmptnVhclControl.tableRenderComplete = true; - + Apply.fromDataset.paging($P.exmptnVhclControl.dataset, obj, "exmptnVhclPaging--${pageName}"); }; - $P.exmptnVhclControl.onCurrentChange = (DI) => { - - if(!$P.exmptnVhclControl.tableRenderComplete){ - return; - } - - $P.exmptnVhclControl.tableRenderComplete = false; - - if(!DI){ - $P.clickExmptnVhclList("", true); - } else { - $P.clickExmptnVhclList($P.exmptnVhclControl.getCurrent()["EXMPTN_VHCL_ID"], true); - } + $P.exmptnVhclControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.exmptnVhclControl.dataset, dataItem, $("#exmptnVhclTbody--${pageName}")[0]); } /************************************************************************** @@ -283,7 +264,24 @@ $(document).ready(function(){ $P.exmptnVhclControl.setData([]); } - $P.refreshExmptnVhclList = () => { + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.taskSeCd = "BPV"; + data.fetchSize = $P.exmptnVhclControl.defaultFetchSize; + return data; + } + + $P.searchExmptnVhclList = () => { + $P.exmptnVhclControl.query = $P.getParams(); + $P.exmptnVhclControl.load(1); + } + + $P.scrollExmptnVhclList = () => { + $P.exmptnVhclControl.load($P.exmptnVhclControl.query.pageNum + 1); + } + + $P.refreshExmptnVhclList = () => { if($P.exmptnVhclControl.query.pageNum == null){ $P.exmptnVhclControl.query.pageNum = 1; } @@ -291,17 +289,52 @@ $(document).ready(function(){ $P.exmptnVhclControl.query.fetchSize = $P.exmptnVhclControl.defaultFetchSize * $P.exmptnVhclControl.query.pageNum; $P.exmptnVhclControl.load(1); } - - $P.searchExmptnVhclList = () => { - $P.exmptnVhclControl.query = $P.getParams(); - $P.exmptnVhclControl.load(1); + + $P.fnExcelDown = () => { + if($P.exmptnVhclControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + var cellDefs = getCellDefs($("#exmptnVhclTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)"), + $($("#exmptnVhclRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); + $P.exmptnVhclControl.query.cellDefs = cellDefs; + + $P.exmptnVhclControl.download(); } + + $P.getGridTemplate = () => { + var notFound = [document.getElementById("exmptnVhclNotFound--${pageName}").innerHTML]; + var found = document.getElementById("exmptnVhclRow--${pageName}").innerHTML; + var replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickExmptnVhclList('" + dataItem.getValue("EXMPTN_VHCL_ID") + "');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickExmptnVhclList('" + dataItem.getValue("EXMPTN_VHCL_ID") + "');"); - $P.scrollExmptnVhclList = () => { - $P.exmptnVhclControl.load($P.exmptnVhclControl.query.pageNum + 1); + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderExmptnVhclList = (total, listLength, trs) => { + + var noMore = (total == listLength); + var initScroll = ($P.exmptnVhclControl.query.pageNum < 2) && ($P.exmptnVhclControl.untilPageNum == 0); + + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + + //보안모드 + fn_securityModeToggle($("#securityMode--top").is(":checked")); + + if($P.exmptnVhclControl.untilPageNum != 0){ + $P.exmptnVhclControl.query.fetchSize = $P.exmptnVhclControl.defaultFetchSize; + $P.exmptnVhclControl.query.pageNum = $P.exmptnVhclControl.untilPageNum; + $P.exmptnVhclControl.untilPageNum = 0; + } } - $P.clickExmptnVhclList = (dataKey, auto) => { + $P.clickExmptnVhclList = (dataKey) => { if(dataKey == ""){ $("#btnOpenDelRsn--${pageName}").prop("disabled", true); $("#btnHistory--${pageName}").prop("disabled", true); @@ -317,9 +350,7 @@ $(document).ready(function(){ $("#exmptnVhclTbody--${pageName}").setCurrentRow(dataKey); - if(!auto) { - $P.exmptnVhclControl.setCurrent(dataKey); - } + Apply.toDataset.current($P.exmptnVhclControl.dataset, dataKey); } $P.dblclickExmptnVhclList = (dataKey) => { @@ -338,40 +369,7 @@ $(document).ready(function(){ } $P.exmptnVhclControl.getInfo({"exmptnVhclId" : dataKey}); } - - $P.renderExmptnVhclList = (total) => { - var exmptnVhclDS = $P.exmptnVhclControl.dataset; - var empty = exmptnVhclDS.empty; - var notFound = [document.getElementById("exmptnVhclNotFound--${pageName}").innerHTML]; - var found = document.getElementById("exmptnVhclRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickExmptnVhclList('" + dataItem.getValue("EXMPTN_VHCL_ID") + "');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickExmptnVhclList('" + dataItem.getValue("EXMPTN_VHCL_ID") + "');"); - - var trs = empty ? notFound : exmptnVhclDS.inStrings(found,replacer); - var noMore = (total == exmptnVhclDS.length); - var initScroll = ($P.exmptnVhclControl.query.pageNum < 2) && ($P.exmptnVhclControl.untilPageNum == 0); - - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - //보안모드 - fn_securityModeToggle($("#securityMode--top").is(":checked")); - - if($P.exmptnVhclControl.untilPageNum != 0){ - $P.exmptnVhclControl.query.fetchSize = $P.exmptnVhclControl.defaultFetchSize; - $P.exmptnVhclControl.query.pageNum = $P.exmptnVhclControl.untilPageNum; - $P.exmptnVhclControl.untilPageNum = 0; - } - } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.taskSeCd = "BPV"; - data.fetchSize = $P.exmptnVhclControl.defaultFetchSize; - return data; - } $P.fnOpenDelRsnDialog = () => { dialog.open({ @@ -396,7 +394,7 @@ $(document).ready(function(){ "exmptnVhclId" : dataKey, "delRsn" : $("#delRsn--${pageName}").val() }, - success : resp => { + success : (resp) => { if(resp.saved){ dialog.close("delRsnDialog--${pageName}"); $P.refreshExmptnVhclList(); @@ -411,7 +409,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/BPV/crdn/crdn08/030/list.do"), data: { "exmptnVhclId" : dataKey }, - success:resp => { + success:(resp) => { dialog.open({ id: "exmptnvhclHistorydialog", title: "면제차량 이력", @@ -437,19 +435,7 @@ $(document).ready(function(){ **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $("#btnSearch--${pageName}").on("click", () => $P.searchExmptnVhclList()); - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.exmptnVhclControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#exmptnVhclTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)"), - $($("#exmptnVhclRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); - $P.exmptnVhclControl.query.cellDefs = cellDefs; - - $P.exmptnVhclControl.download(); - }); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown()); $("#btnCreate--${pageName}").on('click', () => { $P.exmptnVhclControl.newInfo(); }); $("#btnOpenDelRsn--${pageName}").on('click', () => { $P.fnOpenDelRsnDialog(); }); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08020-info.jsp index ef75f0f0..6154c2a9 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08020-info.jsp @@ -106,31 +106,47 @@ $(document).ready(function(){ } }); - + + /************************************************************************** + * DatasetControl.set + **************************************************************************/ $P.exmptnVhclControl.setInfo = (item) => { $P.formFields.set(item); var create = isEmpty(item.EXMPTN_VHCL_ID); $("#vhrno--${pageName}").prop("readonly", !create); } + - $P.exmptnVhclControl.save = (info) => { - if (!info) return; + /************************************************************************** + * pageObject.function + **************************************************************************/ + + $P.fnSave = () => { - var create = isEmpty(info.exmptnVhclId); + if(!customValidate($("#frmEdit--${pageName} input"))) return; - ajax.post({ - url : !create ? $P.exmptnVhclControl.urls.update : $P.exmptnVhclControl.urls.create, - data : info, - success : resp => $P.exmptnVhclControl.onSave(resp) - }); - }; + if(confirm("면제 차량 정보를 저장하시겠습니까?")){ + var info = $P.formFields.get(); + + if (!info) { + return; + } - /************************************************************************** - * DatasetControl.on, Dataset.on - **************************************************************************/ - - $P.exmptnVhclControl.onSave = (resp) => { + var create = isEmpty(info.exmptnVhclId); + + ajax.post({ + url : !create ? $P.exmptnVhclControl.urls.update : $P.exmptnVhclControl.urls.create, + data : info, + success : (resp) => { + $P.saveCallback(resp); + } + }); + } + + }; + + $P.saveCallback = (resp) => { if (resp.saved) { dialog.alert({ content : "저장됐습니다.", @@ -143,20 +159,6 @@ $(document).ready(function(){ $P.provided.refreshList(); } }; - /************************************************************************** - * pageObject.function - **************************************************************************/ - - $P.fnSave = () => { - - if(!customValidate($("#frmEdit--${pageName} input"))) return; - - if(confirm("면제 차량 정보를 저장하시겠습니까?")){ - $P.exmptnVhclControl.save($P.formFields.get()); - } - - }; - /************************************************************************** * element.on diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08030-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08030-info.jsp index db9b9906..b50e5471 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08030-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn08030-info.jsp @@ -89,19 +89,37 @@ $(document).ready(function(){ } }); - $P.exmptnVhclControl.onDatasetChange = (obj) => { - var exmptnVhclDS = $P.exmptnVhclControl.dataset; - var empty = exmptnVhclDS.empty; + /************************************************************************** + * Dataset.on + **************************************************************************/ + + $P.exmptnVhclControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.exmptnVhclControl.dataset, t.found, t.notFound, t.replacer); + $P.renderExmptnVhclList(obj["Total"], $P.exmptnVhclControl.dataset.length, trs); + } + + /************************************************************************** + * pageObject.function + **************************************************************************/ + + $P.getGridTemplate = () => { var notFound = [document.getElementById("exmptnVhclNotFound--${pageName}").innerHTML]; var found = document.getElementById("exmptnVhclRow--${pageName}").innerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "") .replace(/{ondblclick}/gi, ""); - - var trs = empty ? notFound : exmptnVhclDS.inStrings(found,replacer); - - $("#exmptnVhclTbody--${pageName}").html(trs.join()); - + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderExmptnVhclList = (total, listLength, trs) => { + $("#exmptnVhclTbody--${pageName}").html(trs); + //보안모드 fn_securityModeToggle($("#securityMode--top").is(":checked")); } diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01010-main.jsp index f3ca5ef9..df61da0a 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01010-main.jsp @@ -246,68 +246,43 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { + $P.crdnControl.dataset.onDatasetChange = (obj) => { - $P.renderCrdnList(obj["Total"]); + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.crdnControl.tableRenderComplete = true; + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); }; - $P.crdnControl.onCurrentChange = (DI) => { - if(!$P.crdnControl.tableRenderComplete){ - return; - } - - if($P.crdnControl.beforeCurrent != null){ - var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; - var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; - $P.crdnControl.beforeCurrent = null; + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); + if(!dataItem){ + $("#bottomCrdnPlc--${pageName}").val(""); - if(!$P.crdnControl.dataset.empty){ - var info = $P.crdnControl.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); - return; - } - - if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ - info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; - } else { - info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); - return; - } - } - - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); + $("#btnOpenCvlcptOrgnl--${pageName}").hide(); + $("#btnDelete--${pageName}").hide(); + $("#btnDeleteSameRcptYmd--${pageName}").hide(); } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } - } - - $P.crdnControl.onRemove = (selected, resp) => { - if (resp.saved){ - $P.toast.show(); - sleep(1000).then(() => $P.refreshCrdnList()); + + $("#bottomCrdnPlc--${pageName}").val(dataItem.data["CRDN_PLC"]); + + if($P.holdList.includes(dataItem.data["CRDN_ID"])){ + $("#btnOpenCvlcptOrgnl--${pageName}").hide(); + $("#btnDelete--${pageName}").hide(); + $("#btnDeleteSameRcptYmd--${pageName}").hide(); + } else { + $("#btnOpenCvlcptOrgnl--${pageName}").show(); + $("#btnDelete--${pageName}").show(); + $("#btnDeleteSameRcptYmd--${pageName}").show(); + } } } - + /************************************************************************** * pageObject.function **************************************************************************/ @@ -338,14 +313,12 @@ $(document).ready(function(){ $P.crdnControl.urls.remove = wctx.url("/"+taskSeCd+"/cvlc/cvlc01/010/remove.do"); } - $P.refreshCrdnList = () => { - $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; - $P.crdnControl.beforeCurrent = { - key : $P.crdnControl.getCurrent()["CRDN_ID"], - index : $P.crdnControl.getCurrent()["ROW_NUM"] - 1 - }; - $P.crdnControl.load(1); + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.crdnControl.defaultFetchSize; + + return data; } $P.searchCrdnList = () => { @@ -362,13 +335,98 @@ $(document).ready(function(){ $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } - $P.clickCrdnList = (dataKey, auto) => { - if(dataKey == ""){ - $("#bottomCrdnPlc--${pageName}").val(""); + $P.refreshCrdnList = () => { + $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; + $P.crdnControl.beforeCurrent = { + key : $P.crdnControl.getCurrent()["CRDN_ID"], + index : $P.crdnControl.getCurrent()["ROW_NUM"] - 1 + }; + + Apply.fromDatasetControl.load($P.crdnControl, 1).then((resp)=>{ + Apply.toDataset.set($P.crdnControl.dataset, resp); + $P.crdnControl.dataset.onDatasetChange(resp); + + if($P.crdnControl.untilPageNum != 0){ + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize; + $P.crdnControl.query.pageNum = $P.crdnControl.untilPageNum; + $P.crdnControl.untilPageNum = 0; + } - if(auto){ - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); + if($P.crdnControl.beforeCurrent != null){ + var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; + var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; + $P.crdnControl.beforeCurrent = null; + + if(!$P.crdnControl.dataset.empty){ + var info = $P.crdnControl.dataset.getData(beforeCurrentKey); + + if(info != null){ + $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); + } else { + + if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ + info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; + } else { + info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; + } + + $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); + } + } } + + $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); + }); + + } + + $P.fnExcelDown = () => { + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)"), + $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); + $P.crdnControl.query.cellDefs = cellDefs; + + $P.crdnControl.download(); + } + + $P.getGridTemplate = () => { + var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; + var found = document.getElementById("crdnRow--${pageName}").innerHTML; + var replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { + + var noMore = (total == listLength); + var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); + + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + + //보안모드 + fn_securityModeToggle($("#securityMode--top").is(":checked")); + + $P.holdList.forEach(function(item){ + $("#crdnTbody--${pageName}").find("tr[data-key='"+item+"']").addClass("bg-dark"); + }); + + } + + $P.clickCrdnList = (dataKey) => { + if(dataKey == ""){ + $("#bottomCrdnPlc--${pageName}").val(""); return; } @@ -386,11 +444,7 @@ $(document).ready(function(){ $("#btnDeleteSameRcptYmd--${pageName}").show(); } - if(!auto){ - $P.crdnControl.setCurrent(dataKey); - } else { - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); - } + Apply.toDataset.current($P.crdnControl.dataset, dataKey); } $P.dblclickCrdnList = (dataKey) => { @@ -407,7 +461,7 @@ $(document).ready(function(){ "crdnId" : dataKey, "openerPageName" : "${pageName}" }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "민원접수 초기자료 편집", @@ -434,45 +488,6 @@ $(document).ready(function(){ }); } - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; - var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; - var found = document.getElementById("crdnRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); - - var trs = empty ? notFound : crdnDS.inStrings(found, replacer); - var noMore = (total == crdnDS.length); - var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - //보안모드 - fn_securityModeToggle($("#securityMode--top").is(":checked")); - - - if($P.crdnControl.untilPageNum != 0){ - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize; - $P.crdnControl.query.pageNum = $P.crdnControl.untilPageNum; - $P.crdnControl.untilPageNum = 0; - } - - $P.holdList.forEach(function(item){ - $("#crdnTbody--${pageName}").find("tr[data-key='"+item+"']").addClass("bg-dark"); - }); - - } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.crdnControl.defaultFetchSize; - - return data; - } $P.fnHold = () => { var curKey = $P.crdnControl.getCurrent()["CRDN_ID"]; @@ -516,9 +531,31 @@ $(document).ready(function(){ $P.crdnControl.select(curKey,true); } - $P.crdnControl.remove(); + var selected = $P.crdnControl.dataset.getKeys("selected"); + if (selected.length < 1) { + return; + } + + var params = { + "IDs" : selected.join(",") + }; + + ajax.post({ + url : $P.crdnControl.urls.remove, + data : params, + success : (resp) => { + $P.removeCallback(selected, resp); + } + }); } + $P.removeCallback = (selected, resp) => { + if (resp.saved){ + $P.toast.show(); + sleep(1000).then(() => $P.refreshCrdnList()); + } + }; + $P.fnRemoveSameRcptYmd = () => { var cur = $P.crdnControl.getCurrent(); if(cur == null){ @@ -549,7 +586,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/"+taskSeCd+"/cvlc/cvlc01/050/info.do"), data : { crdnId : cur["CRDN_ID"] }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "민원내역 원본", @@ -612,7 +649,7 @@ $(document).ready(function(){ "holdRow" : function(currentKey){ $P.fnHold(currentKey); }, - "refreshList" : function(){ + "refreshList" : function(){ $P.refreshCrdnList(); }, "hasData" : function(key){ @@ -630,19 +667,7 @@ $(document).ready(function(){ **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.crdnControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)"), - $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); - $P.crdnControl.query.cellDefs = cellDefs; - - $P.crdnControl.download(); - }); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown()); $("#btnHold--${pageName}").on("click", () => $P.fnHold()); $("#btnDelete--${pageName}").on("click", () => $P.fnRemove()); diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01020-info.jsp index 21f7b0ef..db2b7e15 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01020-info.jsp @@ -437,65 +437,14 @@ $(document).ready(function(){ }); - $P.crdnControl.save = (info, accept) => { - if (!info) return; - - var formData = new FormData(document.getElementById("frmEdit--${pageName}")); - - if(accept){ - formData.append("acceptYn", "Y"); - } else { - formData.append("acceptYn", "N"); - } - - ajax.post({ - url : $P.crdnControl.urls.update, - data : formData, contentType : false, processData : false, - success : resp => { $P.crdnControl.onSave(resp); } - }); - }; - /************************************************************************** - * DatasetControl.on, Dataset.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onCurrentChange = (DI) => { - $P.formFields.set(DI); + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + $P.formFields.set(dataItem); } - $P.crdnControl.onSave = (resp) => { - if (resp.saved) { - - dialog.alert({ - content : "저장됐습니다.", - init : function() { - setDialogZindex(); - focusClose(); - } - }); - - if($("#levyExcldialog--${pageName}").length > 0){ - dialog.close("levyExcldialog--${pageName}"); - } - - var crdnId = $("#crdnId--${pageName}").val(); - - var cursorKey = ""; - - var nextKey = $P.provided.getNextKey(crdnId); - if(nextKey != ""){ - cursorKey = nextKey; - } else { - var prevKey = $P.provided.getPrevKey(crdnId); - if(prevKey != ""){ - cursorKey = prevKey; - } - } - - $("#refreshEnd--${pageName}").attr("data-cursor-key", cursorKey); - $P.provided.refreshList(); - } - }; /************************************************************************** * pageObject.function **************************************************************************/ @@ -531,7 +480,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/${taskSeCd}/excl/excl01/020/info.do"), data : params, - success : resp => { + success : (resp) => { dialog.open({ id : "levyExcldialog--${pageName}", @@ -546,6 +495,26 @@ $(document).ready(function(){ } }); }; + + $P.save = (info, accept) => { + if (!info) return; + + var formData = new FormData(document.getElementById("frmEdit--${pageName}")); + + if(accept){ + formData.append("acceptYn", "Y"); + } else { + formData.append("acceptYn", "N"); + } + + ajax.post({ + url : $P.crdnControl.urls.update, + data : formData, contentType : false, processData : false, + success : (resp) => { + $P.saveCallback(resp); + } + }); + }; $P.exclSaveCallback = function(exclInfo){ @@ -556,9 +525,43 @@ $(document).ready(function(){ mergeInfo.levyExclRsnCd = exclInfo.levyExclRsnCd; mergeInfo.levyExclSeCd = exclInfo.levyExclSeCd; - $P.crdnControl.save(mergeInfo, false); + $P.save(mergeInfo, false); } + $P.saveCallback = (resp) => { + if (resp.saved) { + + dialog.alert({ + content : "저장됐습니다.", + init : function() { + setDialogZindex(); + focusClose(); + } + }); + + if($("#levyExcldialog--${pageName}").length > 0){ + dialog.close("levyExcldialog--${pageName}"); + } + + var crdnId = $("#crdnId--${pageName}").val(); + + var cursorKey = ""; + + var nextKey = $P.provided.getNextKey(crdnId); + if(nextKey != ""){ + cursorKey = nextKey; + } else { + var prevKey = $P.provided.getPrevKey(crdnId); + if(prevKey != ""){ + cursorKey = prevKey; + } + } + + $("#refreshEnd--${pageName}").attr("data-cursor-key", cursorKey); + $P.provided.refreshList(); + } + }; + $P.fnPrev = () => { var prevKey = $P.provided.getPrevKey($("#crdnId--${pageName}").val()); if(prevKey != ""){ @@ -580,7 +583,7 @@ $(document).ready(function(){ headers: { Accept: "application/json; charset=utf-8" }, - success : resp => { + success : (resp) => { var crdnInfo = resp.crdnInfo; crdnInfo.CVLCPT_APLY_CN = escapeHTMLEntity(crdnInfo.CVLCPT_APLY_CN); $P.crdnControl.setData([crdnInfo]); @@ -614,7 +617,7 @@ $(document).ready(function(){ ajax.get({ url : $P.crdnControl.urls.create, data : { crdnId : crdnId }, - success : resp => { + success : (resp) => { if (resp.saved) { dialog.alert({ content : "복사 자료가 생성되었습니다.", @@ -641,7 +644,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/${taskSeCd}/cvlc/cvlc01/050/info.do"), data : { crdnId : crdnId }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "민원내역 원본", @@ -705,7 +708,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/"+params.taskSeCd + "/payer/info.do"), data : params || {}, - success : resp => { + success : (resp) => { dialog.open({ id : "payerDialog", title : dialogTitle, @@ -732,7 +735,7 @@ $(document).ready(function(){ url : wctx.url("/"+params.taskSeCd + "/sprt/sprt02/020/info.do"), headers: { Accept: "application/json; charset=utf-8" }, data : params || {}, - success : resp => { + success : (resp) => { if (resp.crdnPayer) { var payer = resp.crdnPayer; @@ -795,7 +798,7 @@ $(document).ready(function(){ } if(confirm("현재 단속 정보를 저장하시겠습니까?")){ - $P.crdnControl.save($P.formFields.get(), true); + $P.save($P.formFields.get(), true); } }; @@ -811,7 +814,7 @@ $(document).ready(function(){ ajax.post({ url : $P.crdnControl.urls.remove, data : { crdnId : crdnId }, - success : resp => { + success : (resp) => { if(resp.saved){ var message = "민원회수 요청이 등록되었습니다.\n" +"30~60분 사이에 서버에서 민원시스템으로 전송이 진행되니 이후에 민원시스템에서 확인하시기 바랍니다."; @@ -1135,7 +1138,7 @@ $(document).ready(function(){ if(!$P.provided.hasData(this.dataset.cursorKey)){ dialog.close("cvlcptInitialDataEditDialog--${openerPageName}"); return; - } + } $P.fnGo(this.dataset.cursorKey); }); diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01050-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01050-info.jsp index 3d178094..3ab20c3d 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01050-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc01050-info.jsp @@ -130,10 +130,10 @@ $(document).ready(function() { }); /************************************************************************** - * DatasetControl.on, Dataset.on + * Dataset.on **************************************************************************/ - $P.cvlcptControl.onCurrentChange = (DI) => { - $P.formFields.set(DI); + $P.cvlcptControl.dataset.onCurrentChange = (dataItem) => { + $P.formFields.set(dataItem); } /************************************************************************** @@ -161,7 +161,7 @@ $(document).ready(function() { headers: { Accept: "application/json; charset=utf-8" }, - success : resp => { + success : (resp) => { var cvlcptInfo = resp.cvlcptInfo; cvlcptInfo.CVLCPT_APLY_CN = escapeHTMLEntity(cvlcptInfo.CVLCPT_APLY_CN); $P.cvlcptControl.setData([cvlcptInfo]); @@ -178,7 +178,7 @@ $(document).ready(function() { ajax.post({ url : wctx.url("/"+$P.taskSeCd+"/cvlc/cvlc01/050/makeFileFromHwpFormat.do"), data : { crdnId : $("#crdnId--${pageName}").val() }, - success : resp => { + success : (resp) => { var a = document.createElement("a"); a.href = resp.filePath; diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp index fdc6cda6..a22134c2 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp @@ -146,7 +146,7 @@ No. + onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);" /> 접수번호 @@ -181,7 +181,7 @@ {ROW_NUM} + onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);" /> {CVLCPT_RCPT_NO} {CVLCPT_LIST_NO} @@ -252,97 +252,28 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; - - $P.crdnControl.save = (processType) => { - - ajax.post({ - url : $P.crdnControl.urls.update, - data : { - "processType" : processType, - "crdnIDs" : $P.crdnControl.dataset.getKeys("selected").join(",") - }, - success : resp => { - if(resp.saved){ - dialog.alert({ - content : "처리되었습니다.", - init : function() { - focusClose(); - } - }); - $P.refreshCrdnList(); - } - } - }); - } /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { + $P.crdnControl.dataset.onDatasetChange = (obj) => { - $P.renderCrdnList(obj["Total"]); - - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); - - $P.crdnControl.tableRenderComplete = true; + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); + + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); }; - $P.crdnControl.onCurrentChange = (DI) => { - - if(!$P.crdnControl.tableRenderComplete){ - return; - } - - if($P.crdnControl.beforeCurrent != null){ - var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; - var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; - $P.crdnControl.beforeCurrent = null; - - if(!$P.crdnControl.dataset.empty){ - var info = $P.crdnControl.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); - return; - } - - if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ - info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; - } else { - info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); - return; - } - } - - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); - } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); } - $P.crdnControl.onSelectionChange = (selectedArr) => { - - var crdnDS = $P.crdnControl.dataset; - var keys = selectedArr.map(item => crdnDS.getKey(item)); - - $("#table-responsive--${pageName}").find("input[name='gridCheckbox']").each(function() { - var checkbox = $(this); - checkbox.prop("checked", keys.includes(checkbox.val())); - }); - - $("#btnExecuteAnswer--${pageName}").prop("disabled", keys.length < 1); - $("#btnAnswerComplete--${pageName}").prop("disabled", keys.length < 1); - $("#btnExecuteDisabledTagInfoInquire--${pageName}").prop("disabled", keys.length < 1); + $P.crdnControl.dataset.onSelectionChange = (selectedArr) => { + Apply.fromDataset.gridCheckbox($P.crdnControl.dataset, document.getElementById("crdnTbody--${pageName}"), 1, selectedArr); + Apply.fromDataset.gridButton($P.crdnControl.dataset, $("#btnExecuteAnswer--${pageName}")[0], selectedArr); + Apply.fromDataset.gridButton($P.crdnControl.dataset, $("#btnAnswerComplete--${pageName}")[0], selectedArr); + Apply.fromDataset.gridButton($P.crdnControl.dataset, $("#btnExecuteDisabledTagInfoInquire--${pageName}")[0], selectedArr); }; /************************************************************************** @@ -377,16 +308,14 @@ $(document).ready(function(){ $P.crdnControl.urls.update = wctx.url("/"+taskSeCd+"/cvlc/cvlc02/030/update.do"); } - $P.refreshCrdnList = () => { - $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; - $P.crdnControl.beforeCurrent = { - key : $P.crdnControl.getCurrent()["CRDN_ID"], - index : $P.crdnControl.getCurrent()["ROW_NUM"] - 1 - }; - $P.crdnControl.load(1); - } + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.crdnControl.defaultFetchSize; + return data; + } + $P.searchCrdnList = () => { $P.crdnControl.query = $P.getParams(); $P.crdnControl.load(1); @@ -396,6 +325,16 @@ $(document).ready(function(){ $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } + $P.refreshCrdnList = () => { + $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; + $P.crdnControl.beforeCurrent = { + key : $P.crdnControl.getCurrent()["CRDN_ID"], + index : $P.crdnControl.getCurrent()["ROW_NUM"] - 1 + }; + $P.crdnControl.load(1); + } + $P.fnExcelDown = (forApproval) => { if($P.crdnControl.dataset.empty){ @@ -417,55 +356,28 @@ $(document).ready(function(){ $P.crdnControl.query.includePhoto = null; }; - - $P.clickCrdnList = (dataKey, auto) => { - if(dataKey == ""){ - return; - } - $("#crdnTbody--${pageName}").setCurrentRow(dataKey); - if(!auto){ - $P.crdnControl.setCurrent(dataKey); - } - } - $P.dblclickCrdnList = (dataKey) => { - let params = { - callControlName : "pageObject['${pageName}'].crdnControl" - , crdnId : dataKey - } - - ajax.get({ - url : $P.crdnControl.urls.getInfo, - data : params, - success : resp => { - - dialog.open({ - id : "totalInfoMainDialog", - title : "개별총정보", size : "xxl", content : resp, - init : () => {} - }); - - } - }); - - } - - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; + $P.getGridTemplate = () => { var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; var found = document.getElementById("crdnRow--${pageName}").innerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); - var trs = empty ? notFound : crdnDS.inStrings(found, replacer); - var noMore = (total == crdnDS.length); + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { + + var noMore = (total == listLength); var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); //보안모드 fn_securityModeToggle($("#securityMode--top").is(":checked")); @@ -479,7 +391,7 @@ $(document).ready(function(){ $("#crdnTbody--${pageName}").find("tr[data-key]").each(function(item){ var crdnId = this.dataset.key; - var data = crdnDS.getData(crdnId); + var data = $P.crdnControl.dataset.getData(crdnId); if(data.COPY_EXIST_YN == "Y"){ $(this).addClass("text-red"); @@ -490,13 +402,47 @@ $(document).ready(function(){ }); } + + $P.checkCrdnList = (element, bool) => { + Grid.checkbox.sync(element, bool); - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.crdnControl.defaultFetchSize; + var atLeastOne = Grid.checkbox.countChecked(element) > 0; + $("#btnExecuteAnswer--${pageName}").prop("disabled", !atLeastOne); + $("#btnAnswerComplete--${pageName}").prop("disabled", !atLeastOne); + $("#btnExecuteDisabledTagInfoInquire--${pageName}").prop("disabled", !atLeastOne); + + Apply.toDataset.selection($P.crdnControl.dataset, element, bool); + } + + $P.clickCrdnList = (dataKey) => { + if(dataKey == ""){ + return; + } + $("#crdnTbody--${pageName}").setCurrentRow(dataKey); + + Apply.toDataset.current($P.crdnControl.dataset, dataKey); + } + + $P.dblclickCrdnList = (dataKey) => { + let params = { + callControlName : "pageObject['${pageName}'].crdnControl" + , crdnId : dataKey + } + + ajax.get({ + url : $P.crdnControl.urls.getInfo, + data : params, + success : (resp) => { + + dialog.open({ + id : "totalInfoMainDialog", + title : "개별총정보", size : "xxl", content : resp, + init : () => {} + }); + + } + }); - return data; } $P.fnOpenCvlcptOrgnl = () => { @@ -511,7 +457,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/"+taskSeCd+"/cvlc/cvlc01/050/info.do"), data : { crdnId : cur["CRDN_ID"] }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "민원내역 원본", @@ -548,7 +494,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/"+taskSeCd+"/cvlc/cvlc02/060/info.do"), data : { crdnId : cur["CRDN_ID"] }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "답변내용 미리보기", @@ -583,7 +529,7 @@ $(document).ready(function(){ focusOK(); }, onOK : () => { - $P.crdnControl.save('answerExecute'); + $P.save('answerExecute'); } }); } @@ -598,11 +544,34 @@ $(document).ready(function(){ focusOK(); }, onOK : () => { - $P.crdnControl.save('answerComplete'); + $P.save('answerComplete'); } }); } + // + $P.save = (processType) => { + + ajax.post({ + url : $P.crdnControl.urls.update, + data : { + "processType" : processType, + "crdnIDs" : $P.crdnControl.dataset.getKeys("selected").join(",") + }, + success : (resp) => { + if(resp.saved){ + dialog.alert({ + content : "처리되었습니다.", + init : function() { + focusClose(); + } + }); + $P.refreshCrdnList(); + } + } + }); + } + //표지정보 조회 $P.fnExecuteDisabledTagInfoInquire = () => { @@ -643,7 +612,7 @@ $(document).ready(function(){ data : { "crdnIDs" : keys.join(",") }, - success : resp => { + success : (resp) => { dialog.alert({ content : "표지정보조회가 실행되었습니다.", init : function() { diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02060-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02060-info.jsp index 1e11c6f7..0119a91c 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02060-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02060-info.jsp @@ -100,34 +100,12 @@ $(document).ready(function() { } }); - $P.cvlcptControl.save = (info) => { - if (!info) return; - - ajax.post({ - url : $P.cvlcptControl.urls.update, - data : info, - success : resp => { $P.cvlcptControl.onSave(resp); } - }); - - }; /************************************************************************** - * DatasetControl.on, Dataset.on + * Dataset.on **************************************************************************/ - $P.cvlcptControl.onCurrentChange = (DI) => { - $P.formFields.set(DI); - } - - $P.cvlcptControl.onSave = (resp) => { - if (resp.saved) { - dialog.alert({ - content : "표지정보조회가 실행되었습니다.", - init : function() { - setDialogZindex(); - focusClose(); - } - }); - } + $P.cvlcptControl.dataset.onCurrentChange = (dataItem) => { + $P.formFields.set(dataItem); } /************************************************************************** @@ -155,7 +133,7 @@ $(document).ready(function() { headers: { Accept: "application/json; charset=utf-8" }, - success : resp => { + success : (resp) => { var cvlcptInfo = resp.cvlcptInfo; cvlcptInfo.CVLCPT_APLY_CN = escapeHTMLEntity(cvlcptInfo.CVLCPT_APLY_CN); $P.cvlcptControl.setData([cvlcptInfo]); @@ -172,11 +150,35 @@ $(document).ready(function() { if(!customValidate($("#frmEdit--${pageName} input"))) return; if(confirm("현재 답변 내용을 저장하시겠습니까?")){ - $P.cvlcptControl.save($P.formFields.get()); + var info = $P.formFields.get(); + + if (!info) { + return; + } + + ajax.post({ + url : $P.cvlcptControl.urls.update, + data : info, + success : (resp) => { + $P.saveCallback(resp); + } + }); } } - + + $P.saveCallback = (resp) => { + if (resp.saved) { + dialog.alert({ + content : "표지정보조회가 실행되었습니다.", + init : function() { + setDialogZindex(); + focusClose(); + } + }); + } + } + /************************************************************************** * element.on **************************************************************************/ diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc03010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc03010-main.jsp index bcfa9b59..3cbc2414 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc03010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc03010-main.jsp @@ -242,67 +242,24 @@ $(document).ready(function(){ $P.crdnControl.defaultFetchSize = FETCH_XS; $P.crdnControl.untilPageNum = 0; $P.crdnControl.beforeCurrent = null; - $P.crdnControl.tableRenderComplete = false; + /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.crdnControl.onDatasetChange = (obj) => { - - $P.renderCrdnList(obj["Total"]); - - $("#crdnPaging--${pageName}").setPagingInfo({ - list : $P.crdnControl.dataset, - prefix : "crdnPaging--${pageName}", - totalSize : obj["Total"] - }); + $P.crdnControl.dataset.onDatasetChange = (obj) => { - $P.crdnControl.tableRenderComplete = true; + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.crdnControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.crdnControl.dataset.length, trs); + + Apply.fromDataset.paging($P.crdnControl.dataset, obj, "crdnPaging--${pageName}"); }; - $P.crdnControl.onCurrentChange = (DI) => { - if(!$P.crdnControl.tableRenderComplete){ - return; - } - - if($P.crdnControl.beforeCurrent != null){ - var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; - var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; - $P.crdnControl.beforeCurrent = null; - - if(!$P.crdnControl.dataset.empty){ - var info = $P.crdnControl.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); - return; - } - - if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ - info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; - } else { - info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); - return; - } - } - - $P.crdnControl.tableRenderComplete = false; - if(!DI){ - $P.clickCrdnList("", true); - } else { - $P.clickCrdnList($P.crdnControl.getCurrent()["CRDN_ID"], true); - } + $P.crdnControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.crdnControl.dataset, dataItem, $("#crdnTbody--${pageName}")[0]); } - $P.crdnControl.onRemove = (selected, resp) => { - if (resp.saved){ - $P.toast.show(); - sleep(1000).then(() => $P.refreshCrdnList()); - } - } /************************************************************************** * pageObject.function @@ -329,6 +286,25 @@ $(document).ready(function(){ $P.crdnControl.urls.remove = wctx.url("/"+taskSeCd+"/cvlc/cvlc01/010/remove.do"); } + + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.crdnControl.defaultFetchSize; + + return data; + } + + $P.searchCrdnList = () => { + + $P.crdnControl.query = $P.getParams(); + $P.crdnControl.load(1); + } + + $P.scrollCrdnList = () => { + $P.crdnControl.load($P.crdnControl.query.pageNum + 1); + } + $P.refreshCrdnList = () => { $P.crdnControl.untilPageNum = $P.crdnControl.query.pageNum; $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize * $P.crdnControl.query.pageNum; @@ -336,35 +312,91 @@ $(document).ready(function(){ key : $P.crdnControl.getCurrent()["CRDN_ID"], index : $P.crdnControl.getCurrent()["ROW_NUM"] - 1 }; - $P.crdnControl.load(1); - } + + Apply.fromDatasetControl.load($P.crdnControl, 1).then((resp)=>{ + Apply.toDataset.set($P.crdnControl.dataset, resp); + $P.crdnControl.dataset.onDatasetChange(resp); + + if($P.crdnControl.untilPageNum != 0){ + $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize; + $P.crdnControl.query.pageNum = $P.crdnControl.untilPageNum; + $P.crdnControl.untilPageNum = 0; + } + + if($P.crdnControl.beforeCurrent != null){ + var beforeCurrentKey = $P.crdnControl.beforeCurrent.key; + var beforeCurrentIndex = $P.crdnControl.beforeCurrent.index; + $P.crdnControl.beforeCurrent = null; + + if(!$P.crdnControl.dataset.empty){ + var info = $P.crdnControl.dataset.getData(beforeCurrentKey); + + if(info != null){ + $P.crdnControl.dataset.setCurrent(beforeCurrentKey,true); + } else { + if(beforeCurrentIndex > ($P.crdnControl.dataset.length - 1)){ + info = $P.crdnControl.dataset.getDataset()[$P.crdnControl.dataset.length - 1]; + } else { + info = $P.crdnControl.dataset.getDataset()[beforeCurrentIndex]; + } - $P.searchCrdnList = () => { + $P.crdnControl.dataset.setCurrent(info["CRDN_ID"],true); + } + } + } + + $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); + }); + } + + $P.fnExcelDown = () => { + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } - $P.crdnControl.query = $P.getParams(); - $P.crdnControl.load(1); + var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)"), + $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); + $P.crdnControl.query.cellDefs = cellDefs; + + $P.crdnControl.download(); } + + $P.getGridTemplate = () => { + var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; + var found = document.getElementById("crdnRow--${pageName}").innerHTML; + var replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); + + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderCrdnList = (total, listLength, trs) => { + + var noMore = (total == listLength); + var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); + + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + + //보안모드 + fn_securityModeToggle($("#securityMode--top").is(":checked")); - $P.scrollCrdnList = () => { - $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } - $P.clickCrdnList = (dataKey, auto) => { + $P.clickCrdnList = (dataKey) => { if(dataKey == ""){ - - if(auto){ - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); - } return; } $("#crdnTbody--${pageName}").setCurrentRow(dataKey); - - if(!auto){ - $P.crdnControl.setCurrent(dataKey); - } else { - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); - } + + Apply.toDataset.current($P.crdnControl.dataset, dataKey); } $P.dblclickCrdnList = (dataKey) => { @@ -376,7 +408,7 @@ $(document).ready(function(){ ajax.get({ url : $P.crdnControl.urls.getInfo, data : params, - success : resp => { + success : (resp) => { dialog.open({ id : "totalInfoMainDialog", @@ -387,44 +419,7 @@ $(document).ready(function(){ } }); } - - $P.renderCrdnList = (total) => { - - var crdnDS = $P.crdnControl.dataset; - var empty = crdnDS.empty; - var notFound = [document.getElementById("crdnNotFound--${pageName}").innerHTML]; - var found = document.getElementById("crdnRow--${pageName}").innerHTML; - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('" + dataItem.getValue("CRDN_ID") + "');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('" + dataItem.getValue("CRDN_ID") + "');"); - - var trs = empty ? notFound : crdnDS.inStrings(found, replacer); - var noMore = (total == crdnDS.length); - var initScroll = ($P.crdnControl.query.pageNum < 2) && ($P.crdnControl.untilPageNum == 0); - - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - //보안모드 - fn_securityModeToggle($("#securityMode--top").is(":checked")); - - if($P.crdnControl.untilPageNum != 0){ - $P.crdnControl.query.fetchSize = $P.crdnControl.defaultFetchSize; - $P.crdnControl.query.pageNum = $P.crdnControl.untilPageNum; - $P.crdnControl.untilPageNum = 0; - } - - } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.crdnControl.defaultFetchSize; - - return data; - } - - - + $P.fnRemove = () => { var cur = $P.crdnControl.getCurrent(); @@ -435,11 +430,31 @@ $(document).ready(function(){ var curKey = cur["CRDN_ID"]; $P.crdnControl.select(curKey,true); - $P.crdnControl.remove(); - } + var selected = $P.crdnControl.dataset.getKeys("selected"); + if (selected.length < 1) { + return; + } + var params = { + "IDs" : selected.join(",") + }; + ajax.post({ + url : $P.crdnControl.urls.remove, + data : params, + success : (resp) => { + $P.saveCallback(selected, resp); + } + }); + } + $P.saveCallback = (selected, resp) => { + if (resp.saved){ + $P.toast.show(); + sleep(1000).then(() => $P.refreshCrdnList()); + } + } + $P.fnOpenCvlcptOrgnl = () => { var cur = $P.crdnControl.getCurrent(); if(cur == null){ @@ -452,7 +467,7 @@ $(document).ready(function(){ ajax.get({ url : wctx.url("/"+taskSeCd+"/cvlc/cvlc01/050/info.do"), data : { crdnId : cur["CRDN_ID"] }, - success : resp => { + success : (resp) => { dialog.open({ id : dialogId, title : "민원내역 원본", @@ -522,19 +537,7 @@ $(document).ready(function(){ **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.crdnControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)"), - $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); - $P.crdnControl.query.cellDefs = cellDefs; - - $P.crdnControl.download(); - }); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown()); $("#btnDelete--${pageName}").on("click", () => $P.fnRemove()); $("#btnOpenCvlcptOrgnl--${pageName}").on("click", () => $P.fnOpenCvlcptOrgnl()); diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc04010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc04010-main.jsp index 893a4c00..7acc8060 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc04010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc04010-main.jsp @@ -193,67 +193,20 @@ $(document).ready(function(){ $P.dmndControl.defaultFetchSize = FETCH_XS; $P.dmndControl.untilPageNum = 0; $P.dmndControl.beforeCurrent = null; - $P.dmndControl.tableRenderComplete = false; /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.dmndControl.onDatasetChange = (obj) => { - - $P.renderDmndList(obj["Total"]); - - $("#dmndPaging--${pageName}").setPagingInfo({ - list : $P.dmndControl.dataset, - prefix : "dmndPaging--${pageName}", - totalSize : obj["Total"] - }); + $P.dmndControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.dmndControl.dataset, t.found, t.notFound, t.replacer); + $P.renderDmndList(obj["Total"], $P.dmndControl.dataset.length, trs); - $P.dmndControl.tableRenderComplete = true; + Apply.fromDataset.paging($P.dmndControl.dataset, obj, "dmndPaging--${pageName}"); }; - $P.dmndControl.onCurrentChange = (DI) => { - if(!$P.dmndControl.tableRenderComplete){ - return; - } - - if($P.dmndControl.beforeCurrent != null){ - var beforeCurrentKey = $P.dmndControl.beforeCurrent.key; - var beforeCurrentIndex = $P.dmndControl.beforeCurrent.index; - $P.dmndControl.beforeCurrent = null; - - if(!$P.dmndControl.dataset.empty){ - var info = $P.dmndControl.dataset.getData(beforeCurrentKey); - - if(info != null){ - $P.dmndControl.dataset.setCurrent(beforeCurrentKey,true); - return; - } - - if(beforeCurrentIndex > ($P.dmndControl.dataset.length - 1)){ - info = $P.dmndControl.dataset.getDataset()[$P.dmndControl.dataset.length - 1]; - } else { - info = $P.dmndControl.dataset.getDataset()[beforeCurrentIndex]; - } - - $P.dmndControl.dataset.setCurrent(info["INDIV_ID"],true); - return; - } - } - - $P.dmndControl.tableRenderComplete = false; - if(!DI){ - $P.clickDmndList("", true); - } else { - $P.clickDmndList($P.dmndControl.getCurrent()["INDIV_ID"], true); - } - } - - $P.dmndControl.onRemove = (selected, resp) => { - if (resp.saved){ - $("#toastText--${pageName}").html("삭제 되었습니다."); - $P.toast.show(); - sleep(1000).then(() => $P.refreshDmndList()); - } + $P.dmndControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.dmndControl.dataset, dataItem, $("#dmndTbody--${pageName}")[0]); } /************************************************************************** @@ -273,24 +226,16 @@ $(document).ready(function(){ $P.dmndControl.urls.remove = wctx.url("/"+taskSeCd+"/cvlc/cvlc04/010/remove.do"); } - $P.refreshDmndList = () => { - $P.dmndControl.untilPageNum = $P.dmndControl.query.pageNum; - $P.dmndControl.query.fetchSize = $P.dmndControl.defaultFetchSize * $P.dmndControl.query.pageNum; - - if(!$P.dmndControl.dataset.empty){ - $P.dmndControl.beforeCurrent = { - key : $P.dmndControl.getCurrent()["INDIV_ID"], - index : $P.dmndControl.getCurrent()["ROW_NUM"] - 1 - }; - } - - $P.dmndControl.load(1); + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.dmndControl.defaultFetchSize; + + return data; } $P.searchDmndList = () => { - $P.dmndControl.query = $P.getParams(); - $P.dmndControl.load(1); } @@ -298,37 +243,72 @@ $(document).ready(function(){ $P.dmndControl.load($P.dmndControl.query.pageNum + 1); } - $P.clickDmndList = (dataKey, auto) => { - if(dataKey == ""){ - if(auto){ - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); - } - return; - } + $P.refreshDmndList = () => { + $P.dmndControl.untilPageNum = $P.dmndControl.query.pageNum; + $P.dmndControl.query.fetchSize = $P.dmndControl.defaultFetchSize * $P.dmndControl.query.pageNum; - $("#dmndTbody--${pageName}").setCurrentRow(dataKey); - - if(!auto){ - $P.dmndControl.setCurrent(dataKey); - } else { - $("label[for='table-responsive--${pageName}']").trigger("refreshEnd"); + if(!$P.dmndControl.dataset.empty){ + $P.dmndControl.beforeCurrent = { + key : $P.dmndControl.getCurrent()["INDIV_ID"], + index : $P.dmndControl.getCurrent()["ROW_NUM"] - 1 + }; } + + Apply.fromDatasetControl.load($P.dmndControl, 1).then((resp)=>{ + Apply.toDataset.set($P.dmndControl.dataset, resp); + $P.dmndControl.dataset.onDatasetChange(resp); + + if($P.dmndControl.untilPageNum != 0){ + $P.dmndControl.query.fetchSize = $P.dmndControl.defaultFetchSize; + $P.dmndControl.query.pageNum = $P.dmndControl.untilPageNum; + $P.dmndControl.untilPageNum = 0; + } + + if($P.dmndControl.beforeCurrent != null){ + var beforeCurrentKey = $P.dmndControl.beforeCurrent.key; + var beforeCurrentIndex = $P.dmndControl.beforeCurrent.index; + $P.dmndControl.beforeCurrent = null; + + if(!$P.dmndControl.dataset.empty){ + var info = $P.dmndControl.dataset.getData(beforeCurrentKey); + + if(info != null){ + $P.dmndControl.dataset.setCurrent(beforeCurrentKey,true); + } else { + + if(beforeCurrentIndex > ($P.dmndControl.dataset.length - 1)){ + info = $P.dmndControl.dataset.getDataset()[$P.dmndControl.dataset.length - 1]; + } else { + info = $P.dmndControl.dataset.getDataset()[beforeCurrentIndex]; + } + + $P.dmndControl.dataset.setCurrent(info["INDIV_ID"],true); + } + } + } + + }); } - $P.renderDmndList = (total) => { - - var dmndDS = $P.dmndControl.dataset; - var empty = dmndDS.empty; + $P.getGridTemplate = () => { var notFound = [document.getElementById("dmndNotFound--${pageName}").innerHTML]; var found = document.getElementById("dmndRow--${pageName}").innerHTML; var replacer = (str, dataItem) => str .replace(/{onclick}/gi, "pageObject['${pageName}'].clickDmndList('" + dataItem.getValue("INDIV_ID") + "');"); - var trs = empty ? notFound : dmndDS.inStrings(found, replacer); - var noMore = (total == dmndDS.length); + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderDmndList = (total, listLength, trs) => { + + var noMore = (total == listLength); var initScroll = ($P.dmndControl.query.pageNum < 2) && ($P.dmndControl.untilPageNum == 0); - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); if($P.dmndControl.untilPageNum != 0){ $P.dmndControl.query.fetchSize = $P.dmndControl.defaultFetchSize; @@ -337,12 +317,13 @@ $(document).ready(function(){ } } - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.dmndControl.defaultFetchSize; - - return data; + $P.clickDmndList = (dataKey) => { + if(dataKey == ""){ + return; + } + + $("#dmndTbody--${pageName}").setCurrentRow(dataKey); + Apply.toDataset.current($P.dmndControl.dataset, dataKey); } $P.fnRemove = (allCompleteDataIds) => { @@ -359,7 +340,31 @@ $(document).ready(function(){ $P.dmndControl.select(curKey,true); } - $P.dmndControl.remove(); + var selected = $P.dmndControl.dataset.getKeys("selected"); + if (selected.length < 1) { + return; + } + + var params = { + "IDs" : selected.join(",") + }; + + ajax.post({ + url : $P.dmndControl.urls.remove, + data : params, + success : (resp) => { + $P.removeCallback(selected, resp); + } + }); + + } + + $P.removeCallback = (selected, resp) => { + if (resp.saved){ + $("#toastText--${pageName}").html("삭제 되었습니다."); + $P.toast.show(); + sleep(1000).then(() => $P.refreshDmndList()); + } } $P.fnRemoveAllCompleteData = () => { @@ -425,7 +430,7 @@ $(document).ready(function(){ ajax.get({ url : $P.dmndControl.urls.create, data : info, - success : resp => { + success : (resp) => { if(resp.saved){ dialog.close("seallDmndDialog--${pageName}"); diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc05010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc05010-main.jsp index 96cc7ea9..b8c08eea 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc05010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc05010-main.jsp @@ -380,7 +380,7 @@ $(document).ready(function(){ ajax.get({ url : $P.ansBodyControl.urls.load, data : {"taskSeCd" : taskSeCd}, - success : resp => { + success : (resp) => { $("#headerCn--${pageName}").val(resp.headerCn); $("#footerCn--${pageName}").val(resp.footerCn); @@ -561,7 +561,7 @@ $(document).ready(function(){ ajax.get({ url : $P.ansBodyControl.urls.load, data : {"taskSeCd" : taskSeCd}, - success : resp => { + success : (resp) => { $("#headerCn--${pageName}").val(resp.headerCn); $("#footerCn--${pageName}").val(resp.footerCn); @@ -625,7 +625,7 @@ $(document).ready(function(){ ajax.get({ url : $P.ansBodyControl.urls.update, data : info, - success : resp => { + success : (resp) => { if(resp.saved){ $P.toast.show(); sleep(1000).then(() => $P.refreshAnsWordsInfo()); @@ -649,7 +649,7 @@ $(document).ready(function(){ ajax.get({ url : $P.ansBodyControl.urls.remove, data : info, - success : resp => { + success : (resp) => { if(resp.saved){ $P.toast.show(); sleep(1000).then(() => $P.refreshAnsWordsInfo()); diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc06010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc06010-main.jsp index ae9fb1ca..8c0ff2ba 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc06010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc06010-main.jsp @@ -184,7 +184,7 @@ $(document).ready(function(){ ajax.get({ url : $P.warningWordsControl.urls.load, data : {"taskSeCd" : taskSeCd}, - success : resp => { + success : (resp) => { $P.warningWordsControl.setData(resp.List); @@ -258,7 +258,7 @@ $(document).ready(function(){ ajax.get({ url : $P.warningWordsControl.urls.load, data : {"taskSeCd" : taskSeCd}, - success : resp => { + success : (resp) => { $P.warningWordsControl.setData(resp.List); $P.renderWarningWordsList(resp.List.length); @@ -291,7 +291,7 @@ $(document).ready(function(){ ajax.get({ url : $P.warningWordsControl.urls.update, data : info, - success : resp => { + success : (resp) => { if(resp.saved){ $P.toast.show(); sleep(1000).then(() => $P.refreshWarningWordsInfo()); diff --git a/src/main/webapp/WEB-INF/jsp/fims/mngt/mngt04010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/mngt/mngt04010-main.jsp index 2d85e2c9..62bd22b3 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/mngt/mngt04010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/mngt/mngt04010-main.jsp @@ -166,51 +166,26 @@ $(document).ready(function(){ $P.deptControl.defaultFetchSize = FETCH_XS; $P.deptControl.untilPageNum = 0; $P.deptControl.beforeCurrent = null; - $P.deptControl.tableRenderComplete = false; + /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.deptControl.onDatasetChange = (obj) => { - - $P.renderDeptList(obj["Total"]); - - $("#deptPaging--${pageName}").setPagingInfo({ - list: $P.deptControl.dataset, - prefix: "deptPaging--${pageName}", - start: obj["Start"], - totalSize: obj["Total"], - fetchSize: obj["Fetch"], - func: "pageObject['${pageName}'].deptControl.load({index})" - }); - - $P.deptControl.tableRenderComplete = true; + $P.deptControl.dataset.onDatasetChange = (obj) => { + var t = $P.getGridTemplate(); + var trs = Apply.fromDataset.getTbody($P.deptControl.dataset, t.found, t.notFound, t.replacer); + $P.renderCrdnList(obj["Total"], $P.deptControl.dataset.length, trs); + + Apply.fromDataset.paging($P.deptControl.dataset, obj, "deptPaging--${pageName}"); }; - $P.deptControl.onCurrentChange = (item) => { - - if(!$P.deptControl.tableRenderComplete){ - return; - } - - $P.deptControl.tableRenderComplete = false; - if(!item){ - $P.clickDeptList("", true); - } else { - $P.clickDeptList($P.deptControl.getCurrent()["DEPT_CD"], true); - } + $P.deptControl.dataset.onCurrentChange = (dataItem) => { + Apply.fromDataset.currentRow($P.deptControl.dataset, dataItem, $("#deptTbody--${pageName}")[0]); } - $P.deptControl.onSelectionChange = (selected) => { - var deptDS = $P.deptControl.dataset; - var keys = selected.map(e => deptDS.getKey(e)); - - $("#deptTbody--${pageName} input[type='checkbox']").each(function() { - var checkbox = $(this); - checkbox.prop("checked", keys.includes(checkbox.val())); - }); - - $("#btnDel--${pageName}").prop("disabled", keys.length < 1); + $P.deptControl.dataset.onSelectionChange = (selectedArr) => { + Apply.fromDataset.gridCheckbox($P.deptControl.dataset, document.getElementById("deptTbody--${pageName}"), 1, selectedArr); + Apply.fromDataset.gridButton($P.deptControl.dataset, $("#btnDel--${pageName}")[0], selectedArr); }; /************************************************************************** @@ -227,14 +202,15 @@ $(document).ready(function(){ $P.deptControl.setData([]); } + + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var data = formFields.get(); + data.fetchSize = $P.deptControl.defaultFetchSize; - - $P.refreshDeptList = () => { - $P.deptControl.untilPageNum = $P.deptControl.query.pageNum; - $P.deptControl.query.fetchSize = $P.deptControl.defaultFetchSize * $P.deptControl.query.pageNum; - $P.deptControl.load(1); - } - + return data; + } + $P.searchDeptList = () => { $P.deptControl.query = $P.getParams(); $P.deptControl.load(1); @@ -244,16 +220,50 @@ $(document).ready(function(){ $P.deptControl.load($P.deptControl.query.pageNum + 1); } - $P.clickDeptList = (dataKey, auto) => { + $P.refreshDeptList = () => { + $P.deptControl.untilPageNum = $P.deptControl.query.pageNum; + $P.deptControl.query.fetchSize = $P.deptControl.defaultFetchSize * $P.deptControl.query.pageNum; + $P.deptControl.load(1); + } + + $P.getGridTemplate = () => { + var notFound = [document.getElementById("deptNotFound--${pageName}").innerHTML]; + var found = document.getElementById("deptRow--${pageName}").innerHTML; + var replacer = (str, dataItem) => str + .replace(/{onclick}/gi, "pageObject['${pageName}'].clickDeptList('" + dataItem.getValue("DEPT_CD") + "');") + .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickDeptList('" + dataItem.getValue("DEPT_CD") + "');"); + + return { + found : found, + notFound : notFound, + replacer : replacer + }; + } + + $P.renderDeptList = (total, listLength, trs) => { + + var noMore = (total == listLength); + var initScroll = ($P.deptControl.query.pageNum < 2) && ($P.deptControl.untilPageNum == 0); + + $("#table-responsive--${pageName}")[0].changeContent(trs, initScroll, noMore); + + fn_securityModeToggle($("#securityMode--top").is(":checked")); //보안모드 + + if($P.deptControl.untilPageNum != 0){ + $P.deptControl.query.fetchSize = $P.deptControl.defaultFetchSize; + $P.deptControl.query.pageNum = $P.deptControl.untilPageNum; + $P.deptControl.untilPageNum = 0; + } + } + + $P.clickDeptList = (dataKey) => { if(dataKey == ""){ return; } $("#deptTbody--${pageName}").setCurrentRow(dataKey); - if(!auto){ - $P.deptControl.setCurrent(dataKey); - } + Apply.toDataset.current($P.deptControl.dataset, dataKey); } $P.dblclickDeptList = (dataKey) => { @@ -264,7 +274,7 @@ $(document).ready(function(){ ajax.get({ url : $P.deptControl.urls.getInfo, data : params, - success : resp => { + success : (resp) => { dialog.open({ id : "deptInfoDialog", @@ -277,49 +287,14 @@ $(document).ready(function(){ }); } - - $P.renderDeptList = (total) => { - - var deptDS = $P.deptControl.dataset; - var empty = deptDS.empty; - - var found = document.getElementById("deptRow--${pageName}").innerHTML; - var notFound = [document.getElementById("deptNotFound--${pageName}").innerHTML]; - - var replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].clickDeptList('" + dataItem.getValue("DEPT_CD") + "');") - .replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickDeptList('" + dataItem.getValue("DEPT_CD") + "');"); - - var trs = empty ? notFound : deptDS.inStrings(found, replacer); - var noMore = (total == deptDS.length); - var initScroll = ($P.deptControl.query.pageNum < 2) && ($P.deptControl.untilPageNum == 0); - - $("#table-responsive--${pageName}")[0].changeContent(trs.join(), initScroll, noMore); - - fn_securityModeToggle($("#securityMode--top").is(":checked")); //보안모드 - - if($P.deptControl.untilPageNum != 0){ - $P.deptControl.query.fetchSize = $P.deptControl.defaultFetchSize; - $P.deptControl.query.pageNum = $P.deptControl.untilPageNum; - $P.deptControl.untilPageNum = 0; - } - } - - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var data = formFields.get(); - data.fetchSize = $P.deptControl.defaultFetchSize; - - return data; - } - /************************************************************************** * element.on **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $('#btnSearch--${pageName}').on('click', () => $P.searchDeptList()); - + $('#btnAdd--${pageName}').on('click', () => {}); + $('#btnDel--${pageName}').on('click', () => {}); /************************************************************************** * 초기화 diff --git a/src/main/webapp/WEB-INF/jsp/fims/mngt/select-sgg.jsp b/src/main/webapp/WEB-INF/jsp/fims/mngt/select-sgg.jsp index b37232d8..08160c96 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/mngt/select-sgg.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/mngt/select-sgg.jsp @@ -27,7 +27,7 @@ function fnGoToEditSgg(selected){ ajax.get({ url: menuUrl, data : { sggCd : selected }, - success:resp => { + success:(resp) => { $("div[id='innerPage-"+sggMainMenuNum+"']").html(resp); } }); diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01010-main.jsp index c71c972d..ebd06ebe 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01010-main.jsp @@ -96,33 +96,33 @@ $(document).ready(function() { * DatasetControl 이벤트 **************************************************************************/ // Dataset 변경 이벤트 - $P.integrationSearchControl.updataset.onDatasetChange = (obj) => { + $P.integrationSearchControl.upDataset.onDatasetChange = (obj) => { var upActiveTab = $("#upGridTabs--${pageName}").find("button.active").text().trim(); $P.renderList("up", upActiveTab); }; - $P.integrationSearchControl.downdataset.onDatasetChange = (obj) => { + $P.integrationSearchControl.downDataset.onDatasetChange = (obj) => { var downActiveTab = $("#downGridTabs--${pageName}").find("button.active").text().trim(); $P.renderList("down", downActiveTab); }; // 현재 선택 자료 변경 이벤트 - $P.integrationSearchControl.updataset.onCurrentChange = (DI) => { + $P.integrationSearchControl.upDataset.onCurrentChange = (DI) => { if (!DI) return; var key = DI.data.CRDN_ID; $("#upTbody--${pageName}").setCurrentRow(key); }; - $P.integrationSearchControl.downdataset.onCurrentChange = (DI) => { + $P.integrationSearchControl.downDataset.onCurrentChange = (DI) => { if (!DI) return; var key = DI.data.CRDN_ID; $("#downTbody--${pageName}").setCurrentRow(key); }; // 선택(체크) 변경 이벤트 - $P.integrationSearchControl.updataset.onSelectionChange = (selectedArr) => { + $P.integrationSearchControl.upDataset.onSelectionChange = (selectedArr) => { - var DS = $P.integrationSearchControl.updataset; + var DS = $P.integrationSearchControl.upDataset; var keys = selectedArr.map(item => DS.getKey(item)); $("#upTbody--${pageName}").find("input[type='checkbox']").each(function() { @@ -132,9 +132,9 @@ $(document).ready(function() { }; - $P.integrationSearchControl.downdataset.onSelectionChange = (selectedArr) => { + $P.integrationSearchControl.downDataset.onSelectionChange = (selectedArr) => { - var DS = $P.integrationSearchControl.downdataset; + var DS = $P.integrationSearchControl.downDataset; var keys = selectedArr.map(item => DS.getKey(item)); $("#downTbody--${pageName}").find("input[type='checkbox']").each(function() { @@ -154,14 +154,6 @@ $(document).ready(function() { }); - // 검색 조건 파라미터 가져오기 - $P.getParams = () => { - var formFields = new FimsFormFields("#frmSearch--${pageName}"); - var formData = formFields.get(); - - return formData; - } - // 초기화 $P.fnResetAndChangeBiz = (taskSeCd) => { @@ -197,11 +189,19 @@ $(document).ready(function() { $P.fnReset = () => { - $P.integrationSearchControl.updataset.clear(); - $P.integrationSearchControl.downdataset.clear(); + $P.integrationSearchControl.upDataset.clear(); + $P.integrationSearchControl.downDataset.clear(); } + + // 검색 조건 파라미터 가져오기 + $P.getParams = () => { + var formFields = new FimsFormFields("#frmSearch--${pageName}"); + var formData = formFields.get(); + return formData; + } + // 검색 $P.fnSearchList = () => { // 검색조건 @@ -236,12 +236,45 @@ $(document).ready(function() { $("#upGridTabs--${pageName}").find("button").eq(0).addClass("active"); $("#downGridTabs--${pageName}").find("button").not(":eq(0)").removeClass("active"); $("#downGridTabs--${pageName}").find("button").eq(0).addClass("active"); - $P.integrationSearchControl.updataset.clear(); - $P.integrationSearchControl.downdataset.clear(); + $P.integrationSearchControl.upDataset.clear(); + $P.integrationSearchControl.downDataset.clear(); $P.integrationSearchControl.load(); } + // 엑셀 + $P.fnExcel = (updown) => { + + var cellDefs; + + if(updown == "up"){ + if($P.integrationSearchControl.upDataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + cellDefs = getCellDefs($("#upTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)").not(":hidden"), + $($("#row--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(".privacy-mask")); + + $P.integrationSearchControl.query.gridType = "up"; + } else { + if($P.integrationSearchControl.downDataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + cellDefs = getCellDefs($("#downTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)").not(":hidden"), + $($("#row--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(".privacy-mask")); + + $P.integrationSearchControl.query.gridType = "down"; + } + + $P.integrationSearchControl.query.cellDefs = cellDefs; + + $P.integrationSearchControl.download(); + + } + $P.renderList = (updown, tabGroup) => { var tbody = updown == "up" ? "upTbody--${pageName}" : "downTbody--${pageName}"; @@ -250,18 +283,18 @@ $(document).ready(function() { var found = document.getElementById("row--${pageName}").innerHTML; var DS; if(updown == "up"){ - DS = $P.integrationSearchControl.updataset; + DS = $P.integrationSearchControl.upDataset; } else { - DS = $P.integrationSearchControl.downdataset; + DS = $P.integrationSearchControl.downDataset; } var replacer; if(updown == "up"){ replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].integrationSearchControl.updataset.setCurrent('" + dataItem.getValue("CRDN_ID") + "');") + .replace(/{onclick}/gi, "pageObject['${pageName}'].integrationSearchControl.upDataset.setCurrent('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, "pageObject['${pageName}'].getInfo('"+ dataItem.getValue("TASK_SE_CD") +"','" + dataItem.getValue("CRDN_ID") + "');") } else { replacer = (str, dataItem) => str - .replace(/{onclick}/gi, "pageObject['${pageName}'].integrationSearchControl.downdataset.setCurrent('" + dataItem.getValue("CRDN_ID") + "');") + .replace(/{onclick}/gi, "pageObject['${pageName}'].integrationSearchControl.downDataset.setCurrent('" + dataItem.getValue("CRDN_ID") + "');") .replace(/{ondblclick}/gi, "pageObject['${pageName}'].getInfo('"+ dataItem.getValue("TASK_SE_CD") +"','" + dataItem.getValue("CRDN_ID") + "');") } @@ -340,46 +373,13 @@ $(document).ready(function() { }; - // 엑셀 - $P.fnExcel = (updown) => { - - var cellDefs; - - if(updown == "up"){ - if($P.integrationSearchControl.updataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - cellDefs = getCellDefs($("#upTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)").not(":hidden"), - $($("#row--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(".privacy-mask")); - - $P.integrationSearchControl.query.gridType = "up"; - } else { - if($P.integrationSearchControl.downdataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - cellDefs = getCellDefs($("#downTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)").not(":hidden"), - $($("#row--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(".privacy-mask")); - - $P.integrationSearchControl.query.gridType = "down"; - } - - $P.integrationSearchControl.query.cellDefs = cellDefs; - - $P.integrationSearchControl.download(); - - } - //납부자번호 복사 $P.fnCopyPyrNo = (updown) => { var cur; if(updown == "up"){ - cur = $P.integrationSearchControl.updataset.getCurrent(); + cur = $P.integrationSearchControl.upDataset.getCurrent(); } else { - cur = $P.integrationSearchControl.downdataset.getCurrent(); + cur = $P.integrationSearchControl.downDataset.getCurrent(); } if(cur != null){ @@ -393,9 +393,9 @@ $(document).ready(function() { $P.fnManageEtcCn = (updown) => { var cur; if(updown == "up"){ - cur = $P.integrationSearchControl.updataset.getCurrent(); + cur = $P.integrationSearchControl.upDataset.getCurrent(); } else { - cur = $P.integrationSearchControl.downdataset.getCurrent(); + cur = $P.integrationSearchControl.downDataset.getCurrent(); } if(cur.length <= 0){ @@ -408,10 +408,10 @@ $(document).ready(function() { $P.fnInputEtcCn = (updown) => { var cur; if(updown == "up"){ - cur = $P.integrationSearchControl.updataset; + cur = $P.integrationSearchControl.upDataset; } else { - cur = $P.integrationSearchControl.downdataset; + cur = $P.integrationSearchControl.downDataset; } @@ -430,7 +430,7 @@ $(document).ready(function() { ajax.get({ url : url , data : { crdnIds : crdnIds.join(",") } - , success : resp => { + , success : (resp) => { dialog.open({ id : dialogId , title : "특기사항입력-일괄" @@ -454,8 +454,8 @@ $(document).ready(function() { //단속내역서,단속확인서 $P.fnPrintCrdn = () => { - var upDataset = $P.integrationSearchControl.updataset; - var downDataset = $P.integrationSearchControl.downdataset; + var upDataset = $P.integrationSearchControl.upDataset; + var downDataset = $P.integrationSearchControl.downDataset; if((upDataset.length <= 0) && (downDataset.length <= 0)){ dialog.alert("출력할 자료가 없습니다."); @@ -475,7 +475,7 @@ $(document).ready(function() { ajax.get({ url : url , data : { crdnIds : crdnIds.join(",") } - , success : resp => { + , success : (resp) => { dialog.open({ id : dialogId , title : "종합조회-단속내역" @@ -500,7 +500,7 @@ $(document).ready(function() { //교부청구서,채권신고서 $P.fnPrintBill = () => { - var upDataset = $P.integrationSearchControl.updataset; + var upDataset = $P.integrationSearchControl.upDataset; if(upDataset.length <= 0){ dialog.alert("출력할 자료가 없습니다."); @@ -518,7 +518,7 @@ $(document).ready(function() { ajax.get({ url : url , data : { crdnIds : crdnIds.join(",") } - , success : resp => { + , success : (resp) => { dialog.open({ id : dialogId , title : "종합조회-교부청구서,채권신고서" @@ -555,7 +555,7 @@ $(document).ready(function() { //납부확인서 $P.fnPrintRcvmtConfirm = () => { - var downDataset = $P.integrationSearchControl.downdataset; + var downDataset = $P.integrationSearchControl.downDataset; if(downDataset.length <= 0){ dialog.alert("출력할 자료가 없습니다."); @@ -574,7 +574,7 @@ $(document).ready(function() { crdnIds : crdnIds.join(","), globalVariable : {} }, - success : resp => { + success : (resp) => { if(resp.filePath != null && resp.filePath != ""){ var a = document.createElement("a"); a.href = resp.filePath; @@ -591,7 +591,7 @@ $(document).ready(function() { //사전통지서 $P.fnPrintAdvntce = () => { - var upDataset = $P.integrationSearchControl.updataset; + var upDataset = $P.integrationSearchControl.upDataset; if(upDataset.length <= 0){ dialog.alert("출력할 자료가 없습니다."); @@ -609,7 +609,7 @@ $(document).ready(function() { ajax.get({ url : url , data : { crdnIds : crdnIds.join(",") } - , success : resp => { + , success : (resp) => { dialog.open({ id : dialogId , title : "종합조회-사전통지서" @@ -646,7 +646,7 @@ $(document).ready(function() { //고지서 $P.fnPrintNht = () => { - var upDataset = $P.integrationSearchControl.updataset; + var upDataset = $P.integrationSearchControl.upDataset; if(upDataset.length <= 0){ dialog.alert("출력할 자료가 없습니다."); @@ -664,7 +664,7 @@ $(document).ready(function() { ajax.get({ url : url , data : { crdnIds : crdnIds.join(",") } - , success : resp => { + , success : (resp) => { dialog.open({ id : dialogId , title : "종합조회-고지서" @@ -714,7 +714,7 @@ $(document).ready(function() { ajax.get({ url : url , data : params - , success : resp => { + , success : (resp) => { dialog.open({ id : "totalInfoMainDialog" , title : "개별총정보" @@ -730,8 +730,8 @@ $(document).ready(function() { $P.provide = { "getInfo" : function(crdnId){ - var upDataset = $P.integrationSearchControl.updataset; - var downDataset = $P.integrationSearchControl.downdataset; + var upDataset = $P.integrationSearchControl.upDataset; + var downDataset = $P.integrationSearchControl.downDataset; if(upDataset.length > 0){ var info = upDataset.getData(crdnId); @@ -751,8 +751,8 @@ $(document).ready(function() { }, "isAllSameTask" : function(crdnIdArr){ - var upArr = $P.integrationSearchControl.updataset.getDataset(); - var downArr = $P.integrationSearchControl.downdataset.getDataset(); + var upArr = $P.integrationSearchControl.upDataset.getDataset(); + var downArr = $P.integrationSearchControl.downDataset.getDataset(); var unionArr = [...upArr, ...downArr]; var filtered = unionArr.filter(item => crdnIdArr.includes(item.CRDN_ID)); diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01100-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01100-info.jsp index 58c92240..e107330e 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01100-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01100-info.jsp @@ -94,7 +94,7 @@ $(document).ready(function(){ crdnIds : $P.crdnIds.join(","), etcCn : etcCn }, - success : resp => { + success : (resp) => { if(resp.saved){ alert("저장되었습니다."); var dialogId = $("#frmEdit--${pageName}").find("input[name='dialogId']").val(); diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp index 3368003c..ec8230d2 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp @@ -126,7 +126,7 @@ $(document).ready(function(){ data : { crdnIds : $P.crdnIds.join(",") }, - success : resp => { + success : (resp) => { if(resp.filePath != null && resp.filePath != ""){ var a = document.createElement("a"); a.href = resp.filePath; @@ -139,11 +139,8 @@ $(document).ready(function(){ }); } - //버튼 이벤트 - $("#btnPrintCrdnList--${pageName}").on("click", () => $P.fnMakeCrdnListFile() ); - $("#btnPrintCrdnConfirm--${pageName}").on("click", () => $P.fnMakeCrdnConfirmFile() ); - $("#btnExcel--${pageName}").on("click", function(){ - var query = {}; + $P.fnExcelDown = () => { + var query = {}; var cellDefs = getCellDefs($("#theadTr--${pageName} th").not(".dummy-th"), $($("#found--${pageName}")[0].content).find("td").not(".dummy-td")); @@ -154,7 +151,12 @@ $(document).ready(function(){ var queryStr = toQuery(query); document.location.href = wctx.url("/sprt/sprt01/010/list.do") + "?" + queryStr; - }); + } + + //버튼 이벤트 + $("#btnPrintCrdnList--${pageName}").on("click", () => $P.fnMakeCrdnListFile() ); + $("#btnPrintCrdnConfirm--${pageName}").on("click", () => $P.fnMakeCrdnConfirmFile() ); + $("#btnExcel--${pageName}").on("click", () => $P.fnExcelDown()); //첫번째 줄 클릭 $("#tbody--${pageName}").find("tr:eq(0)").click(); diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01120-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01120-info.jsp index 9ad48100..2994c8c8 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01120-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01120-info.jsp @@ -294,7 +294,7 @@ $(document).ready(function(){ data : { crdnIds : $P.crdnIds.join(",") }, - success : resp => { + success : (resp) => { if(resp.filePath != null && resp.filePath != ""){ var a = document.createElement("a"); a.href = resp.filePath; diff --git a/src/main/webapp/WEB-INF/jsp/fims/stat/stat-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stat/stat-main.jsp index 5990db3f..1b0682f0 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stat/stat-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stat/stat-main.jsp @@ -212,9 +212,9 @@ $(document).ready(function(){ }); /************************************************************************** - * DatasetControl.on + * Dataset.on **************************************************************************/ - $P.detailGridControl.onDatasetChange = () => { + $P.detailGridControl.dataset.onDatasetChange = () => { var DS = $P.detailGridControl.dataset; var empty = DS.empty; diff --git a/src/main/webapp/resources/js/base/base-fims.js b/src/main/webapp/resources/js/base/base-fims.js index 63976c59..59c028d7 100644 --- a/src/main/webapp/resources/js/base/base-fims.js +++ b/src/main/webapp/resources/js/base/base-fims.js @@ -462,3 +462,134 @@ class FimsFormFields extends FormFields { return obj; } } + + +const Apply = { + fromDataset : { + gridCheckbox : function(dataset, tbody, colIndex, checkedArr){ + + var keys = checkedArr.map(item => dataset.getKey(item)); + + $(tbody).find("tr").each(function() { + var cb = $(this).find("td").eq(colIndex).find(":checkbox"); + cb.prop("checked", keys.includes(cb.val())); + }); + + }, + gridButton : function(dataset, button, checkedArr){ + var keys = checkedArr.map(item => dataset.getKey(item)); + $(button).prop("disabled", keys.length < 1); + }, + currentRow : function(dataset, dataItem, tbody){ + if(!dataItem){ + return; + } + $(tbody).setCurrentRow(dataset.getKey(dataItem)); + }, + paging : function(dataset, resp, navId){ + + $("#"+navId).setPagingInfo({ + list : dataset, + prefix : navId, + totalSize : resp["Total"] + }); + + }, + getTbody : function(dataset, found, notFound, replacer){ + var empty = dataset.empty; + var trs = empty ? notFound : dataset.inStrings(found, replacer); + return trs.join(); + } + }, + toDataset : { + current : function(dataset, dataKey){ + dataset.setCurrent(dataKey, false); + }, + selection : function(dataset, checkbox, bool){ + + var parentEl = $(checkbox).parent()[0]; + var isTH = parentEl.tagName == "TH" ? true : false; + + if(isTH) { + var dataItems = dataset.getDataset("item"); + for(var i=0; i < dataItems.legnth; i++){ + dataItems[i].select(bool); + } + } else { + var dataItem = dataset.getData(checkbox.value, "item"); + dataItem.select(bool); + } + }, + set : function(dataset, resp){ + dataset._byKeys = {}; + dataset._current = null; + + var data = dataset._getDataItems(resp = resp || {}); + dataset._items = data.items; + dataset._byKeys = data.byKeys; + }, + add : function(dataset, resp){ + if (dataset.empty){ + this.set(dataset, resp); + return; + } + var state = dataset.state; + var data = dataset._getDataItems(resp = resp || {}); + dataset._items = this._items.concat(data.items); + dataset._byKeys = { + ...this._byKeys, + ...data.byKeys + }; + } + }, + fromDatasetControl : { + load : async function(control, pageNum){ + control.query.pageNum = pageNum; + if (!control.query.pageNum){ + control.query.pageNum = 1; + } + ajax.get({ + url:control.urls.load, + data:control.query, + success:(resp) => { + resolve(resp); + } + }); + }, + save : async function(control, info){ + if (!info) { + return; + } + + var item = control.getCurrent("item"); + var create = "added" == item.state; + + ajax.post({ + url:!create ? control.urls.update : control.urls.create, + data:info, + success:(resp) => { + resolve(resp); + } + }); + }, + remove : async function(control, params){ + var selected = control.dataset.getKeys("selected"); + if(selected.length < 1) { + return; + } + + if(!params) { + params = {}; + params[control.prefixed("IDs")] = selected.join(","); + } + + ajax.post({ + url:control.urls.remove, + data:params, + success:(resp) => { + resolve(resp); + } + }); + } + } +}; \ No newline at end of file diff --git a/src/main/webapp/resources/js/fims/crdn/inspection.js b/src/main/webapp/resources/js/fims/crdn/inspection.js index b9243db8..692a9f51 100644 --- a/src/main/webapp/resources/js/fims/crdn/inspection.js +++ b/src/main/webapp/resources/js/fims/crdn/inspection.js @@ -1,11 +1,3 @@ -class InspectionControl { - constructor(mainConf, subConf) { - this.main = new DatasetControl(mainConf); - this.sub = new DatasetControl(subConf); - } - -} - function fnMakeImgTagForInspection(url, title, crdnPhotoId, mosaic) { return `
diff --git a/src/main/webapp/resources/js/fims/framework/cmm/cmmnUtil.js b/src/main/webapp/resources/js/fims/framework/cmm/cmmnUtil.js index de85fb41..1a27dc20 100644 --- a/src/main/webapp/resources/js/fims/framework/cmm/cmmnUtil.js +++ b/src/main/webapp/resources/js/fims/framework/cmm/cmmnUtil.js @@ -165,4 +165,66 @@ function fnJsonToFormData(originalJson, arrayName){ return {...originalJson, ...newObj}; } -} \ No newline at end of file +} + +const GRID = { + checkbox : { + sync : function(checkboxElement, bool){ + var parentEl = $(checkboxElement).parent()[0]; + var isTH = parentEl.tagName == "TH" ? true : false; + var tr = $(checkboxElement).parents("tr"); + var siblingTag = isTH ? "TH" : "TD"; + var siblings = tr.find(siblingTag); + var checkboxColIndex = siblings.index(parentEl); + + var table = $(checkboxElement).parents("table"); + var thead = table.find("thead"); + var tbody = table.find("tbody"); + var trs = tbody.find("tr"); + + if(isTH) { + + trs.each(function(){ + $(this).find("td").eq(checkboxColIndex).find(":checkbox").prop("checked", bool); + }); + + } else { + var countCheck = 0; + var countUncheck = 0; + + trs.each(function(){ + var cb = $(this).find("td").eq(checkboxColIndex).find(":checkbox"); + if(cb.length > 0){ + cb.is(":checked") ? countCheck++ : countUncheck++; + } + }); + + if((countCheck == 0 && countUncheck != 0) || (countCheck != 0 && countUncheck == 0)){ + thead.find(":checkbox").prop("checked", bool); + } + + } + }, + countChecked : function(checkboxElement){ + var parentEl = $(checkboxElement).parent()[0]; + var tr = $(checkboxElement).parents("tr"); + var siblings = tr.find("TD"); + var checkboxColIndex = siblings.index(parentEl); + + var table = $(checkboxElement).parents("table"); + var tbody = table.find("tbody"); + var trs = tbody.find("tr"); + + var count = 0; + trs.each(function(){ + var cb = $(this).find("td").eq(checkboxColIndex).find(":checkbox"); + if(cb.length > 0){ + if(cb.is(":checked")) { + count++; + } + } + }); + return count; + } + } +}; diff --git a/src/main/webapp/resources/js/fims/photo-main.js b/src/main/webapp/resources/js/fims/photo-main.js index 5701c2b3..4838f56b 100644 --- a/src/main/webapp/resources/js/fims/photo-main.js +++ b/src/main/webapp/resources/js/fims/photo-main.js @@ -248,7 +248,7 @@ function settingPhotoMain(pageName, crdnIdElementId, carInfoFunc, carLinkFunc){ ajax.post({ url : fileProcessingURL, data : formData, contentType : false, processData : false, - success : resp => { + success : (resp) => { if(resp.saved){ var crdnId = $("#"+crdnIdElementId).val(); diff --git a/src/main/webapp/resources/js/fims/sprt/integrationSearch.js b/src/main/webapp/resources/js/fims/sprt/integrationSearch.js index 94197a6d..aae252a1 100644 --- a/src/main/webapp/resources/js/fims/sprt/integrationSearch.js +++ b/src/main/webapp/resources/js/fims/sprt/integrationSearch.js @@ -2,8 +2,8 @@ class IntegrationSearchControl extends DatasetControl { constructor(conf) { super(conf); - this.updataset = new Dataset(conf); - this.downdataset = new Dataset(conf); + this.upDataset = new Dataset(conf); + this.downDataset = new Dataset(conf); } @@ -18,15 +18,15 @@ class IntegrationSearchControl extends DatasetControl { ajax.get({ url:this.urls.load, data:this.query, - success:resp => { + success:(resp) => { this.setData(resp); } }); } setData(obj) { - this.updataset.setData(obj.upList); - this.downdataset.setData(obj.downList); + this.upDataset.setData(obj.upList); + this.downDataset.setData(obj.downList); } } \ No newline at end of file