|
|
|
|
@ -1,3 +1,8 @@
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 2. DOM 초기화 및 마스크 설정 (시스템 초기화 관련)
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
// 날짜피커 한국어 설정
|
|
|
|
|
$.fn.datepicker.dates['kr'] = {
|
|
|
|
|
days: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"],
|
|
|
|
|
daysShort: ["일", "월", "화", "수", "목", "금", "토"],
|
|
|
|
|
@ -11,6 +16,7 @@ $.fn.datepicker.dates['kr'] = {
|
|
|
|
|
weekStart: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// DOM 준비 완료 시 초기화 함수들
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
$("body").on("focus", ".datepicker", function () {
|
|
|
|
|
@ -96,7 +102,6 @@ $(document).ready(function () {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 중요로직: Strct_Idx_Cd 전용 마스크 - 숫자 3자리
|
|
|
|
|
$("body").on("focus", ".strctIdxCdMask", function () {
|
|
|
|
|
$(this).inputmask({
|
|
|
|
|
@ -227,244 +232,9 @@ $(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if value is empty. Deep-checks arrays and objects Note: isEmpty([]) ==
|
|
|
|
|
* true, isEmpty({}) == true, isEmpty([{0:false},"",0]) == true, isEmpty({0:1}) ==
|
|
|
|
|
* false
|
|
|
|
|
*
|
|
|
|
|
* @param value
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
function isEmpty(value) {
|
|
|
|
|
|
|
|
|
|
if (value === null || value === undefined) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'string' && value.trim() === '') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(value) && value.length === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'object' && Object.keys(value).length === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
기존소스 주석. 0 true 가 이닌 false 처리
|
|
|
|
|
var isEmptyObject = function(a) {
|
|
|
|
|
if(typeof a.length === 'undefined') { // it's an Object, not an Array
|
|
|
|
|
var hasNonempty = Object.keys(a).some(function nonEmpty(element) {
|
|
|
|
|
return !isEmpty(a[element]);
|
|
|
|
|
});
|
|
|
|
|
return hasNonempty ? false : isEmptyObject(Object.keys(a));
|
|
|
|
|
}
|
|
|
|
|
return !a.some(function nonEmpty(element) { // check if array is really
|
|
|
|
|
// not empty as JS thinks
|
|
|
|
|
return !isEmpty(element); // at least one element should be
|
|
|
|
|
// non-empty
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
return(value == false || typeof value === 'undefined' || value == null || (typeof value === 'object' && isEmptyObject(value)));
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* null 이나 빈값을 기본값으로 변경
|
|
|
|
|
*
|
|
|
|
|
* @param str
|
|
|
|
|
* 입력값
|
|
|
|
|
* @param defaultVal
|
|
|
|
|
* 기본값(옵션)
|
|
|
|
|
* @returns {String} 체크 결과값
|
|
|
|
|
*/
|
|
|
|
|
function nvl(str, defaultVal) {
|
|
|
|
|
var defaultValue = "";
|
|
|
|
|
if(typeof defaultVal != 'undefined') {
|
|
|
|
|
defaultValue = defaultVal;
|
|
|
|
|
}
|
|
|
|
|
if(typeof str == "undefined" || str == null || str == '' || str == "undefined") {
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 길이체크
|
|
|
|
|
*
|
|
|
|
|
* @param str
|
|
|
|
|
* @returns {Number}
|
|
|
|
|
*/
|
|
|
|
|
function checkLength(str) {
|
|
|
|
|
var stringLength = str.length;
|
|
|
|
|
var stringByteLength = 0;
|
|
|
|
|
for(var i = 0; i < stringLength; i++) {
|
|
|
|
|
if(escape(str.charAt(i)).length >= 4) {
|
|
|
|
|
stringByteLength += 3;
|
|
|
|
|
} else if(escape(str.charAt(i)) == "%A7") {
|
|
|
|
|
stringByteLength += 3;
|
|
|
|
|
} else {
|
|
|
|
|
if(escape(str.charAt(i)) != "%0D") {
|
|
|
|
|
stringByteLength++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return stringByteLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Left 빈자리 만큼 str 을 붙인다.
|
|
|
|
|
* @param src : Right에 붙을 원본 데이터
|
|
|
|
|
* @param len : str붙힐 데이터 길이
|
|
|
|
|
* @param str : 대상 데이터
|
|
|
|
|
* @returns : str과 src가 붙은 데이터
|
|
|
|
|
* @example : lpad("123123", 10, " ");
|
|
|
|
|
*/
|
|
|
|
|
function lpad(src, len, str) {
|
|
|
|
|
var retStr = "";
|
|
|
|
|
var padCnt = Number(len) - String(src).length;
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<padCnt;i++) {
|
|
|
|
|
retStr += String(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retStr+src;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Right 빈자리 만큼 str 을 붙인다.
|
|
|
|
|
* @param src : Left에 붙을 원본 데이터
|
|
|
|
|
* @param len : str붙힐 데이터 길이
|
|
|
|
|
* @param str : 대상 데이터
|
|
|
|
|
* @returns : str과 src가 붙은 데이터
|
|
|
|
|
* @example : rpad("123123", 10, " ");
|
|
|
|
|
*/
|
|
|
|
|
function rpad(src, len, str) {
|
|
|
|
|
var retStr = "";
|
|
|
|
|
var padCnt = Number(len) - String(src).length;
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<padCnt;i++) {
|
|
|
|
|
retStr += String(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return src+retStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 절상, 절하, 반올림 처리
|
|
|
|
|
* @param strMode - 수식
|
|
|
|
|
* @param nCalcVal - 처리할 값(소수점 이하 데이터 포함)
|
|
|
|
|
* @param nDigit - 연산 기준 자릿수(오라클의 ROUND함수 자릿수 기준)
|
|
|
|
|
* -2:십단위, -1:원단위, 0:소수점 1자리
|
|
|
|
|
* 1:소수점 2자리, 2:소수점 3자리, 3:소수점 4자리, 4:소수점 5자리 처리
|
|
|
|
|
* @return String nCalcVal
|
|
|
|
|
*/
|
|
|
|
|
function fnCalcMath(strMode, nCalcVal, nDigit) {
|
|
|
|
|
if(strMode == "CEIL") { //절상
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.ceil(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.ceil(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
} else if(strMode == "FLOOR") { //절하
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.floor(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.floor(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
} else { //반올림
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.round(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.round(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nCalcVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
|
* 함 수 명 : isNull
|
|
|
|
|
* 기 능 : null 체크 함수
|
|
|
|
|
* 인 자 : value
|
|
|
|
|
* 리 턴 값 : boolean
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
var isNull = function(value) {
|
|
|
|
|
if (new String(value).valueOf() == "undefined") return true;
|
|
|
|
|
if (value == null) return true;
|
|
|
|
|
|
|
|
|
|
value = trimAll(value);
|
|
|
|
|
value = new String(value);
|
|
|
|
|
if (value == null) return true;
|
|
|
|
|
if (value.toString().length == 0) return true;
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
|
* 함 수 명 : utils.trimAll
|
|
|
|
|
* 기 능 : 문자열 전체의 공백제거 함수
|
|
|
|
|
* 인 자 : value
|
|
|
|
|
* 리 턴 값 : string
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
var trimAll = function(value) {
|
|
|
|
|
if (value == null) return "";
|
|
|
|
|
if (new String(value).valueOf() == "undefined") return "";
|
|
|
|
|
|
|
|
|
|
var rtnValue = "";
|
|
|
|
|
value = new String(value);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
for(var i=0; i<value.length; i++) {
|
|
|
|
|
if (value.charAt(i) != " ") {
|
|
|
|
|
rtnValue = rtnValue + value.charAt(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return rtnValue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var downloadAjax = function(data, jqXhr) {
|
|
|
|
|
if (!data) {
|
|
|
|
|
alert("다운로드 파일이 없습니다.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var blob = new Blob([data], { type: jqXhr.getResponseHeader('content-type') });
|
|
|
|
|
var fileName = getFileName(jqXhr.getResponseHeader('content-disposition'));
|
|
|
|
|
fileName = decodeURI(fileName);
|
|
|
|
|
|
|
|
|
|
if (window.navigator.msSaveOrOpenBlob) { // IE 10+
|
|
|
|
|
window.navigator.msSaveOrOpenBlob(blob, fileName);
|
|
|
|
|
} else { // not IE
|
|
|
|
|
var link = document.createElement('a');
|
|
|
|
|
var url = window.URL.createObjectURL(blob);
|
|
|
|
|
link.href = url;
|
|
|
|
|
link.target = '_self';
|
|
|
|
|
if (fileName) link.download = fileName;
|
|
|
|
|
document.body.append(link);
|
|
|
|
|
link.click();
|
|
|
|
|
link.remove();
|
|
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
alert("다운로드 중 에러입니다.");
|
|
|
|
|
console.error(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL 파라미터 관리 유틸리티
|
|
|
|
|
* 검색 조건 유지 및 파라미터 관리를 위한 함수 모음
|
|
|
|
|
*/
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 3. URL 파라미터 관리 함수들 (검색 조건 유지 및 파라미터 관리)
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL의 쿼리 파라미터를 객체로 변환
|
|
|
|
|
@ -502,6 +272,23 @@ var getUrlParams = function(search) {
|
|
|
|
|
return params;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL에서 파라미터 값 가져오기
|
|
|
|
|
*
|
|
|
|
|
* @param {string} paramName - 가져올 파라미터 이름
|
|
|
|
|
* @param {string} defaultValue - 파라미터가 없을 경우 기본값
|
|
|
|
|
* @param {string} url - 대상 URL (기본값: 현재 페이지 URL)
|
|
|
|
|
* @returns {string} 파라미터 값 또는 기본값
|
|
|
|
|
*/
|
|
|
|
|
var getUrlParam = function(paramName, defaultValue, url) {
|
|
|
|
|
// URL이 없으면 현재 페이지 URL 사용
|
|
|
|
|
var targetUrl = url || window.location.href;
|
|
|
|
|
var params = getUrlParams(targetUrl.split('?')[1] ? '?' + targetUrl.split('?')[1] : '');
|
|
|
|
|
|
|
|
|
|
// 파라미터 값이 있으면 반환, 없으면 기본값 반환
|
|
|
|
|
return params[paramName] !== undefined ? params[paramName] : (defaultValue || null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL에 파라미터 추가
|
|
|
|
|
*
|
|
|
|
|
@ -579,23 +366,6 @@ var removeUrlParam = function(paramName, url) {
|
|
|
|
|
return baseUrl + (queryString ? '?' + queryString : '');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL에서 파라미터 값 가져오기
|
|
|
|
|
*
|
|
|
|
|
* @param {string} paramName - 가져올 파라미터 이름
|
|
|
|
|
* @param {string} defaultValue - 파라미터가 없을 경우 기본값
|
|
|
|
|
* @param {string} url - 대상 URL (기본값: 현재 페이지 URL)
|
|
|
|
|
* @returns {string} 파라미터 값 또는 기본값
|
|
|
|
|
*/
|
|
|
|
|
var getUrlParam = function(paramName, defaultValue, url) {
|
|
|
|
|
// URL이 없으면 현재 페이지 URL 사용
|
|
|
|
|
var targetUrl = url || window.location.href;
|
|
|
|
|
var params = getUrlParams(targetUrl.split('?')[1] ? '?' + targetUrl.split('?')[1] : '');
|
|
|
|
|
|
|
|
|
|
// 파라미터 값이 있으면 반환, 없으면 기본값 반환
|
|
|
|
|
return params[paramName] !== undefined ? params[paramName] : (defaultValue || null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL에서 파라미터 값 변경
|
|
|
|
|
*
|
|
|
|
|
@ -761,6 +531,10 @@ var buildContextUrl = function(url) {
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 4. 공통 코드 및 선택박스 관리
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공통코드를 조회하여 select box에 option을 추가하는 함수
|
|
|
|
|
* 중요로직: 코드 그룹 ID를 기준으로 해당 코드들을 조회하여 select box를 동적으로 생성
|
|
|
|
|
@ -891,39 +665,9 @@ function commonCodeSelectAjax(cdGroupId, selectId, firstOptionText, selectedValu
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 자식 팝업창들을 모두 닫고 현재 창을 닫는 공통 함수
|
|
|
|
|
*
|
|
|
|
|
* @param {Array} childPopups - 자식 팝업창 참조 배열
|
|
|
|
|
* @returns {Array} 초기화된 빈 배열
|
|
|
|
|
*/
|
|
|
|
|
function closeChildPopupsAndSelf(childPopups) {
|
|
|
|
|
// 자식 팝업창들이 배열이 아닌 경우 빈 배열로 초기화
|
|
|
|
|
if (!Array.isArray(childPopups)) {
|
|
|
|
|
childPopups = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 열려있는 자식 팝업창들을 먼저 닫기
|
|
|
|
|
for (var i = 0; i < childPopups.length; i++) {
|
|
|
|
|
try {
|
|
|
|
|
if (childPopups[i] && !childPopups[i].closed) {
|
|
|
|
|
childPopups[i].close();
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// 팝업창 접근 오류 무시 (이미 닫혔거나 접근 권한 없음)
|
|
|
|
|
console.warn('팝업창 닫기 중 오류 발생:', e.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 자식 팝업 배열 초기화
|
|
|
|
|
childPopups.length = 0;
|
|
|
|
|
|
|
|
|
|
// 자신의 창 닫기
|
|
|
|
|
window.close();
|
|
|
|
|
|
|
|
|
|
// 초기화된 배열 반환
|
|
|
|
|
return childPopups;
|
|
|
|
|
}
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 5. UI 컴포넌트 (드롭다운)
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 전역 드롭다운 인스턴스 관리
|
|
|
|
|
@ -1434,6 +1178,10 @@ XitDropdown.prototype = {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 6. 파일 다운로드 및 기타 유틸리티 함수들
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 팝업 창 열기 공통함수
|
|
|
|
|
* 중요로직: 팝업창을 화면 중앙에 위치시켜 열기, 위치 조정 가능
|
|
|
|
|
@ -1468,3 +1216,273 @@ function openPopup(url, width, height, windowName, leftOffset, topOffset) {
|
|
|
|
|
return window.open(url, windowName, popupOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 자식 팝업창들을 모두 닫고 현재 창을 닫는 공통 함수
|
|
|
|
|
*
|
|
|
|
|
* @param {Array} childPopups - 자식 팝업창 참조 배열
|
|
|
|
|
* @returns {Array} 초기화된 빈 배열
|
|
|
|
|
*/
|
|
|
|
|
function closeChildPopupsAndSelf(childPopups) {
|
|
|
|
|
// 자식 팝업창들이 배열이 아닌 경우 빈 배열로 초기화
|
|
|
|
|
if (!Array.isArray(childPopups)) {
|
|
|
|
|
childPopups = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 열려있는 자식 팝업창들을 먼저 닫기
|
|
|
|
|
for (var i = 0; i < childPopups.length; i++) {
|
|
|
|
|
try {
|
|
|
|
|
if (childPopups[i] && !childPopups[i].closed) {
|
|
|
|
|
childPopups[i].close();
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// 팝업창 접근 오류 무시 (이미 닫혔거나 접근 권한 없음)
|
|
|
|
|
console.warn('팝업창 닫기 중 오류 발생:', e.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 자식 팝업 배열 초기화
|
|
|
|
|
childPopups.length = 0;
|
|
|
|
|
|
|
|
|
|
// 자신의 창 닫기
|
|
|
|
|
window.close();
|
|
|
|
|
|
|
|
|
|
// 초기화된 배열 반환
|
|
|
|
|
return childPopups;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var downloadAjax = function(data, jqXhr) {
|
|
|
|
|
if (!data) {
|
|
|
|
|
alert("다운로드 파일이 없습니다.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var blob = new Blob([data], { type: jqXhr.getResponseHeader('content-type') });
|
|
|
|
|
var fileName = getFileName(jqXhr.getResponseHeader('content-disposition'));
|
|
|
|
|
fileName = decodeURI(fileName);
|
|
|
|
|
|
|
|
|
|
if (window.navigator.msSaveOrOpenBlob) { // IE 10+
|
|
|
|
|
window.navigator.msSaveOrOpenBlob(blob, fileName);
|
|
|
|
|
} else { // not IE
|
|
|
|
|
var link = document.createElement('a');
|
|
|
|
|
var url = window.URL.createObjectURL(blob);
|
|
|
|
|
link.href = url;
|
|
|
|
|
link.target = '_self';
|
|
|
|
|
if (fileName) link.download = fileName;
|
|
|
|
|
document.body.append(link);
|
|
|
|
|
link.click();
|
|
|
|
|
link.remove();
|
|
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
alert("다운로드 중 에러입니다.");
|
|
|
|
|
console.error(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// 1. 핵심 유틸리티 함수들 (가장 중요 - 전체적으로 사용되는 기본 함수들)
|
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if value is empty. Deep-checks arrays and objects Note: isEmpty([]) ==
|
|
|
|
|
* true, isEmpty({}) == true, isEmpty([{0:false},"",0]) == true, isEmpty({0:1}) ==
|
|
|
|
|
* false
|
|
|
|
|
*
|
|
|
|
|
* @param value
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
function isEmpty(value) {
|
|
|
|
|
if (value === null || value === undefined) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'string' && value.trim() === '') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(value) && value.length === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'object' && Object.keys(value).length === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
기존소스 주석. 0 true 가 이닌 false 처리
|
|
|
|
|
var isEmptyObject = function(a) {
|
|
|
|
|
if(typeof a.length === 'undefined') { // it's an Object, not an Array
|
|
|
|
|
var hasNonempty = Object.keys(a).some(function nonEmpty(element) {
|
|
|
|
|
return !isEmpty(a[element]);
|
|
|
|
|
});
|
|
|
|
|
return hasNonempty ? false : isEmptyObject(Object.keys(a));
|
|
|
|
|
}
|
|
|
|
|
return !a.some(function nonEmpty(element) { // check if array is really
|
|
|
|
|
// not empty as JS thinks
|
|
|
|
|
return !isEmpty(element); // at least one element should be
|
|
|
|
|
// non-empty
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
return(value == false || typeof value === 'undefined' || value == null || (typeof value === 'object' && isEmptyObject(value)));
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* null 이나 빈값을 기본값으로 변경
|
|
|
|
|
*
|
|
|
|
|
* @param str
|
|
|
|
|
* 입력값
|
|
|
|
|
* @param defaultVal
|
|
|
|
|
* 기본값(옵션)
|
|
|
|
|
* @returns {String} 체크 결과값
|
|
|
|
|
*/
|
|
|
|
|
function nvl(str, defaultVal) {
|
|
|
|
|
var defaultValue = "";
|
|
|
|
|
if(typeof defaultVal != 'undefined') {
|
|
|
|
|
defaultValue = defaultVal;
|
|
|
|
|
}
|
|
|
|
|
if(typeof str == "undefined" || str == null || str == '' || str == "undefined") {
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
|
* 함 수 명 : isNull
|
|
|
|
|
* 기 능 : null 체크 함수
|
|
|
|
|
* 인 자 : value
|
|
|
|
|
* 리 턴 값 : boolean
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
var isNull = function(value) {
|
|
|
|
|
if (new String(value).valueOf() == "undefined") return true;
|
|
|
|
|
if (value == null) return true;
|
|
|
|
|
|
|
|
|
|
value = trimAll(value);
|
|
|
|
|
value = new String(value);
|
|
|
|
|
if (value == null) return true;
|
|
|
|
|
if (value.toString().length == 0) return true;
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
|
* 함 수 명 : utils.trimAll
|
|
|
|
|
* 기 능 : 문자열 전체의 공백제거 함수
|
|
|
|
|
* 인 자 : value
|
|
|
|
|
* 리 턴 값 : string
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
var trimAll = function(value) {
|
|
|
|
|
if (value == null) return "";
|
|
|
|
|
if (new String(value).valueOf() == "undefined") return "";
|
|
|
|
|
|
|
|
|
|
var rtnValue = "";
|
|
|
|
|
value = new String(value);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
for(var i=0; i<value.length; i++) {
|
|
|
|
|
if (value.charAt(i) != " ") {
|
|
|
|
|
rtnValue = rtnValue + value.charAt(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return rtnValue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 길이체크
|
|
|
|
|
*
|
|
|
|
|
* @param str
|
|
|
|
|
* @returns {Number}
|
|
|
|
|
*/
|
|
|
|
|
function checkLength(str) {
|
|
|
|
|
var stringLength = str.length;
|
|
|
|
|
var stringByteLength = 0;
|
|
|
|
|
for(var i = 0; i < stringLength; i++) {
|
|
|
|
|
if(escape(str.charAt(i)).length >= 4) {
|
|
|
|
|
stringByteLength += 3;
|
|
|
|
|
} else if(escape(str.charAt(i)) == "%A7") {
|
|
|
|
|
stringByteLength += 3;
|
|
|
|
|
} else {
|
|
|
|
|
if(escape(str.charAt(i)) != "%0D") {
|
|
|
|
|
stringByteLength++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return stringByteLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Left 빈자리 만큼 str 을 붙인다.
|
|
|
|
|
* @param src : Right에 붙을 원본 데이터
|
|
|
|
|
* @param len : str붙힐 데이터 길이
|
|
|
|
|
* @param str : 대상 데이터
|
|
|
|
|
* @returns : str과 src가 붙은 데이터
|
|
|
|
|
* @example : lpad("123123", 10, " ");
|
|
|
|
|
*/
|
|
|
|
|
function lpad(src, len, str) {
|
|
|
|
|
var retStr = "";
|
|
|
|
|
var padCnt = Number(len) - String(src).length;
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<padCnt;i++) {
|
|
|
|
|
retStr += String(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retStr+src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Right 빈자리 만큼 str 을 붙인다.
|
|
|
|
|
* @param src : Left에 붙을 원본 데이터
|
|
|
|
|
* @param len : str붙힐 데이터 길이
|
|
|
|
|
* @param str : 대상 데이터
|
|
|
|
|
* @returns : str과 src가 붙은 데이터
|
|
|
|
|
* @example : rpad("123123", 10, " ");
|
|
|
|
|
*/
|
|
|
|
|
function rpad(src, len, str) {
|
|
|
|
|
var retStr = "";
|
|
|
|
|
var padCnt = Number(len) - String(src).length;
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<padCnt;i++) {
|
|
|
|
|
retStr += String(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return src+retStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 절상, 절하, 반올림 처리
|
|
|
|
|
* @param strMode - 수식
|
|
|
|
|
* @param nCalcVal - 처리할 값(소수점 이하 데이터 포함)
|
|
|
|
|
* @param nDigit - 연산 기준 자릿수(오라클의 ROUND함수 자릿수 기준)
|
|
|
|
|
* -2:십단위, -1:원단위, 0:소수점 1자리
|
|
|
|
|
* 1:소수점 2자리, 2:소수점 3자리, 3:소수점 4자리, 4:소수점 5자리 처리
|
|
|
|
|
* @return String nCalcVal
|
|
|
|
|
*/
|
|
|
|
|
function fnCalcMath(strMode, nCalcVal, nDigit) {
|
|
|
|
|
if(strMode == "CEIL") { //절상
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.ceil(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.ceil(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
} else if(strMode == "FLOOR") { //절하
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.floor(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.floor(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
} else { //반올림
|
|
|
|
|
if(nDigit < 0) {
|
|
|
|
|
nDigit = -(nDigit);
|
|
|
|
|
nCalcVal = Math.round(nCalcVal / Math.pow(10, nDigit)) * Math.pow(10, nDigit);
|
|
|
|
|
} else {
|
|
|
|
|
nCalcVal = Math.round(nCalcVal * Math.pow(10, nDigit)) / Math.pow(10, nDigit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nCalcVal;
|
|
|
|
|
}
|
|
|
|
|
|