diff --git a/src/main/webapp/WEB-INF/jsp/include/fims/tail-framework.jsp b/src/main/webapp/WEB-INF/jsp/include/fims/tail-framework.jsp index b2ccfc97..a56ec279 100644 --- a/src/main/webapp/WEB-INF/jsp/include/fims/tail-framework.jsp +++ b/src/main/webapp/WEB-INF/jsp/include/fims/tail-framework.jsp @@ -39,6 +39,8 @@ + + <%--TODO: 보완 필요 : 공통 ajax 호출 모듈과 통합 필요 --%> diff --git a/src/main/webapp/resources/js/base/base-fims.js b/src/main/webapp/resources/js/base/base-fims.js new file mode 100644 index 00000000..e3b8f1df --- /dev/null +++ b/src/main/webapp/resources/js/base/base-fims.js @@ -0,0 +1,113 @@ +class FimsFormFields extends FormFields { + + /** + * form 에 json data set + * element tag에 data-fmt-type 으로 데이타 format이 지정된 경우 해당 포맷으로 출력 + * @param {object} formObj document.querySelector('form') + * @param {object} jsonData json type data + */ + set(obj){ + + document.querySelectorAll(this.children).forEach(input => { + + let prop = input.getAttribute("data-map") + || input.name + || input.id; + if (!prop) return; + + let dataItem = obj instanceof DataItem, + value = dataItem ? obj.getValue(prop) : obj[prop]; + + if ("radio" == input.type) { + if (value && value == input.value) + input.checked = true; + } else if("checkbox" == input.type) { + if (value && value == input.value) + input.checked = ("Y" === value); + } else if(input.tagName == "SELECT") { + for(let option of input.options) { + if(option.value == value){ + option.selected = true; + } else { + option.selected = false; + } + } + } else { + if(value == null){ + value = ""; + } + // element data-fmt-type에 정의된 format 적용 + // dt - yyyy-mm-dd HH:mm:ss, day - yyyy-mm-dd, time - HH:mm:ss, number - #,### + if(input.dataset.fmtType){ + const fmtType = input.dataset.fmtType; + switch (fmtType) { + case 'dt' : + value = StrDateTimeFormat.format(value); + break; + case 'day' : + value = StrDateFormat.format(value); + break; + case 'time' : + value = StrTimeFormat.format(value); + break; + case 'number' : + value = CommaNumberFormat.format(value); + break; + default: + break; + + } + } + if(input.name){ + + input.value = value; + + //보안모드 마스킹 항목 + if(input.tagName === 'INPUT' && input.id && input.classList.contains("privacy")){ + let maskVal = value.replace(/[0-9a-zA-Z]/g, "*"); + document.getElementById(input.id+"$mask").value = maskVal; + } + } + + } + }); + + + } + + get() { + let obj = {}; + document.querySelectorAll(this.children).forEach(input => { + let property = input.name || input.id; + let value = input.value; + if ("radio" == input.type) { + if (input.checked) + obj[property] = value; + } else { + if(input.dataset.fmtType){ + const fmtType = input.dataset.fmtType; + switch (fmtType) { + case 'dt' : + value = value.replaceAll("-","").replaceAll(":","").replaceAll(" ",""); + break; + case 'day' : + value = value.replaceAll("-",""); + break; + case 'time' : + value = value.replaceAll(":",""); + break; + case 'number' : + value = value.replaceAll(",",""); + break; + default: + break; + + } + } + obj[property] = value; + } + + }); + return obj; + } +} \ No newline at end of file diff --git a/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js b/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js index e235d088..928cfcb4 100644 --- a/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js +++ b/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js @@ -411,119 +411,7 @@ String.prototype.isEmail = function() { }; -class FimsFormFields extends FormFields { - - /** - * form 에 json data set - * element tag에 data-fmt-type 으로 데이타 format이 지정된 경우 해당 포맷으로 출력 - * @param {object} formObj document.querySelector('form') - * @param {object} jsonData json type data - */ - set(obj){ - - document.querySelectorAll(this.children).forEach(input => { - - let prop = input.getAttribute("data-map") - || input.name - || input.id; - if (!prop) return; - - let dataItem = obj instanceof DataItem, - value = dataItem ? obj.getValue(prop) : obj[prop]; - - if ("radio" == input.type) { - if (value && value == input.value) - input.checked = true; - } else if("checkbox" == input.type) { - if (value && value == input.value) - input.checked = ("Y" === value); - } else if(input.tagName == "SELECT") { - for(let option of input.options) { - if(option.value == value){ - option.selected = true; - } else { - option.selected = false; - } - } - } else { - if(value == null){ - value = ""; - } - // element data-fmt-type에 정의된 format 적용 - // dt - yyyy-mm-dd HH:mm:ss, day - yyyy-mm-dd, time - HH:mm:ss, number - #,### - if(input.dataset.fmtType){ - const fmtType = input.dataset.fmtType; - switch (fmtType) { - case 'dt' : - value = StrDateTimeFormat.format(value); - break; - case 'day' : - value = StrDateFormat.format(value); - break; - case 'time' : - value = StrTimeFormat.format(value); - break; - case 'number' : - value = CommaNumberFormat.format(value); - break; - default: - break; - - } - } - if(input.name){ - - input.value = value; - - //보안모드 마스킹 항목 - if(input.tagName === 'INPUT' && input.id && input.classList.contains("privacy")){ - let maskVal = value.replace(/[0-9a-zA-Z]/g, "*"); - document.getElementById(input.id+"$mask").value = maskVal; - } - } - - } - }); - - } - - get() { - let obj = {}; - document.querySelectorAll(this.children).forEach(input => { - let property = input.name || input.id; - let value = input.value; - if ("radio" == input.type) { - if (input.checked) - obj[property] = value; - } else { - if(input.dataset.fmtType){ - const fmtType = input.dataset.fmtType; - switch (fmtType) { - case 'dt' : - value = value.replaceAll("-","").replaceAll(":","").replaceAll(" ",""); - break; - case 'day' : - value = value.replaceAll("-",""); - break; - case 'time' : - value = value.replaceAll(":",""); - break; - case 'number' : - value = value.replaceAll(",",""); - break; - default: - break; - - } - } - obj[property] = value; - } - - }); - return obj; - } -}