화면 main 수정.

검색 list 수정.
main
jjh 1 year ago
parent 26f4e9bc46
commit b48d61c8af

@ -41,22 +41,17 @@ public class Excl01Controller extends ApplicationController {
*/
@RequestMapping(name = "부과제외 관리 메인", value = "/010/main.do")
public ModelAndView levyExclusionMain() {
ModelAndView mav = getLevyExclusionList(new Excl01Query().setPageNum(1));
// View(jsp)
mav.setViewName("fims/excl/excl01010-main");
ModelAndView mav = new ModelAndView("fims/excl/excl01010-main");
// View(jsp)에서 사용할 공통코드를 조회
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM021", "FIM054");
mav.addObject("FIM021List", commonCodes.get("FIM021")); // 부과 제외 구분 코드(LEVY_EXCL_SE_CD)
mav.addObject("FIM054List", commonCodes.get("FIM054")); // 업무 구분 코드(TASK_SE_CD)
addCodes(commonCodes, mav, "FIM021", "FIM054");
// View(jsp)에서 사용할 id 뒤에 붙일 suffix
mav.addObject("pageName", "excl01010");
return mav;
return mav.addObject("pageName", "excl01010") // View(jsp)에서 사용할 id 뒤에 붙일 suffix
.addObject("urlPrefix", "/excl/excl01") // URL로 사용할 prefix
.addObject("infoPrefix", "levyExcl") // prefix
.addObject("FIM021List", commonCodes.get("FIM021")) // 부과 제외 구분 코드(LEVY_EXCL_SE_CD)
.addObject("FIM054List", commonCodes.get("FIM054")) // 업무 구분 코드(TASK_SE_CD)
;
}
/** .<br />
@ -144,4 +139,4 @@ public class Excl01Controller extends ApplicationController {
.addObject("saved", saved);
}
}
}

@ -41,22 +41,17 @@ public class Excl02Controller extends ApplicationController {
*/
@RequestMapping(name = "의견제출 관리 메인", value = "/010/main.do")
public ModelAndView opinionSubmissionMain() {
ModelAndView mav = getOpinionSubmissionList(new Excl02Query().setPageNum(1));
// View(jsp)
mav.setViewName("fims/excl/excl02010-main");
ModelAndView mav = new ModelAndView("fims/excl/excl02010-main");
// View(jsp)에서 사용할 공통코드를 조회
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM031", "FIM054");
mav.addObject("FIM031List", commonCodes.get("FIM031")); // 의견 제출 답변 결과(OPNN_SBMSN_STTS_CD)
mav.addObject("FIM054List", commonCodes.get("FIM054")); // 업무 구분 코드(TASK_SE_CD)
addCodes(commonCodes, mav, "FIM031", "FIM054");
// View(jsp)에서 사용할 id 뒤에 붙일 suffix
mav.addObject("pageName", "excl02010");
return mav;
return mav.addObject("pageName", "excl02010") // View(jsp)에서 사용할 id 뒤에 붙일 suffix
.addObject("urlPrefix", "/excl/excl02") // URL로 사용할 prefix
.addObject("infoPrefix", "opnnSbmsn") // prefix
.addObject("FIM031List", commonCodes.get("FIM031")) // 부과 제외 구분 코드(LEVY_EXCL_SE_CD)
.addObject("FIM054List", commonCodes.get("FIM054")) // 업무 구분 코드(TASK_SE_CD)
;
}
/** .<br />

@ -41,21 +41,16 @@ public class Excl03Controller extends ApplicationController {
*/
@RequestMapping(name = "단속 재등록 메인", value = "/010/main.do")
public ModelAndView crackdownReRegistrationMain() {
ModelAndView mav = getCrackdownReRegistrationList(new Excl03Query().setPageNum(1));
// View(jsp)
mav.setViewName("fims/excl/excl03010-main");
ModelAndView mav = new ModelAndView("fims/excl/excl03010-main");
// View(jsp)에서 사용할 공통코드를 조회
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM054");
mav.addObject("FIM054List", commonCodes.get("FIM054")); // 업무 구분 코드(TASK_SE_CD)
addCodes(commonCodes, mav, "FIM054");
// View(jsp)에서 사용할 id 뒤에 붙일 suffix
mav.addObject("pageName", "excl03010");
return mav;
return mav.addObject("pageName", "excl03010") // View(jsp)에서 사용할 id 뒤에 붙일 suffix
.addObject("urlPrefix", "/excl/excl03") // URL로 사용할 prefix
.addObject("infoPrefix", "crdnRe") // prefix
.addObject("FIM054List", commonCodes.get("FIM054")) // 업무 구분 코드(TASK_SE_CD)
;
}
/** .<br />

@ -150,14 +150,16 @@
<span class="container-page-btn">
<!-- 건수, 페이지 표시 -->
<div class="d-flex flex-row justify-content-between">
<label id="paging--${pageName}PagingInfo" class="dataTables_info" role="status" aria-live="polite"></label>
<ul id="paging--${pageName}" class="pagination pagination-primary">
<label class="dataTables_info" id="paging--${pageName}PagingInfo" role="status" aria-live="polite"></label>
<ul class="pagination pagination-primary" id="paging--${pageName}">
</ul>
</div>
<span class="container-window-btn-right">
<!-- 업무 버튼 -->
<a href="#" class="btn btn-blue" id="" title="업무처리1">업무 처리1</a>
<a href="#" class="btn btn-blue" id="" title="업무처리2">업무 처리2</a>
<a href="#" class="btn btn-blue" id="btnNotLevyCreate--${pageName}" title="비부과 등록">비부과 등록</a>
<a href="#" class="btn btn-blue" id="btnWarningCreate--${pageName}" title="계고 등록">계고 등록</a>
<a href="#" class="btn btn-blue" id="btnUpdate--${pageName}" title="수정">수정</a>
<a href="#" class="btn btn-blue" id="btnRemove--${pageName}" title="삭제">삭제</a>
</span>
</span>
</div>
@ -194,7 +196,7 @@
</thead>
<tbody id="tbody--${pageName}">
</tbody>
<template id="${infoPrefix}Row">
<template id="${infoPrefix}Row--${pageName}">
<tr data-key="{LEVY_EXCL_ID}">
<td style="text-align:center;" {onclick} {ondblclick}>{ROW_NUM}</td>
<td style="text-align:center;">
@ -217,7 +219,7 @@
<td style="text-align:center;" {onclick} {ondblclick}>{MDFR}</td>
</tr>
</template>
<template id="${infoPrefix}NotFound">
<template id="${infoPrefix}NotFound--${pageName}">
<tr class="odd">
<td valign="top" colspan="14" class="dataTables_empty text-center">${prefixName} 정보를 찾지 못했습니다.</td>
</tr>
@ -249,20 +251,7 @@
* Global Variable
**************************************************************************/
// Control 생성
var ${pageName}Control = new LevyExclControl();
// 공통코드
var FIM021 = new CommonCodes(${FIM021});
var FIM054 = new CommonCodes(${FIM054});
// script 진입
$(document).ready(function() {
// 검색조건 초기값 셋팅
initSearch${pageName}();
// 이벤트
setEvent${pageName}();
});
var ${pageName}Control = new LevyExclControl("${urlPrefix}");
/**************************************************************************
* 초기 셋팅
@ -281,10 +270,17 @@
//
function setEvent${pageName}() {
// 검색 버튼 이벤트
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}());
// 테이블 스크롤 이벤트
// 버튼 이벤트
$("#btnReset--${pageName}").on("click", () => searchList${pageName}()); // 초기화
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}()); // 검색
$("#btnExcle--${pageName}").on("click", () => searchList${pageName}()); // 엑셀
$("#btnNotLevyCreate--${pageName}").on("click", () => searchList${pageName}()); // 비부과 등록
$("#btnWarningCreate--${pageName}").on("click", () => searchList${pageName}()); // 계고 등록
$("#btnUpdate--${pageName}").on("click", () => searchList${pageName}()); // 수정
$("#btnRemove--${pageName}").on("click", () => searchList${pageName}()); // 삭제
$("#term--${pageName}").onEnterPress(() => searchList${pageName}()); // 동적 검색
// DataTables 스크롤 이벤트
$("#table-responsive--${pageName}").scroll(function() {
let el = $(this);
@ -299,6 +295,24 @@
/**************************************************************************
* Event
**************************************************************************/
// DataTables에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("LEVY_EXCL_ID") + '\');"')
.replace(/{ondblclick}/gi, 'ondblclick="${pageName}Control.getInfo(\'' + 'levyExclId=' + dataItem.getValue("LEVY_EXCL_ID") + '\')"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// Dataset 변경
${pageName}Control.onDatasetChange = obj => {
renderList${pageName}();
@ -337,55 +351,48 @@
// $("#btnRemove${infoPrefix}s").prop("disabled", keys.length < 1);
};
//
$("#term").onEnterPress(searchList${pageName}());
/**************************************************************************
*
* function
**************************************************************************/
// 검색조건 파라미터 가져오기
function getParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let data = formFields.get();
data.sggCd = "41480"; // 시군구 코드 임시
data.fetchSize = 30; // 한번에 30건씩 조회
return data;
}
// 검색
function searchList${pageName}(pageNumber) {
// pageNumber 값 확인
if (!pageNumber) pageNumber = 1;
${pageName}Control.query = getParams${pageName}(); // 검색조건
${pageName}Control.query = fnGetParams${pageName}(); // 검색조건
${pageName}Control.query.orderBy = "LEVY_EXCL_ID"; // 정렬
${pageName}Control.load(pageNumber);
}
// 테이블에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("{LEVY_EXCL_ID}") + '\');"')
.replace(/{ondblclick}/gi, 'ondblclick="${pageName}Control.getInfo(\'' + dataItem.getValue("{LEVY_EXCL_ID}") + '\')"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// 업무구분 변경
function fnResetAndChangeBiz(taskSeCd) {
$("tbody--${pageName}").html("");
}
// 검색 조건 파라미터 가져오기
function fnGetParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let formData = formFields.get();
formData.sggCd = "41480"; // 시군구 코드 임시
formData.fetchSize = 30; // 한번에 30건씩 조회
return formData;
}
/**************************************************************************
* script 진입
**************************************************************************/
$(document).ready(function() {
// 검색조건 초기값 설정
initSearch${pageName}();
// 이벤트 설정
setEvent${pageName}();
${pageName}Control.addData(${levyExcl});
});
// #sourceURL=excl01010-main.jsp
</script>

@ -151,8 +151,8 @@
<span class="container-page-btn">
<!-- 건수, 페이지 표시 -->
<div class="d-flex flex-row justify-content-between">
<label id="paging--${pageName}PagingInfo" class="dataTables_info" role="status" aria-live="polite"></label>
<ul id="paging--${pageName}" class="pagination pagination-primary">
<label class="dataTables_info" id="paging--${pageName}PagingInfo" role="status" aria-live="polite"></label>
<ul class="pagination pagination-primary" id="paging--${pageName}">
</ul>
</div>
<span class="container-window-btn-right">
@ -198,7 +198,7 @@
</thead>
<tbody id="tbody--${pageName}">
</tbody>
<template id="${infoPrefix}Row">
<template id="${infoPrefix}Row--${pageName}">
<tr data-key="{OPNN_ID}">
<td style="text-align:center;" {onclick} {ondblclick}>{ROW_NUM}</td>
<td style="text-align:center;">
@ -224,7 +224,7 @@
<td style="text-align:center;" {onclick} {ondblclick}>{MDFR}</td>
</tr>
</template>
<template id="${infoPrefix}NotFound">
<template id="${infoPrefix}NotFound--${pageName}">
<tr class="odd">
<td valign="top" colspan="14" class="dataTables_empty text-center">${prefixName} 정보를 찾지 못했습니다.</td>
</tr>
@ -256,21 +256,7 @@
* Global Variable
**************************************************************************/
// Control 생성
var ${pageName}Control = new OpnnSbmsnControl();
// 공통코드
var FIM031 = new CommonCodes(${FIM031});
var FIM054 = new CommonCodes(${FIM054});
// script 진입
$(document).ready(function() {
// 검색조건 초기값 셋팅
initSearch${pageName}();
// 이벤트
setEvent${pageName}();
});
var ${pageName}Control = new OpnnSbmsnControl("${urlPrefix}");
/**************************************************************************
* 초기 셋팅
@ -289,8 +275,9 @@
//
function setEvent${pageName}() {
// 검색 버튼 이벤트
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}());
// 버튼 이벤트
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}()); // 검색
$("#term--${pageName}").onEnterPress(() => searchList${pageName}()); // 동적 검색
// DataTables 스크롤 이벤트
$("#table-responsive--${pageName}").scroll(function() {
@ -298,8 +285,6 @@
if (el.scrollTop() == 0) return;
if (dataItem.getValue("{ROW_NUMBER}") >= dataItem.getValue("{TOT_CNT}") ) return;
if ((el[0].scrollHeight - el.scrollTop() + 15) == el.outerHeight()) {
searchList${pageName}(${pageName}Control.query.pageNum + 1);
}
@ -309,6 +294,24 @@
/**************************************************************************
* Event
**************************************************************************/
// DataTables에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("OPNN_ID") + '\');"')
.replace(/{ondblclick}/gi, 'ondblclick="${pageName}Control.getInfo(\'' + 'opnnId=' + dataItem.getValue("OPNN_ID") + '\')"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// Dataset 변경
${pageName}Control.onDatasetChange = obj => {
renderList${pageName}();
@ -347,55 +350,48 @@
// $("#btnRemove${infoPrefix}s").prop("disabled", keys.length < 1);
};
//
$("#term").onEnterPress(searchList${pageName}());
/**************************************************************************
*
* function
**************************************************************************/
// 검색조건 파라미터 가져오기
function getParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let data = formFields.get();
data.sggCd = "41480"; // 시군구 코드 임시
data.fetchSize = 30; // 한번에 30건씩 조회
return data;
}
// 검색
function searchList${pageName}(pageNumber) {
// pageNumber 값 확인
if (!pageNumber) pageNumber = 1;
${pageName}Control.query = getParams${pageName}(); // 검색조건
${pageName}Control.query = fnGetParams${pageName}(); // 검색조건
${pageName}Control.query.orderBy = "OPNN_ID"; // 정렬
${pageName}Control.load(pageNumber);
}
// DataTables에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("{OPNN_ID}") + '\');"')
.replace(/{ondblclick}/gi, 'ondblclick="${pageName}Control.getInfo(\'' + dataItem.getValue("{OPNN_ID}") + '\')"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// 업무구분 변경
function fnResetAndChangeBiz(taskSeCd) {
$("tbody--${pageName}").html("");
}
// 검색 조건 파라미터 가져오기
function fnGetParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let formData = formFields.get();
formData.sggCd = "41480"; // 시군구 코드 임시
formData.fetchSize = 30; // 한번에 30건씩 조회
return formData;
}
/**************************************************************************
* script 진입
**************************************************************************/
$(document).ready(function() {
// 검색조건 초기값 설정
initSearch${pageName}();
// 이벤트 설정
setEvent${pageName}();
${pageName}Control.addData(${opnnSbmsn});
});
// #sourceURL=excl02010-main.jsp
</script>

@ -112,8 +112,8 @@
<span class="container-page-btn">
<!-- 건수, 페이지 표시 -->
<div class="d-flex flex-row justify-content-between">
<label id="paging--${pageName}PagingInfo" class="dataTables_info" role="status" aria-live="polite"></label>
<ul id="paging--${pageName}" class="pagination pagination-primary">
<label class="dataTables_info" id="paging--${pageName}PagingInfo" role="status" aria-live="polite"></label>
<ul class="pagination pagination-primary" id="paging--${pageName}">
</ul>
</div>
<span class="container-window-btn-right">
@ -150,7 +150,7 @@
</thead>
<tbody id="tbody--${pageName}">
</tbody>
<template id="${infoPrefix}Row">
<template id="${infoPrefix}Row--${pageName}">
<tr data-key="{RE_REG_ID}">
<td style="text-align:center;" {onclick} {ondblclick}>{ROW_NUM}</td>
<td style="text-align:center;">
@ -168,7 +168,7 @@
<td style="text-align:center;" {onclick} {ondblclick}>{RGTR}</td>
</tr>
</template>
<template id="${infoPrefix}NotFound">
<template id="${infoPrefix}NotFound--${pageName}">
<tr class="odd">
<td valign="top" colspan="14" class="dataTables_empty text-center">${prefixName} 정보를 찾지 못했습니다.</td>
</tr>
@ -200,19 +200,7 @@
* Global Variable
**************************************************************************/
// Control 생성
var ${pageName}Control = new CrdnReControl();
// 공통코드
var FIM054 = new CommonCodes(${FIM054});
// script 진입
$(document).ready(function() {
// 검색조건 초기값 셋팅
initSearch${pageName}();
// 이벤트
setEvent${pageName}();
});
var ${pageName}Control = new CrdnReControl("${urlPrefix}");
/**************************************************************************
* 초기 셋팅
@ -231,10 +219,11 @@
//
function setEvent${pageName}() {
// 검색 버튼 이벤트
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}());
// 버튼 이벤트
$("#btnSearch--${pageName}").on("click", () => searchList${pageName}()); // 검색
$("#term--${pageName}").onEnterPress(() => searchList${pageName}()); // 동적 검색
// 테이블 스크롤 이벤트
// DataTables 스크롤 이벤트
$("#table-responsive--${pageName}").scroll(function() {
let el = $(this);
@ -249,6 +238,23 @@
/**************************************************************************
* Event
**************************************************************************/
// DataTables에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("RE_REG_ID") + '\');"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// Dataset 변경
${pageName}Control.onDatasetChange = obj => {
renderList${pageName}();
@ -287,55 +293,48 @@
// $("#btnRemove${infoPrefix}s").prop("disabled", keys.length < 1);
};
//
$("#term").onEnterPress(searchList${pageName}());
/**************************************************************************
*
* function
**************************************************************************/
// 검색조건 파라미터 가져오기
function getParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let data = formFields.get();
data.sggCd = "41480"; // 시군구 코드 임시
data.fetchSize = 30; // 한번에 30건씩 조회
return data;
}
// 검색
function searchList${pageName}(pageNumber) {
// pageNumber 값 확인
if (!pageNumber) pageNumber = 1;
${pageName}Control.query = getParams${pageName}(); // 검색조건
${pageName}Control.query = fnGetParams${pageName}(); // 검색조건
${pageName}Control.query.orderBy = "RE_REG_ID"; // 정렬
${pageName}Control.load(pageNumber);
}
// 테이블에 click, dbclick 이벤트
function renderList${pageName}() {
let ${infoPrefix}List = ${pageName}Control.dataset;
let empty = ${infoPrefix}List.empty;
let trs = empty ?
[document.getElementById("${infoPrefix}NotFound").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}/gi, 'onclick="${pageName}Control.setCurrent(\'' + dataItem.getValue("{RE_REG_ID}") + '\');"')
.replace(/{ondblclick}/gi, 'ondblclick="${pageName}Control.getInfo(\'' + dataItem.getValue("{RE_REG_ID}") + '\')"')
);
$("#tbody--${pageName}").html(trs.join());
$("th input[type='checkbox']").prop("checked", false);
}
// 업무구분 변경
function fnResetAndChangeBiz(taskSeCd) {
$("tbody--${pageName}").html("");
}
// 검색 조건 파라미터 가져오기
function fnGetParams${pageName}() {
let formFields = new FimsFormFields("#frmSearch--${pageName}");
let formData = formFields.get();
formData.sggCd = "41480"; // 시군구 코드 임시
formData.fetchSize = 30; // 한번에 30건씩 조회
return formData;
}
/**************************************************************************
* script 진입
**************************************************************************/
$(document).ready(function() {
// 검색조건 초기값 설정
initSearch${pageName}();
// 이벤트 설정
setEvent${pageName}();
${pageName}Control.addData(${crdnRe});
});
// #sourceURL=excl03010-main.jsp
</script>

