
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
/**
*
* 공통 처리 플러그인
*/
function prefixZero(number, length) {
var zero = '';
number = number.toString();
if (number.length < length) {
for (let i = 0; i < length - number.length; i++) {
zero += '0';
}
}
return zero + number;
}
//////////////////////////////////////////////////////////////////
import axios from 'axios';
import { mdiMagnify, mdiFolder, mdiFolderOpen, mdiTable, mdiPlay, mdiKeyVariant, mdiTrashCan } from '@mdi/js';
import moment from 'moment';
import Vue from "vue";
export default {
install(Vue) {
let alertRef = {};
let commonXios = {};
let defaultObject = {};
Vue.config.globalProperties.$setAlertRef = function (ref) {
alertRef = ref;
}
//날짜 비교 함수
Vue.config.globalProperties.$getSum = function (prevDate, currentDate) {
alert(prevDate)
alert(currentDate)
}
// 모달 호출
Vue.config.globalProperties.$showAlert = function (title, message) {
alertRef.setTitle(title);
alertRef.setMessage(message);
alertRef.showModal();
}
// confirm 창 호출
Vue.config.globalProperties.$showConfirm = async function (title, message) {
alertRef.setTitle(title);
alertRef.setMessage(message);
const resultData = await alertRef.showConfirm();
return resultData;
}
// confirm 창 호출
Vue.config.globalProperties.$showRadioConfirm = async function (title, message) {
alertRef.setTitle(title);
alertRef.setMessage(message);
const resultData = await alertRef.showRadioConfirm();
return resultData;
}
// 공통코드 호출
Vue.config.globalProperties.$getCommonCode = async function (GroupCode) {
const promise = new Promise((resolve, reject) => {
axios({
url: '/common/getCodeList.json',
method: 'post',
headers: {
'Content-Type': 'application/json; charset=UTF-8'
},
data: JSON.stringify({ 'groupCode': GroupCode })
}).then(function (response) {
resolve(response.data.resultData.codeList)
}).catch(function (error) {
resolve('cancle')
});
});
return promise.then(
(data) => {
return data;
}
).catch(function (err) {
console.log(err)
return [];
});
}
// 데이터베이스 타입호출
Vue.config.globalProperties.$getDataBaseTypeList = async function () {
const promise = new Promise((resolve, reject) => {
axios({
url: '/common/getDataBaseTypeList.json',
method: 'post',
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
}).then(function (response) {
resolve(response.data.resultData.DatabaseTypeList)
}).catch(function (error) {
resolve('cancle')
});
});
return promise.then(
(data) => {
return data;
}
).catch(function (err) {
console.log(err)
return [];
});
}
//시간 구하기
Vue.config.globalProperties.$getFullTime = function (hour, minute, seconds) {
var date = new Date();
var h = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
if (this.$isEmpty(hour) == false) {
h += hour;
} if (this.$isEmpty(minute) == false) {
m += minute;
} if (this.$isEmpty(seconds) == false) {
s += seconds;
}
return prefixZero(h, 2) + ":" + prefixZero(m, 2) + ":" + prefixZero(s, 2);
}
// 빈값체크
Vue.config.globalProperties.$isEmpty = function (data) {
if (data === undefined || data === null || data === "" || data.length === 0 || (data.constructor == Object && Object.keys(data).length === 0)) {
if ((typeof data) === "number") {
return false
} else {
return true;
}
} else {
return false;
}
}
// 기본 검색 객체 생성
Vue.config.globalProperties.$getDefaultSerchVO = function () {
return {
searchObjectList: [],
order: '',
orderASC: true,
currentPage: 1,
perPage: 10,
totalRows: 0
}
}
// 기본 검색 객체 생성
Vue.config.globalProperties.$getDefaultSerchItem = function (key, type) {
let value1 = null;
let value2 = null;
if (type === 'dates') {
value1 = moment().add("-1", "M").format('YYYY-MM-DD');
value2 = moment().format('YYYY-MM-DD');
}
return {
key: key,
value: value1,
key2: key,
value2: value2,
type: type
}
}
// 기본 검색 객체 생성
Vue.config.globalProperties.$getIconPath = function (icon) {
if (icon == null) {
icon = 'mdiMagnify';
}
if (icon == 'mdiFolder') {
return mdiFolder;
} else if (icon == 'mdiFolder') {
return mdiFolderOpen;
} else if (icon == 'mdiTable') {
return mdiTable;
} else if (icon == 'mdiPlay') {
return mdiPlay;
} else if (icon == 'mdiKeyVariant') {
return mdiKeyVariant;
} else if (icon == 'mdiTrashCan') {
return mdiTrashCan;
} else {
return mdiMagnify;
}
}
// 기본 job 관련 vo 세팅
Vue.config.globalProperties.$setDefaultObject = function () {
axios({
url: '/common/getDefaultObject.json',
method: 'post',
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
}).then(function (response) {
defaultObject = response.data.resultData;
}).catch(function (error) {
console.log(error);
});
}
// default jobItm 호출
Vue.config.globalProperties.$getDefaultJobGroup = function () {
return defaultObject;
}
// default jobItm 호출
Vue.config.globalProperties.$getDefaultObject = function () {
return defaultObject;
}
// 스타일 생성
Vue.config.globalProperties.$createStyleSheet = function (stylesheet) {
// 스타일 생성
let result = '';
// 폰트스타일
if (stylesheet.fontStyle != null) {
// 폰트 옵션
result += 'font-size:' + stylesheet.fontStyle.font_size + 'px;';
result += 'color : ' + stylesheet.fontStyle.font_color + ';';
result += 'font-family:' + stylesheet.fontStyle.font + ';';
result += 'text-align: ' + stylesheet.fontStyle.text_align + ';';
result += 'vertical-align: ' + stylesheet.fontStyle.vertical_align + ';';
// 볼드 처리
if (stylesheet.fontStyle.bold_at) result += 'font-weight: bold;'
// 이탤릭 처리
if (stylesheet.fontStyle.italic_at) result += 'font-style: italic;'
// 라인 귿기
if (stylesheet.fontStyle.underline_at || stylesheet.fontStyle.line_through_at) {
result += 'text-decoration:';
if (stylesheet.fontStyle.underline_at) result += ' underline';
if (stylesheet.fontStyle.line_through_at) result += ' line-through';
result += ';';
}
}
// 보더스타일
if (stylesheet.borderStyle != null) {
result += 'border-top:' + stylesheet.borderStyle.border_item[0].border_width + 'px;';
result += 'border-right:' + stylesheet.borderStyle.border_item[1].border_width + 'px;';
result += 'border-bottom:' + stylesheet.borderStyle.border_item[3].border_width + 'px;';
result += 'border-left:' + stylesheet.borderStyle.border_item[2].border_width + 'px;';
result += 'border-radius:' + stylesheet.borderStyle.border_item[0].border_radius + 'px ';
result += stylesheet.borderStyle.border_item[1].border_radius + 'px ';
result += stylesheet.borderStyle.border_item[3].border_radius + 'px ';
result += stylesheet.borderStyle.border_item[2].border_radius + 'px;';
result += 'border-style:' + stylesheet.borderStyle.border_style + ';';
result += 'border-color:' + stylesheet.borderStyle.border_color + ';';
}
// 백그라운드
if (stylesheet.background_style != null) {
// 백그라운드 이미지 사용 여부
if (stylesheet.background_style.image_at) {
result += 'background-image: linear-gradient(rgba(255,255,255, ' + (1 - stylesheet.background_style.opacity / 100) + ' ), rgba(255, 255, 255, ' + (1 - stylesheet.background_style.opacity / 100) + '))';
result += ', url("' + stylesheet.background_style.imageUrl + '");';
result += 'background-position: center;';
result += 'background-repeat: no-repeat;';
// 채우기 설정
if (stylesheet.background_style.imageType) {
result += 'background-size: cover;';
} else {
result += 'background-size: contain;';
}
result += 'background-size: cover;';
} else {
let opacity = Math.floor(stylesheet.background_style.opacity * 2.55).toString(16);
if (opacity == '0') {
opacity = '00';
}
result += 'background-color:' + stylesheet.background_style.background_color + opacity + ';';
}
}
return result;
}
/**
* 아이디 정규식(5~20자의 영문 소문자, 숫자와 특수기호(_),(-)만 사용)
*/
Vue.config.globalProperties.$idCheck = function (data) {
let validateId = /^[a-z0-9_-]{5,20}$/;
if (validateId.test(data) === true) return true;
return false;
}
/**
* 비밀번호 정규식(8~16자의 영문 대문자, 소문자, 숫자, 특수문자를 사용)
*/
Vue.config.globalProperties.$pwCheck = function (data) {
let validatePw = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@#$%^&+=!]).{8,16}$/;
if (validatePw.test(data) === true) return true;
return false;
}
/* 이메일 형식 검사*/
Vue.config.globalProperties.$email = function (email) {
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
try {
return emailPattern.test(email);
} catch (e) {
return false;
}
}
/**
* IPv4 정규식
*/
Vue.config.globalProperties.$ipv4 = function (ip) {
let validateIPv4 = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
if (validateIPv4.test(ip) === true) return true;
return false;
}
/* 3글자 마다 콤마 찍기 (돈) */
Vue.config.globalProperties.$comma = function (text) {
try {
return text.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} catch (e) {
if (text === undefined || text === null || text === "" || text.length === 0) {
return "-";
} else {
return text;
}
}
}
/**
* 사업자번호 정규식(10자리)
*/
Vue.config.globalProperties.$businessNumber = function (data) {
let validateBusinessNumber = /^\d{10}$/;
if (validateBusinessNumber.test(data) === true) return true;
return false;
}
// 날짜 형식 바꾸기 (YYYY-MM-DD HH:MM:SS)
Vue.config.globalProperties.$getFullTime = function (date) {
return moment(date).format('YYYY-MM-DD HH:mm:ss');
}
Vue.config.globalProperties.$getFullFileTime = function (date) {
return moment(date).format('YYMMDD_HHmmss');
}
}
}