mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-07 06:24:47 +09:00
hubez-admin partner-git master -> hubez-git transfer 202205241800
This commit is contained in:
9
frontend/src/common/comm-api.js
Normal file
9
frontend/src/common/comm-api.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import httpClient from '@/common/http-client';
|
||||
// 주소찾기
|
||||
const getAddressList = params => {
|
||||
return httpClient.get('/api/comm/address', { params: params })
|
||||
}
|
||||
|
||||
export default {
|
||||
getAddressList
|
||||
}
|
||||
10
frontend/src/common/config.js
Normal file
10
frontend/src/common/config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const { VUE_APP_TEST_PROP, NODE_ENV = '' } = process.env;
|
||||
|
||||
const environment = NODE_ENV.toLowerCase();
|
||||
const testProp = VUE_APP_TEST_PROP;
|
||||
|
||||
const consts = {
|
||||
tokenPart1: 'JwtPart1'
|
||||
}
|
||||
|
||||
export { environment, testProp, consts };
|
||||
143
frontend/src/common/excel.js
Normal file
143
frontend/src/common/excel.js
Normal file
@@ -0,0 +1,143 @@
|
||||
import xlsx from 'xlsx';
|
||||
|
||||
const xlsxUtils = {
|
||||
filename: '',
|
||||
data: [],
|
||||
header: [],
|
||||
options: {},
|
||||
summary: {
|
||||
isUse: false,
|
||||
position: '',
|
||||
data: null,
|
||||
title: { replaceKeys: [], name: '' }
|
||||
},
|
||||
visibleDataOrder: [],
|
||||
instance: undefined,
|
||||
createInstance() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.instance = document.createElement('table');
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
createHeader() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let header = this.header;
|
||||
/*
|
||||
if (!Array.isArray(this.header[0])) {
|
||||
header.push(this.header);
|
||||
} else {
|
||||
header = this.header;
|
||||
}
|
||||
*/
|
||||
|
||||
let thead = document.createElement('thead');
|
||||
for (let row of header) {
|
||||
let tr = document.createElement('tr');
|
||||
for (let h of row) {
|
||||
let rowspan = h.rowspan || '1';
|
||||
let colspan = h.colspan || '1';
|
||||
let th = document.createElement('th');
|
||||
th.setAttribute('rowspan', rowspan);
|
||||
th.setAttribute('colspan', colspan);
|
||||
//th.setAttribute('align', 'center');
|
||||
th.innerText = h.name;
|
||||
tr.appendChild(th);
|
||||
}
|
||||
thead.appendChild(tr);
|
||||
}
|
||||
this.instance.appendChild(thead);
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
createDataRows() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let tbody = document.createElement('tbody');
|
||||
|
||||
if (this.options.summary != undefined && this.options.summary.isUse) {
|
||||
this.summary = this.options.summary;
|
||||
}
|
||||
|
||||
if (this.summary.isUse && this.summary.position === 'first') {
|
||||
this.appendDataRow(tbody, this.summary.data, true);
|
||||
}
|
||||
|
||||
this.appendDataRow(tbody, this.data, false);
|
||||
|
||||
if (this.summary.isUse && this.summary.position === 'last') {
|
||||
this.appendDataRow(tbody, this.summary.data, true);
|
||||
}
|
||||
|
||||
this.instance.appendChild(tbody);
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
|
||||
appendDataRow(tbody, data, isSummary) {
|
||||
for (let row of data) {
|
||||
let tr = document.createElement('tr');
|
||||
|
||||
if (isSummary) {
|
||||
let td = document.createElement('td');
|
||||
td.innerText = this.summary.title.name;
|
||||
td.setAttribute('colspan', this.summary.title.replaceKeys.length);
|
||||
//td.setAttribute('align', 'center');
|
||||
tr.appendChild(td);
|
||||
}
|
||||
|
||||
for (let cellkey of this.visibleDataOrder) {
|
||||
if (isSummary && this.summary.title.replaceKeys.indexOf(cellkey) > -1) continue;
|
||||
|
||||
let td = document.createElement('td');
|
||||
td.innerText = row[cellkey];
|
||||
tr.appendChild(td);
|
||||
}
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
return tbody;
|
||||
},
|
||||
getVisibleDataOrder() {
|
||||
let dataOrder = [];
|
||||
if (Array.isArray(this.options.dataOrder)) {
|
||||
dataOrder = this.options.dataOrder;
|
||||
} else if (this.options.dataOrder === 'header') {
|
||||
for (let row of this.header) {
|
||||
for (let h of row) {
|
||||
if (h.key != undefined && h.key != null && h.key !== '') {
|
||||
dataOrder.push(h.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataOrder = Object.keys(this.data[0]);
|
||||
}
|
||||
this.visibleDataOrder = dataOrder;
|
||||
},
|
||||
export(data, filename, options) {
|
||||
this.data = data;
|
||||
this.filename = filename;
|
||||
this.header = options.header;
|
||||
this.options = options;
|
||||
|
||||
this.getVisibleDataOrder();
|
||||
return new Promise((resolve, reject) => {
|
||||
this.createInstance().then(() => {
|
||||
this.createHeader().then(() => {
|
||||
this.createDataRows().then(() => {
|
||||
this.exportTableToXlsx();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
exportTableToXlsx() {
|
||||
let config = { raw: true, type: 'string' };
|
||||
let ws = xlsx.utils.table_to_sheet(this.instance, config);
|
||||
let wb = xlsx.utils.book_new();
|
||||
|
||||
xlsx.utils.book_append_sheet(wb, ws, 'Sheet1');
|
||||
xlsx.writeFile(wb, this.filename);
|
||||
}
|
||||
};
|
||||
|
||||
export default xlsxUtils;
|
||||
105
frontend/src/common/http-client.js
Normal file
105
frontend/src/common/http-client.js
Normal file
@@ -0,0 +1,105 @@
|
||||
import axios from 'axios';
|
||||
import { testProp } from './config';
|
||||
|
||||
const config = {
|
||||
//baseURL: 'http://localhost:7070',
|
||||
// baseURL: apiBaseUrl,
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
timeout: 120000 // timeout은 120초로 설정
|
||||
};
|
||||
|
||||
const httpClient = axios.create(config);
|
||||
|
||||
const authInterceptor = config => {
|
||||
// frontend와 backend의 origin이 다른 경우
|
||||
// devServer.proxy 설정을 하던지 baseURL과 withCredentials 설정을 해야 한다.
|
||||
// cookie, header 등에 자격정보 설정이 필요한 api는 true 설정으로 호출해야 하고
|
||||
// 자격정보 설정이 필요없는 api는 withCredentials=false 설정으로 호출해야 한다.
|
||||
// config.withCredentials = !config.url.startsWith('/api/public/');
|
||||
console.log("Test Url : "+ config.url);
|
||||
/*if(config.url == '/api/auth/login'){
|
||||
config.baseURL = "http://localhost:3000";
|
||||
}*/
|
||||
return config;
|
||||
};
|
||||
|
||||
const loggerInterceptor = config => {
|
||||
console.log('testProp:', testProp);
|
||||
console.log('request url:', config.url, 'params:', config.data);
|
||||
return config;
|
||||
};
|
||||
|
||||
let loadOverlap = [];
|
||||
const loadingLayer = (type, config) => {
|
||||
/*
|
||||
get: httpClient.get(url, { params: { ... }, headers: {"show-layer": "Yes"} }) // in 2nd property
|
||||
post: httpClient.post(url, params, { headers: {"show-layer": "Yes"} }) // 3rd property
|
||||
*/
|
||||
if (config.headers['Show-Layer'] == 'Yes') {
|
||||
if (type) {
|
||||
loadOverlap.push('add');
|
||||
} else {
|
||||
loadOverlap.pop();
|
||||
}
|
||||
|
||||
if (loadOverlap.length > 0) {
|
||||
document.querySelector('html > body').style.overflow = 'hidden'; // 스크롤 block
|
||||
document.getElementsByClassName('loading_layer')[0].style.display = 'block';
|
||||
} else {
|
||||
document.querySelector('html > body').style.removeProperty('overflow'); // 스크롤 allow
|
||||
document.getElementsByClassName('loading_layer')[0].style.display = 'none';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*const loadingLayerInterceptor = config => {
|
||||
loadingLayer(true, config);
|
||||
return config;
|
||||
};*/
|
||||
|
||||
/** Adding the request interceptors */
|
||||
httpClient.interceptors.request.use(authInterceptor);
|
||||
httpClient.interceptors.request.use(loggerInterceptor);
|
||||
//httpClient.interceptors.request.use(loadingLayerInterceptor);
|
||||
|
||||
/** Adding the response interceptors */
|
||||
httpClient.interceptors.response.use(
|
||||
response => {
|
||||
//loadingLayer(false, response.config);
|
||||
console.log('response status:', response.status, 'data:', response.data);
|
||||
return response;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
if (error.response != undefined && error.response != null) loadingLayer(false, error.response.config);
|
||||
else loadingLayer(false, error.config);
|
||||
|
||||
if (error.code === 'ECONNABORTED') {
|
||||
alert('서비스가 지연되고 있습니다. 잠시 후 확인하시고 다시 시도해주세요.');
|
||||
return Promise.reject(error);
|
||||
} else if (error.response.status == 401 || error.response.status == 418) {
|
||||
alert('세션이 만료되었습니다.');
|
||||
window.top.location.href = '/login';
|
||||
} else if (error.response.status == 500) {
|
||||
if (error.response.data != null && error.response.data.message == '511 NETWORK_AUTHENTICATION_REQUIRED') {
|
||||
alert('웹템플릿 IP가 브랜드포털에 등록이 필요합니다. 기술지원에 문의해주세요.');
|
||||
return Promise.reject(error);
|
||||
} else {
|
||||
window.top.location.href = '/view/error/500';
|
||||
}
|
||||
} else if (error.response.status == 511) {
|
||||
alert('웹템플릿 IP가 브랜드포털에 등록이 필요합니다. 기술지원에 문의해주세요.');
|
||||
return Promise.reject(error);
|
||||
} else if (error.message == 'Network Error') {
|
||||
alert('네트워크 오류가 발생했습니다. 잠시 후 다시 시도해주세요.');
|
||||
return Promise.reject(error);
|
||||
} else {
|
||||
console.log('response error:', error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default httpClient;
|
||||
1
frontend/src/common/ko.js
Normal file
1
frontend/src/common/ko.js
Normal file
@@ -0,0 +1 @@
|
||||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((t=t||self).vdp_translation_ko=t.vdp_translation_ko||{},t.vdp_translation_ko.js=n())}(this,function(){"use strict";function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var n=new(function(){function n(t,e,r,o){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.language=t,this.months=e,this.monthsAbbr=r,this.days=o,this.rtl=!1,this.ymd=!1,this.yearSuffix=""}var e,r,o;return e=n,(r=[{key:"language",get:function(){return this._language},set:function(t){if("string"!=typeof t)throw new TypeError("Language must be a string");this._language=t}},{key:"months",get:function(){return this._months},set:function(t){if(12!==t.length)throw new RangeError("There must be 12 months for ".concat(this.language," language"));this._months=t}},{key:"monthsAbbr",get:function(){return this._monthsAbbr},set:function(t){if(12!==t.length)throw new RangeError("There must be 12 abbreviated months for ".concat(this.language," language"));this._monthsAbbr=t}},{key:"days",get:function(){return this._days},set:function(t){if(7!==t.length)throw new RangeError("There must be 7 days for ".concat(this.language," language"));this._days=t}}])&&t(e.prototype,r),o&&t(e,o),n}())("Korean",["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],["일","월","화","수","목","금","토"]);return n.yearSuffix="년",n.ymd=!0,n});
|
||||
38
frontend/src/common/token-service.js
Normal file
38
frontend/src/common/token-service.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as utils from './utils';
|
||||
import { consts } from './config';
|
||||
|
||||
// const KEY_TOKEN = 'access_token';
|
||||
|
||||
const tokenSvc = {
|
||||
getToken() {
|
||||
// return store.getters['login/getToken'];
|
||||
// var payload = sessionStorage.getItem(KEY_TOKEN);
|
||||
var jwtPart1 = utils.getCookie(consts.tokenPart1);
|
||||
if (!jwtPart1)
|
||||
return null;
|
||||
var payload = utils.base64decode(jwtPart1.split('.').pop());
|
||||
return JSON.parse(payload);
|
||||
},
|
||||
removeToken() {
|
||||
var name = consts.tokenPart1;
|
||||
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
|
||||
}
|
||||
|
||||
// saveToken(jwtPart1) {
|
||||
// if (!jwtPart1)
|
||||
// return;
|
||||
|
||||
// var payload = utils.base64decode(jwtPart1.split('.').pop());
|
||||
// console.log('save token:', payload);
|
||||
// // store.commit('login/saveToken', token);
|
||||
// sessionStorage.setItem(KEY_TOKEN, payload);
|
||||
// },
|
||||
|
||||
// removeToken() {
|
||||
// // store.commit('login/removeToken');
|
||||
// sessionStorage.removeItem(KEY_TOKEN);
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
export default tokenSvc;
|
||||
117
frontend/src/common/utils.js
Normal file
117
frontend/src/common/utils.js
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @description This method is responsile for creating the object with mirror key and values
|
||||
* and also add prefix to values if available
|
||||
* @param {Array<string>} arr Array of strings
|
||||
* @param {string} prefix prefix
|
||||
* @returns {Object} object with mirror keys generated from the array of strings
|
||||
*/
|
||||
export const reflectKeys = (arr = [], prefix) =>
|
||||
arr.reduce((obj, key) => {
|
||||
const value = prefix ? prefix + ' ' + key : key;
|
||||
obj[key] = value;
|
||||
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
export const form2obj = function(form) {
|
||||
var queryStr = serializeForm(form);
|
||||
return qstr2obj(queryStr);
|
||||
};
|
||||
|
||||
/*!
|
||||
* Serialize all form data into a query string
|
||||
* (c) 2018 Chris Ferdinandi, MIT License, https://gomakethings.com
|
||||
* @param {Node} form The form to serialize
|
||||
* @return {String} The serialized form data
|
||||
*/
|
||||
export const serializeForm = function(form) {
|
||||
// Setup our serialized data
|
||||
var serialized = [];
|
||||
|
||||
// Loop through each field in the form
|
||||
for (var i = 0; i < form.elements.length; i++) {
|
||||
var field = form.elements[i];
|
||||
|
||||
// Don't serialize fields without a name, submits, buttons, file and reset inputs, and disabled fields
|
||||
if (
|
||||
!field.name ||
|
||||
field.disabled ||
|
||||
field.type === 'file' ||
|
||||
field.type === 'reset' ||
|
||||
field.type === 'submit' ||
|
||||
field.type === 'button'
|
||||
)
|
||||
continue;
|
||||
|
||||
// If a multi-select, get all selections
|
||||
if (field.type === 'select-multiple') {
|
||||
for (var n = 0; n < field.options.length; n++) {
|
||||
if (!field.options[n].selected) continue;
|
||||
serialized.push(encodeURIComponent(field.name) + '=' + encodeURIComponent(field.options[n].value));
|
||||
}
|
||||
}
|
||||
|
||||
// Convert field data to a query string
|
||||
else if ((field.type !== 'checkbox' && field.type !== 'radio') || field.checked) {
|
||||
serialized.push(encodeURIComponent(field.name) + '=' + encodeURIComponent(field.value));
|
||||
}
|
||||
}
|
||||
|
||||
return serialized.join('&');
|
||||
};
|
||||
|
||||
export const qstr2obj = function(qstr) {
|
||||
let obj = {};
|
||||
if (qstr) {
|
||||
qstr.split('&').map(item => {
|
||||
const [k, v] = item.split('=');
|
||||
v ? (obj[k] = v) : null;
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
export const getCookie = function(name) {
|
||||
var value = '; ' + document.cookie;
|
||||
var parts = value.split('; ' + name + '=');
|
||||
if (parts.length == 2)
|
||||
return parts
|
||||
.pop()
|
||||
.split(';')
|
||||
.shift();
|
||||
};
|
||||
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
export const base64encode = function(str) {
|
||||
return Base64.encode(str);
|
||||
};
|
||||
|
||||
export const base64decode = function(b64) {
|
||||
return Base64.decode(b64);
|
||||
};
|
||||
|
||||
export const getGwSuccessCode = function() {
|
||||
return '10000';
|
||||
};
|
||||
|
||||
export const isGwSuccess = function(code) {
|
||||
return getGwSuccessCode() == code;
|
||||
};
|
||||
|
||||
let loadOverlap = [];
|
||||
export const loadingLayer = (type) => {
|
||||
if (type) {
|
||||
loadOverlap.push('add');
|
||||
} else {
|
||||
loadOverlap.pop();
|
||||
}
|
||||
|
||||
if (loadOverlap.length > 0) {
|
||||
document.querySelector('html > body').style.overflow = 'hidden'; // 스크롤 block
|
||||
document.getElementsByClassName('loading_layer')[0].style.display = 'block';
|
||||
} else {
|
||||
document.querySelector('html > body').style.removeProperty('overflow'); // 스크롤 allow
|
||||
document.getElementsByClassName('loading_layer')[0].style.display = 'none';
|
||||
}
|
||||
};
|
||||
228
frontend/src/common/vue-mixins.js
Normal file
228
frontend/src/common/vue-mixins.js
Normal file
@@ -0,0 +1,228 @@
|
||||
const coreUiMixin = {
|
||||
directives: {
|
||||
focus: {
|
||||
inserted: function(el) {
|
||||
el.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clearInput: function(evt) {
|
||||
var me = evt.target;
|
||||
var vname = me.previousElementSibling.name;
|
||||
this.$data[vname] = '';
|
||||
me.previousElementSibling.focus();
|
||||
},
|
||||
showPhoneNumber: function(str) {
|
||||
str = str.replace(/[\-\s\/]+/g, '');
|
||||
if (str.length > 12 || str.length < 10) {
|
||||
return str;
|
||||
}
|
||||
var result =
|
||||
str.substring(0, str.length - 8) +
|
||||
'-' +
|
||||
str.substring(str.length - 8, str.length - 4) +
|
||||
'-' +
|
||||
str.substring(str.length - 4, str.length);
|
||||
return result;
|
||||
},
|
||||
/*
|
||||
openLayer: function(event, callback) {
|
||||
var myId = event.target.getAttribute('data-id');
|
||||
var myLayer = document.querySelector('[layer-id="' + myId + '"]');
|
||||
var btnClose = document.querySelector('[layer-id="' + myId + '"] .btn_close');
|
||||
myLayer.classList.add('active');
|
||||
btnClose.addEventListener("click", function() {
|
||||
myLayer.classList.remove('active');
|
||||
if (callback != undefined && callback != null) {
|
||||
callback('');
|
||||
}
|
||||
});
|
||||
|
||||
if (callback != undefined && callback != null) {
|
||||
callback(myId);
|
||||
}
|
||||
},
|
||||
*/
|
||||
openLayer: function(layerId) {
|
||||
if (layerId == undefined || layerId == null || layerId == '') {
|
||||
alert('layerId를 설정해 주세요.');
|
||||
} else {
|
||||
this.$emit('changeLayerId', layerId);
|
||||
}
|
||||
},
|
||||
closeLayer() {
|
||||
this.$emit('changeLayerId', '');
|
||||
},
|
||||
numberComma(num) {
|
||||
if (typeof num == undefined || num == null) {
|
||||
return '';
|
||||
}
|
||||
num = num + '';
|
||||
let point = num.length % 3;
|
||||
let len = num.length;
|
||||
|
||||
let str = num.substring(0, point);
|
||||
while (point < len) {
|
||||
if (str != '') {
|
||||
str += ',';
|
||||
}
|
||||
str += num.substring(point, point + 3);
|
||||
point += 3;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var chkPattern = {
|
||||
data: function() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
setLenth: function(e, len) {
|
||||
this.cut(e, len);
|
||||
},
|
||||
onlyNum: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[0-9]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^0-9]/gi, '');
|
||||
}
|
||||
},
|
||||
only11Num: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[0-9]*$/g.exec(str)) {
|
||||
str = str.replace(/[^0-9]/gi, '');
|
||||
}
|
||||
|
||||
if (str.length > 11) {
|
||||
str = str.substring(0, 11);
|
||||
}
|
||||
|
||||
e.target.value = str;
|
||||
},
|
||||
onlyEmail: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[a-zA-Z0-9_\.\-@._-]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^a-zA-Z0-9_\.\-@._-]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyName: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[ㄱ-힣a-zA-Z]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^ㄱ-힣a-zA-Z]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyTitle: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[ㄱ-힣a-zA-Z0-9]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^ㄱ-힣a-zA-Z0-9]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyText: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[ㄱ-힣a-zA-Z0-9_-]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^ㄱ-힣a-zA-Z0-9_-]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyPassword: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[A-Za-z0-9!@#$%^&*]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^A-Za-z0-9!@#$%^&*]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyId: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[A-Za-z0-9]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^A-Za-z0-9]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyIp: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[0-9,.*]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^0-9,.*]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyRoleNm_Space: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[ㄱ-힣a-zA-Z0-9/\s]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^ㄱ-힣a-zA-Z0-9/\s]/gi, '');
|
||||
}
|
||||
},
|
||||
onlyRoleId_UnderBar: function(e, len) {
|
||||
this.cut(e, len);
|
||||
var str = e.target.value;
|
||||
if (!/^[a-zA-Z0-9_]*$/g.exec(str)) {
|
||||
e.target.value = str.replace(/[^a-zA-Z0-9_]/gi, '');
|
||||
}
|
||||
},
|
||||
cut: function(e, len) {
|
||||
if (typeof len != 'undefined') {
|
||||
var str = e.target.value;
|
||||
if (this.bytes(str) > len) {
|
||||
e.target.value = this.cutBytes(str, len);
|
||||
}
|
||||
}
|
||||
},
|
||||
cutBytes: function(str, len) {
|
||||
var count = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (escape(str.charAt(i)).length >= 4) count += 2;
|
||||
else if (escape(str.charAt(i)) != '%0D') count++;
|
||||
if (count > len) {
|
||||
if (escape(str.charAt(i)) == '%0A') i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str.substring(0, i);
|
||||
},
|
||||
bytes: function(str) {
|
||||
var length = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (escape(str.charAt(i)).length >= 4) length += 2;
|
||||
else if (escape(str.charAt(i)) == '%A7') length += 2;
|
||||
else {
|
||||
if (escape(str.charAt(i)) != '%0D') length++;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
},
|
||||
checkPhone: function(str) {
|
||||
str = str.replace(/[\-\s\/]+/g, '');
|
||||
if (str.charAt(0) != '0') {
|
||||
str = '0' + str;
|
||||
}
|
||||
if (str.length < 10 || str.length > 12) {
|
||||
return '';
|
||||
}
|
||||
if (isNaN(str)) {
|
||||
return '';
|
||||
}
|
||||
//if (str.substr(0,2)!="01" && str.substr(0,3)!="070" && str.substr(0,4)!="0505" && str.substr(0,4)!="0503"){return ""; }
|
||||
//sif (str.substr(0,3)!="010"){return ""; }
|
||||
return str;
|
||||
},
|
||||
checkExcelFile: function(fileObj) {
|
||||
let reg = /(.*?)\.(xls|xlsx)$/;
|
||||
if (fileObj == undefined || fileObj == null)
|
||||
return false;
|
||||
if (!fileObj.name.match(reg))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export { coreUiMixin, chkPattern };
|
||||
Reference in New Issue
Block a user