@ -1,6 +1,6 @@
/* Copyright (c) 2020 Emjay Khan. All rights reserved. */
/**@file Classes and objects to help control user data in HTML pages
/**@file Classes and objects to help control user data in HTML pages
*/
function lpad(v) {
@ -26,7 +26,7 @@ const numberFormat = {
}
},
/**Formats the value
/**Formats the value
* @param {number} value value to format
* @returns {string} formatted value
*/
@ -38,13 +38,13 @@ const numberFormat = {
/** value format for dates */
const dateFormat = {
/**Formats the value
/**Formats the value
* @param {number} value value to format
* @returns {string} formatted value
*/
format(value) {
if (isEmpty(value)) return "";
let _format = v => {
let date = "number" == typeof v ? new Date(v) : v;
let year = date.getFullYear(),
@ -52,7 +52,7 @@ const dateFormat = {
day = lpad(date.getDate());
return year + "-" + month + "-" + day;
};
switch (value instanceof Date ? "date" : typeof value) {
case "number":
case "date": return _format(value);
@ -64,7 +64,7 @@ const dateFormat = {
/** value format for time */
const timeFormat = {
/**Formats the value
/**Formats the value
* @param {number} value value to format
* @returns {string} formatted value
*/
@ -76,7 +76,7 @@ const timeFormat = {
seconds = lpad(date.getSeconds());
return hours + ":" + minutes + ":" + seconds;
};
switch (value instanceof Date ? "date" : typeof value) {
case "number":
case "date": return _format(value);
@ -90,7 +90,7 @@ const timeFormat = {
/** value format for datetimes */
const datetimeFormat = {
/**Formats the value
/**Formats the value
* @param {number} value value to format
* @returns {string} formatted value
*/
@ -114,8 +114,8 @@ const datetimeFormat = {
* key0: numberFormat,
* key1: dateFormat,
* key2: {
* format(value) {...},
* parse(value) {...}
* format(value) {...},
* parse(value) {...}
* }
* })</code></pre>
*/
@ -137,24 +137,24 @@ class ValueFormat {
* <ul> <li>parser associated with the key</li>
* <li>if not found for the key, default parser</li>
* </ul>
*/
*/
parser(key) {
let parser = this._formats[key];
return parser && parser.parse ? parser.parse : ValueFormat.Default.parse;
}
/**Returns a formatter associated with the key.
* @param {string} key key associated with a value format
* @returns {function}
* <ul> <li>formatter associated with the key</li>
* <li>if not found for the key, default formatter</li>
* </ul>
*/
*/
formatter(key) {
let formatter = this._formats[key];
return formatter && formatter.format ? formatter.format : ValueFormat.Default.format;
}
regexp(key) {
let expr = this._exprs[key];
if (!expr)
@ -172,7 +172,7 @@ ValueFormat.Default = {
/** Represents an invalid value. */
ValueFormat.InvalidValue = "^invalid^value^";
/**Wraps a user data and traces the manipulation performed on it and consequent status.
/**Wraps a user data and traces the manipulation performed on it and consequent status.
*/
class DataItem {
/** user data */
@ -183,7 +183,7 @@ class DataItem {
selected;
/** state of the user data */
state;
/**Creates a new DataItem.
* @param {any} data user data
* @param {object} formats value formatters of the user data's property
@ -273,7 +273,7 @@ class DataItem {
/**Returns a string converted from the template using the property values of the user data.
* In the template, placeholder for the properties of the user data is specified like {property name}.
* @param {string} template template string
* @param {function} formatter function to format a row string with custom property placeholders
* @param {function} formatter function to format a row string with custom property placeholders
* @returns {string} string converted from the template using the property values of the user data
*/
inString(template, formatter) {
@ -291,7 +291,7 @@ class DataItem {
/**Manages user data wrapped in {@link DataItem}s, tracing the state after manipulation performed on them.
* <p>For a Dataset to work properly, it needs a keymapper to identify user data.
* And you specify it in a Dataset's configuration.
* And you specify it in a Dataset's configuration.
* <pre><code>let dataset = new Dataset({
* keymapper: function(info) {return info.keyProperty;},
* ...
@ -338,12 +338,12 @@ class Dataset {
_items;
_byKeys;
_current;
/**Dataset configuration
*/
conf;
_formats;
/**Creates a new Dataset with a configuration.
* The configuration is an object with which you specify
* <ul> <li>keymapper - function that returns a key of a user data. Used to identify user data in the Dataset. Mandatory.</li>
@ -359,21 +359,21 @@ class Dataset {
* <li>{@link Dataset#onRemove onRemove}</li>
* <li>{@link Dataset#onErase onErase}</li>
* <li>{@link Dataset#onDirtiesChange onDirtiesChange}</li>
* </ul>
* </ul>
* </li>
* <li>trace - true to enable message logging</li>
* </ul>
* </ul>
* @param conf {object} configuration
*/
constructor(conf) {
this._items = [];
this._byKeys = {};
this._current = null;
this.conf = notEmpty(conf, "conf is required but missing");
notEmpty(conf.keymapper, "keymapper is required but missing");
this._formats = new ValueFormat(conf.formats);
if (!conf.trace)
this.log = () => {};
@ -428,12 +428,12 @@ class Dataset {
* let added = dirties.added;
* let modified = dirties.modified;
* let removed = dirties.removed;
*/
*/
getKeys(status){
let dataset = this.getDataset(status);
if ("dirty" != status)
return dataset.map(e => this.getKey(e));
let result = {};
for (let prop in dataset) {
result[prop] = dataset[prop].map(e => this.getKey(e));
@ -474,7 +474,7 @@ class Dataset {
let state = this.state;
this._byKeys = {};
this._current = null;
let data = this._getDataItems(obj = obj || {});
this._items = data.items;
this._byKeys = data.byKeys;
@ -483,7 +483,7 @@ class Dataset {
let array = Array.isArray(obj) ? obj : this.conf.dataGetter(obj) || [];
if (!Array.isArray(array))
throw new Error("The data must be an array");
this._items = array.map(e => new DataItem(e, this._formats));
this._items.forEach(item => {
let key = "key-" + this.getKey(item.data);
@ -493,28 +493,28 @@ class Dataset {
this.onDatasetChange(obj);
this.setState(!Array.isArray(obj) ? obj.state : state);
this.onDirtiesChange(this.dirty);
return this;
}
_getDataItems(obj) {
let array = Array.isArray(obj) ? obj : this.conf.dataGetter(obj) || [];
if (!Array.isArray(array))
throw new Error("The data must be an array");
let _items = array.map(e => new DataItem(e, this._formats)),
_byKeys = {};
_items.forEach(item => {
let key = "key-" + this.getKey(item.data);
_byKeys[key] = item;
});
return {
items: _items,
byKeys: _byKeys
};
}
/**Adds user data to the Dataset.
* To get user data from an object, the dataGetter configured is called.
* After user data is set, the methods
@ -530,7 +530,7 @@ class Dataset {
addData(obj) {
if (this.empty)
return this.setData(obj);
let state = this.state;
let data = this._getDataItems(obj = obj || {});
this._items = this._items.concat(data.items);
@ -538,17 +538,17 @@ class Dataset {
...this._byKeys,
...data.byKeys
};
this.onDatasetChange(obj);
this.setState(!Array.isArray(obj) ? obj.state : state);
this.onDirtiesChange(this.dirty);
return this;
}
/**Clears the Dataset's user data.
* @returns {Dataset} the Dataset
* @returns {Dataset} the Dataset
*/
clear() {
this.setData(null);
@ -588,7 +588,7 @@ class Dataset {
/**Sets the user data as current that is associated with the key.
* @param {string} key key to a user data
* After the data is set, the method
* After the data is set, the method
* <ul> <li>{@link Dataset#onCurrentChange}</li>
* </ul>
* is called back.
@ -621,7 +621,7 @@ class Dataset {
}
/**Sets the state to the Dataset.
* After the state is set, the methods
* After the state is set, the methods
* <ul> <li>{@link Dataset#onCurrentChange}</li>
* <li>{@link Dataset#onSelectionChange}</li>
* </ul>
@ -719,7 +719,7 @@ class Dataset {
}
if ("item" == option)
return result;
let getData = item => item.data;
if ("dirty" != status)
return "item" == option ? result : result.map(e => getData(e));
@ -818,13 +818,13 @@ class Dataset {
*/
append(data) {
if (!data) return this;
let notDirty = !this.dirty,
array = Array.isArray(data) ? data : [data];
array.forEach(e => {
let item = new DataItem(e, this._formats);
this._items.push(item);
let key = this.getKey(e);
this._byKeys["key-" + key] = item;
item.state = "added";
@ -834,10 +834,10 @@ class Dataset {
this.onAppend(array);
state.currentKey = this.getKey(array[array.length - 1]);
this.setState(state);
if (notDirty)
this.onDirtiesChange(true);
return this;
};
@ -865,11 +865,11 @@ class Dataset {
*/
modify(key, modifier) {
if (!modifier) return this;
let item = this.getData(key, "item");
if (!item)
return log("Item not found with " + key);
let notDirty = !this.dirty,
data = item.data,
prev = Object.assign({}, data),
@ -883,11 +883,11 @@ class Dataset {
}
return changed;
};
let current = data == this.getCurrent(),
revert = modifier(item) == ValueFormat.InvalidValue,
changed = modifiedProps(prev, data);
if (changed.length > 0) {
if (!item.state)
item.state = "modified";
@ -931,30 +931,30 @@ class Dataset {
*/
replace(replacement) {
if (isEmpty(replacement)) return this;
let before = this.dirty,
replacements = Array.isArray(replacement) ? replacement : [replacement],
replacing = [];
replacements.forEach(obj => {
let data = obj.data;
if (!data) return;
let key = obj.key || this.getKey(data);
if (!key) return;
let oldItem = this.getData(key, "item"),
newItem = new DataItem(data, this._formats),
pos = oldItem ? this._items.indexOf(oldItem) : -1;
newItem.selected = oldItem && oldItem.selected;
newItem.selected = oldItem && oldItem.selected;
if (pos > -1)
this._items[pos] = newItem;
else
this._items.push(newItem);
delete this._byKeys["key-" + key];
this._byKeys["key-" + this.getKey(data)] = newItem;
if (this._current == oldItem)
this._current = newItem;
@ -984,7 +984,7 @@ class Dataset {
*/
remove(key) {
if (!key || this.empty) return this;
let before = this.dirty,
keys = Array.isArray(key) ? key : [key],
removed = this._items.filter(item => {
@ -997,13 +997,13 @@ class Dataset {
}),
currentPos = this._items.indexOf(this._current),
state = this.state;
if (currentPos > -1) {
let newKey = null;
for (let i = currentPos, length = this._items.length; i < length; ++i) {
let item = this._items[i];
if (item.unreachable) continue;
newKey = this.getKey(item);
break;
}
@ -1011,7 +1011,7 @@ class Dataset {
for (let i = this._items.length - 1; i > 0; --i) {
let item = this._items[i];
if (item.unreachable) continue;
newKey = this.getKey(item);
break;
}
@ -1022,7 +1022,7 @@ class Dataset {
let after = this.dirty;
if (before != after)
this.onDirtiesChange(after);
return this;
}
@ -1035,7 +1035,7 @@ class Dataset {
* </ul>
* are called.
* Note that unlike {@link Dataset#remove} this method deletes user data completely from the Dataset
* and the erased user data are not traced as dirty user data.
* and the erased user data are not traced as dirty user data.
* @param {string|array} key key or keys to user data
* @returns {Dataset} the Dataset
* @example
@ -1044,7 +1044,7 @@ class Dataset {
*/
erase(key) {
if (!key || this.empty) return;
let before = this.dirty,
keys = Array.isArray(key) ? key : [key],
erased = this._items.filter(item => {
@ -1055,16 +1055,16 @@ class Dataset {
}
return erase;
});
let currentPos = erased.indexOf(this._current) > -1 ? this._items.indexOf(this._current) : -1,
state = this.state;
if (currentPos > -1) {
let newKey = null;
for (let i = currentPos + 1, length = this._items.length; i < length; ++i) {
let item = this._items[i];
if (item.unreachable || erased.includes(item)) continue;
newKey = this.getKey(item);
break;
}
@ -1072,7 +1072,7 @@ class Dataset {
for (let i = this._items.length - 1; i > 0; --i) {
let item = this._items[i];
if (item.unreachable || erased.includes(item)) continue;
newKey = this.getKey(item);
break;
}
@ -1090,7 +1090,7 @@ class Dataset {
/**Returns an array of strings converted from the template using the property values of the Dataset's user data.
* In the template, placeholder for the properties of the user data is specified like {property name}.
* @param {string} template template string
* @param {function} formatter function to format a row string with custom property placeholders
* @param {function} formatter function to format a row string with custom property placeholders
* @returns {array} array of strings converted from the template using the property values of the user data
*/
inStrings(template, formatter) {
@ -1122,7 +1122,7 @@ class Dataset {
break;
default: return null;
}
let item = this.getData(key, "item");
return item ? item.getValue(property) : undefined;
}
@ -1143,7 +1143,7 @@ class Dataset {
*/
setValue(...args) {
let key = null,
property = null,
property = null,
value = null;
switch (args.length) {
case 2:
@ -1167,46 +1167,46 @@ class Dataset {
* @param {object|array} obj object that has user data or an array of user data
*/
onDatasetChange(obj) {this.log("Dataset changed", obj);}
/**Called back when current user data is changed.
* @param {DataItem} currentItem current dataItem
*/
onCurrentChange(currentItem) {this.log("Current changed", currentItem);}
/**Called back when user data selection changes.
* @param {array} selected array of selected user data
* @param {array} selected array of selected user data
*/
onSelectionChange(selected) {this.log("Selection changed", selected);}
/**Called back when user data is appended.
* @param {object|array} appended user data or array of user data
* @param {object|array} appended user data or array of user data
*/
onAppend(appended) {this.log("Data appended", appended);}
/**Called back when user data is modified.
* @param {array} props names of changed properties
* @param {array} props names of changed properties
* @param {DataItem} modified modified user dataItem
* @param {boolean} current whether current user data is modified
*/
onModify(props, modified, current) {this.log("Data modified", props, modified, current ? "current" : "");}
/**Called back when user data are replaced.
* @param {array} replacing array of user dataItems replacing the old ones
* @param {array} replacing array of user dataItems replacing the old ones
*/
onReplace(replacing) {this.log("Data replaced", replacing);}
/**Called back when user data are removed.
* @param {array} removed array of removed dataItems
* @param {array} removed array of removed dataItems
*/
onRemove(removed) {this.log("Data removed", removed)}
/**Called back when user data are erased.
* @param {array} erased array of erased dataItems
* @param {array} erased array of erased dataItems
*/
onErase(erased) {this.log("Data erased", erased)}
/**Called back when the Dataset gets dirty or not dirty.
* @param {boolean} dirty
* @param {boolean} dirty
* <ul> <li>true if the Dataset is dirty</li>
* <li>false otherwise</li>
* </ul>
@ -1221,9 +1221,9 @@ class DatasetControl {
this.prefixName = conf.prefixName;
this.infoSize = conf.infoSize;
this.appendData = conf.appendData;
this.query = {};
conf.onDatasetChange = obj => this.onDatasetChange(obj),
conf.onCurrentChange = item => this.onCurrentChange(item),
conf.onSelectionChange = selected => this.onSelectionChange(selected),
@ -1236,7 +1236,7 @@ class DatasetControl {
}
this.dataset = new Dataset(conf);
this.urls = conf.urls || {
load:this.url("/list.do"),
getInfo:this.url("/info.do"),
@ -1245,11 +1245,11 @@ class DatasetControl {
remove:this.url("/remove.do")
};
}
prefixed(str) {
return (this.prefix || "") + str;
}
url(str) {
return wctx.url("/" + this.prefixed(str));
}
@ -1278,7 +1278,7 @@ class DatasetControl {
setData(obj) {
this.dataset.setData(obj);
}
addData(obj) {
this.dataset.addData(obj);
}
@ -1286,7 +1286,7 @@ class DatasetControl {
onDatasetChange(obj) {
debug("onDatasetChange", obj);
}
getCurrent(option) {
return this.dataset.getCurrent(option);
}
@ -1328,42 +1328,42 @@ class DatasetControl {
else
this.setInfo(info);
}
setInfo(info) {}
newInfo(obj) {
this.dataset.append(obj || {});
this.getInfo();
}
getValue(name) {
return this.dataset.getValue(name);
}
setValue(name, value) {
this.dataset.setValue(name, value);
}
onAppend(items) {
debug("on append", items);
}
onModify(props, modified, current) {
debug("on modify", props, "modified", modified, "current", current);
}
save(info) {
if (!info) return;
let item = this.getCurrent("item"),
create = "added" == item.state;
ajax.post({
url:!create ? this.urls.update : this.urls.create,
data:info,
success:resp => this.onSave(resp)
});
}
onSave(resp) {
if (resp.saved) {
dialog.alert("저장됐습니다.");
@ -1371,7 +1371,7 @@ class DatasetControl {
this._load();
}
}
remove(params) {
let selected = this.dataset.getKeys("selected");
if (selected.length < 1) return;
@ -1380,14 +1380,14 @@ class DatasetControl {
params = {};
params[this.prefixed("IDs")] = selected.join(",");
}
ajax.post({
url:this.urls.remove,
data:params,
success:resp => this.onRemove(selected, resp)
});
}
onRemove(selected, resp) {
if (resp.saved)
this._load();

@ -1,16 +1,19 @@
class LevyExclControl extends DatasetControl {
constructor(conf) {
super(conf || {
constructor(prefixUrl) {
let conf = {
prefix : "levyExcl"
, prefixName : "부과제외"
, infoSize : "xl"
, urls : {
load : wctx.url("/excl/excl01/010/list.do")
, getInfo : wctx.url("/excl/excl01/020/info.do")
}
, keymapper : info => info ? info.LEVY_EXCL_ID : ""
, dataGetter : obj => obj.levyExclList
, appendData : true
, urls : {
load : wctx.url(prefixUrl + "/010/list.do")
, getInfo : wctx.url(prefixUrl + "/020/info.do")
, create : wctx.url(prefixUrl + "/020/create.do")
, update : wctx.url(prefixUrl + "/020/update.do")
, remove : wctx.url(prefixUrl + "/020/remove.do")
}
, formats : {
LEVY_EXCL_YMD : dateFormat
, CRDN_YMD_TM : datetimeFormat
@ -18,6 +21,7 @@ class LevyExclControl extends DatasetControl {
, REG_DT : datetimeFormat
, MDFCN_DT : datetimeFormat
}
});
}
super(conf);
}
}

@ -1,16 +1,19 @@
class OpnnSbmsnControl extends DatasetControl {
constructor(conf) {
super(conf || {
constructor(prefixUrl) {
let conf = {
prefix : "opnnSbmsn"
, prefixName : "의견제출"
, infoSize : "xl"
, urls : {
load : wctx.url("/excl/excl02/010/list.do")
, getInfo : wctx.url("/excl/excl02/020/info.do")
}
, keymapper : info => info ? info.OPNN_ID : ""
, dataGetter : obj => obj.opnnSbmsnList
, appendData : true
, urls : {
load : wctx.url(prefixUrl + "/010/list.do")
, getInfo : wctx.url(prefixUrl + "/020/info.do")
, create : wctx.url(prefixUrl + "/020/create.do")
, update : wctx.url(prefixUrl + "/020/update.do")
, remove : wctx.url(prefixUrl + "/020/remove.do")
}
, formats : {
RCPT_YMD : dateFormat
, ANS_YMD : dateFormat
@ -19,7 +22,7 @@ class OpnnSbmsnControl extends DatasetControl {
, REG_DT : datetimeFormat
, MDFCN_DT : datetimeFormat
}
});
}
super(conf);
}
}

@ -1,22 +1,25 @@
class CrdnReControl extends DatasetControl {
constructor(conf) {
super(conf || {
constructor(prefixUrl) {
let conf = {
prefix : "crdnRe"
, prefixName : "단속재등록"
, infoSize : "xl"
, urls : {
load : wctx.url("/excl/excl03/010/list.do")
, getInfo : wctx.url("/excl/excl03/020/info.do")
}
, keymapper : info => info ? info.RE_REG_ID : ""
, dataGetter : obj => obj.crdnReList
, appendData : true
, urls : {
load : wctx.url(prefixUrl + "/010/list.do")
, create : wctx.url(prefixUrl + "/010/create.do")
, update : wctx.url(prefixUrl + "/010/update.do")
, remove : wctx.url(prefixUrl + "/010/remove.do")
}
, formats : {
CRDN_REG_YMD : dateFormat
, CRDN_YMD_TM : datetimeFormat
, REG_DT : datetimeFormat
}
});
}
super(conf);
}
}

Loading…
Cancel
Save