소스 정리

main
이범준 3 months ago
parent b19fbae2e3
commit 87f006217b

@ -234,7 +234,7 @@
<script src="/webjars/js/base/dataset.js"></script>
<script src="/webjars/js/base/user.js"></script>
<script src="/resources/js/base/fimsFormFields.js"></script>
<script src="/resources/js/fims/cmmn/fims-base.js"></script>
<script>
var userFields = new FimsFormFields("#user-form");
var userCtrl = newUserControl();

@ -44,9 +44,8 @@
<script src="<c:url value="/webjars/applib/js/componentization.js?${ver}"/>"></script>
<!-- (fims) -->
<script src="<c:url value="/resources/js/base/fimsFormFields.js?${ver}"/>"></script>
<script src="<c:url value="/resources/js/fims/cmmn/fims-base.js?${ver}"/>"></script>
<script src="<c:url value="/resources/js/fims/cmmn/customElements.js?${ver}"/>"></script>
<script src="<c:url value="/resources/js/fims/cmmn/fims-cmmnUtil.js?${ver}"/>"></script>
<script src="<c:url value="/resources/js/fims/cmmn/fims-support.js?${ver}"/>"></script>
<script src="<c:url value="/resources/js/fims/cmmn/fims-componentization.js?${ver}"/>"></script>

@ -48,7 +48,7 @@
<script src="/webjars/js/base/base.js"></script>
<script src="/webjars/js/base/dataset.js"></script>
<script src="/resources/js/base/fimsFormFields.js"></script>
<script src="/resources/js/fims/cmmn/fims-base.js"></script>
<script src="/resources/js/fims/pdfobject.js"></script>
<script>

@ -1,140 +0,0 @@
/**************************************************************************
* FimsFormFields
**************************************************************************/
class FimsFormFields extends FormFields {
help(){
FimsFormFields.help();
}
static help(){
console.log("FormFields클래스를 상속받은 FIMS프로젝트 내에서 사용하는 FormFields클래스");
}
/**
* form json data set
* element tag에 data-fmt-type 으로 데이타 format이 지정된 경우 해당 포맷으로 출력
* @param {object} formObj document.querySelector('form')
* @param {object} jsonData json type data
*/
set(ctrl,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 = datetimeFormat.parse(value);
value = datetimeFormat.format(value);
break;
case 'day' :
value = dateFormat.parse(value);
value = dateFormat.format(value);
break;
case 'time' :
value = timeFormat.parse(value);
value = timeFormat.format(value);
break;
case 'number' :
value = numberFormat.parse(value);
value = numberFormat.format(value);
break;
default:
break;
}
}
if(input.name){
if($(input).hasClass('form-date')){
$(input).datepicker("setDate", value);
} else {
input.value = value;
}
//보안모드 마스킹 항목
if(input.tagName === 'INPUT' && input.id && input.classList.contains("privacy")){
let maskVal = value.replace(/./g, "*");
document.getElementById("mask-"+input.id).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("checkbox" == input.type) {
if(input.checked){
if(obj[property]){
obj[property] += ","+value;
} else {
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;
}
}

@ -1,3 +1,142 @@
/**************************************************************************
* FimsFormFields
**************************************************************************/
class FimsFormFields extends FormFields {
help(){
FimsFormFields.help();
}
static help(){
console.log("FormFields클래스를 상속받은 FIMS프로젝트 내에서 사용하는 FormFields클래스");
}
/**
* form json data set
* element tag에 data-fmt-type 으로 데이타 format이 지정된 경우 해당 포맷으로 출력
* @param {object} formObj document.querySelector('form')
* @param {object} jsonData json type data
*/
set(ctrl,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 = datetimeFormat.parse(value);
value = datetimeFormat.format(value);
break;
case 'day' :
value = dateFormat.parse(value);
value = dateFormat.format(value);
break;
case 'time' :
value = timeFormat.parse(value);
value = timeFormat.format(value);
break;
case 'number' :
value = numberFormat.parse(value);
value = numberFormat.format(value);
break;
default:
break;
}
}
if(input.name){
if($(input).hasClass('form-date')){
$(input).datepicker("setDate", value);
} else {
input.value = value;
}
//보안모드 마스킹 항목
if(input.tagName === 'INPUT' && input.id && input.classList.contains("privacy")){
let maskVal = value.replace(/./g, "*");
document.getElementById("mask-"+input.id).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("checkbox" == input.type) {
if(input.checked){
if(obj[property]){
obj[property] += ","+value;
} else {
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;
}
}
/**************************************************************************
* data-doctx,name 어트리뷰트로 찾기
**************************************************************************/
Loading…
Cancel
Save