Commit c8b52fa4 authored by 黄奎's avatar 黄奎

111

parent 5aa13183
...@@ -14,7 +14,7 @@ module.exports = { ...@@ -14,7 +14,7 @@ module.exports = {
}, },
// Various Dev Server settings // Various Dev Server settings
host: 'www.test.com', // can be overwritten by process.env.HOST host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false, autoOpenBrowser: false,
errorOverlay: true, errorOverlay: true,
......
import md5 from 'js-md5' import md5 from 'js-md5'
import co from 'co' import co from 'co'
export default { export default {
data: { data: {
loginUser: {}, loginUser: {},
apiurl: '' apiurl: ''
}, },
install(Vue, options) { install(Vue, options) {
Vue.prototype.isOnline = function() { Vue.prototype.isOnline = function () {
return process.env.NODE_ENV !== 'development'; return process.env.NODE_ENV !== 'development';
}, },
//域名管理对象 //域名管理对象
Vue.prototype.domainManager = function() { Vue.prototype.domainManager = function () {
// var domainUrl = "http://test_reborn.oytour.com";//主域名 var domainUrl = "http://reborn.oytour.com"; //主域名
var domainUrl = "http://reborn.oytour.com"; //主域名 let locationName = window.location.hostname;
// var domainUrl = "http://192.168.2.16:8087"; //主域名 let javaUrldo = "";
let locationName = window.location.hostname; javaUrldo = locationName.indexOf('zcyx') !== -1 || locationName.indexOf('viitto') !== -1 ? (locationName.indexOf('oytour') !== -1 ? "http://property.oytour.com" : "http://47.96.12.235:9001") : "http://192.168.2.65:8018";
let javaUrldo = ""; if (this.isOnline()) {
javaUrldo = locationName.indexOf('zcyx') !== -1 || locationName.indexOf('viitto') !== -1 ? (locationName.indexOf('oytour') !== -1 ? "http://property.oytour.com" : "http://47.96.12.235:9001") : "http://192.168.2.65:8018"; domainUrl = "http://property.oytour.com"
if (this.isOnline()) { }
if (window.location.host.indexOf('testb2b.oytour.com') != -1) var obj = {
domainUrl = "http://testapi.oytour.com" //主地址
else if (window.location.host.indexOf('oytour.com') != -1) DomainUrl: domainUrl,
domainUrl = "http://property.oytour.com" //上传文件URL
} UploadFileUrl: domainUrl + '/api/File/post',
var obj = { LocalTemplateFileDownLoadUrl: domainUrl,
//主地址 //常用提交数据URL
DomainUrl: domainUrl, PostUrl: domainUrl + "/api/common/post",
//上传文件URL javaUrl: locationName.indexOf('zcyx') !== -1 ? "http://property.oytour.com" : locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://property.oytour.com" : "http://192.168.5.46:5001",
UploadFileUrl: domainUrl + '/api/File/post', ViittoFileUrl: locationName.indexOf('zcyx') !== -1 || locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://staticfile.oytour.com" : 'http://192.168.2.214:8130',
LocalTemplateFileDownLoadUrl: domainUrl, UploadUrl: locationName.indexOf('zcyx') !== -1 || locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://uploadfile.oytour.com" : "http://192.168.2.214:8120",
//常用提交数据URL LocalFileStreamDownLoadUrl: domainUrl + "/api/file/GetFileFromWebApi",
PostUrl: domainUrl + "/api/common/post", JavaLocalFileStreamDownLoadUrl: javaUrldo,
// javaUrl: locationName.indexOf('oytour') !== -1 || locationName.indexOf('testb2b.oytour.com') !== -1 ? (locationName.indexOf('oytour') !== -1 ? "http://efficient.oytour.com" : "http://47.96.12.235:9001") : "http://192.168.2.215:9000", };
console.log(locationName.indexOf('zcyx'))
javaUrl: locationName.indexOf('zcyx') !== -1 ? "http://property.oytour.com" : locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://property.oytour.com" : "http://192.168.1.13:8087", return obj;
ViittoFileUrl: locationName.indexOf('zcyx') !== -1 || locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://staticfile.oytour.com" : 'http://192.168.2.214:8130', },
UploadUrl: locationName.indexOf('zcyx') !== -1 || locationName.indexOf('zcyx.oytour.com') !== -1 ? "http://uploadfile.oytour.com" : "http://192.168.2.214:8120", Vue.prototype.GetLocalFile = function (cmd, msg, fileName, successCall) {
// UploadUrl: "http://uploadfile.oytour.com", var apiurl = this.domainManager().LocalFileStreamDownLoadUrl;
LocalFileStreamDownLoadUrl: domainUrl + "/api/file/GetFileFromWebApi", var timestamp = (new Date()).valueOf();
JavaLocalFileStreamDownLoadUrl: javaUrldo, if (!localStorage.zcuserInfo && localStorage.zcuserInfo != "" && this.$route.path.toLowerCase() != "/login") {
}; this.$router.push({
console.log(locationName.indexOf('zcyx')) path: '/login'
return obj; })
}, }
Vue.prototype.GetLocalFile = function(cmd, msg, fileName, successCall) { var token = "";
var apiurl = this.domainManager().LocalFileStreamDownLoadUrl; var key = "";
var timestamp = (new Date()).valueOf(); if (this.getLocalStorage() != null) {
if (!localStorage.zcuserInfo && localStorage.zcuserInfo != "" && this.$route.path.toLowerCase() != "/login") { token = this.getLocalStorage().token;
this.$router.push({ key = this.getLocalStorage().secretKey;
path: '/login' }
}) var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
} var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var token = ""; var postData = {
var key = ""; "msg": msg,
if (this.getLocalStorage() != null) { "cmd": cmd,
token = this.getLocalStorage().token; "timestamp": timestamp,
key = this.getLocalStorage().secretKey; "token": token,
} "sign": md5Str
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); }
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`); this.$http.post(apiurl, postData, {
var postData = { responseType: 'arraybuffer'
"msg": msg, }).then((res) => {
"cmd": cmd, let blob = new Blob([res.data], {
"timestamp": timestamp, type: "application/vnd.ms-excel"
"token": token, })
"sign": md5Str let url = URL.createObjectURL(blob);
} let link = document.createElement('a');
this.$http.post(apiurl, postData, { link.href = url;
responseType: 'arraybuffer' link.setAttribute("download", fileName);
}).then((res) => { document.body.appendChild(link);
let blob = new Blob([res.data], { link.click();
type: "application/vnd.ms-excel" successCall(res);
}) }).catch(function (res) {});
let url = URL.createObjectURL(blob); },
let link = document.createElement('a'); Vue.prototype.JavaGetLocalFile = function (cmd, msg, fileName, successCall) {
link.href = url; var apiurl = this.domainManager().JavaLocalFileStreamDownLoadUrl + cmd;
link.setAttribute("download", fileName); var timestamp = (new Date()).valueOf();
document.body.appendChild(link); if (!localStorage.zcuserInfo && localStorage.zcuserInfo != "" && this.$route.path.toLowerCase() != "/login") {
link.click(); this.$router.push({
successCall(res); path: '/login'
}).catch(function(res) {}); })
}, }
Vue.prototype.JavaGetLocalFile = function(cmd, msg, fileName, successCall) { var token = "";
var apiurl = this.domainManager().JavaLocalFileStreamDownLoadUrl + cmd; var key = "";
var timestamp = (new Date()).valueOf(); if (this.getLocalStorage() != null) {
if (!localStorage.zcuserInfo && localStorage.zcuserInfo != "" && this.$route.path.toLowerCase() != "/login") { token = this.getLocalStorage().token;
this.$router.push({ key = this.getLocalStorage().SecretKey;
path: '/login' }
}) let zcuserInfo = localStorage.zcuserInfo ? JSON.parse(localStorage.zcuserInfo) : '';
} let groupId = zcuserInfo.RB_Group_id ? zcuserInfo.RB_Group_id : 0;
var token = ""; let uid = zcuserInfo.EmployeeId ? zcuserInfo.EmployeeId : 0;
var key = ""; var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
if (this.getLocalStorage() != null) { // var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
token = this.getLocalStorage().token; var md5Str = md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
key = this.getLocalStorage().SecretKey; var postData = {
} "msg": msg,
let zcuserInfo = localStorage.zcuserInfo ? JSON.parse(localStorage.zcuserInfo) : ''; "timestamp": timestamp,
let groupId = zcuserInfo.RB_Group_id ? zcuserInfo.RB_Group_id : 0; "token": token,
let uid = zcuserInfo.EmployeeId ? zcuserInfo.EmployeeId : 0; "sign": md5Str,
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); "uid": uid,
// var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`); "groupId": groupId
var md5Str = md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`); }
var postData = { // var postData = {
"msg": msg, // "msg": msg,
"timestamp": timestamp, // "cmd": cmd,
"token": token, // "timestamp": timestamp,
"sign": md5Str, // "token": token,
"uid": uid, // "sign": md5Str
"groupId": groupId // }
} this.$http.post(apiurl, postData, {
// var postData = { responseType: 'arraybuffer'
// "msg": msg, }).then((res) => {
// "cmd": cmd, let blob = new Blob([res.data], {
// "timestamp": timestamp, type: "application/vnd.ms-excel"
// "token": token, })
// "sign": md5Str let url = URL.createObjectURL(blob);
// } let link = document.createElement('a');
this.$http.post(apiurl, postData, { link.href = url;
responseType: 'arraybuffer' link.setAttribute("download", fileName);
}).then((res) => { document.body.appendChild(link);
let blob = new Blob([res.data], { link.click();
type: "application/vnd.ms-excel" successCall(res);
}) }).catch(function (res) {});
let url = URL.createObjectURL(blob); },
let link = document.createElement('a'); //价钱格式化,三位数逗号分隔,保留两位小数 duanjun
link.href = url; Vue.prototype.moneyFormat = function (value) {
link.setAttribute("download", fileName); let nStr = Number(value).toFixed(2)
document.body.appendChild(link); nStr += '';
link.click(); let x = nStr.split('.');
successCall(res); let x1 = x[0];
}).catch(function(res) {}); let x2 = x.length > 1 ? '.' + x[1] : '';
}, var rgx = /(\d+)(\d{3})/;
//价钱格式化,三位数逗号分隔,保留两位小数 duanjun while (rgx.test(x1)) {
Vue.prototype.moneyFormat = function(value) { x1 = x1.replace(rgx, '$1' + ',' + '$2');
let nStr = Number(value).toFixed(2) }
nStr += ''; return x1 + x2;
let x = nStr.split('.'); },
let x1 = x[0]; //消息成功提示
let x2 = x.length > 1 ? '.' + x[1] : ''; Vue.prototype.Success = function (msg) {
var rgx = /(\d+)(\d{3})/; this.$message({
while (rgx.test(x1)) { message: msg,
x1 = x1.replace(rgx, '$1' + ',' + '$2'); duration: 2000,
} type: "success"
return x1 + x2; });
}, },
//消息成功提示 //错误提示
Vue.prototype.Success = function(msg) { Vue.prototype.Error = function (msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "success" type: "error"
}); });
}, },
//错误提示
Vue.prototype.Error = function(msg) {
this.$message({
message: msg,
duration: 2000,
type: "error"
});
},
//一般提示 //一般提示
Vue.prototype.Info = function(msg) { Vue.prototype.Info = function (msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "info" type: "info"
}); });
}, },
//警告提示 //警告提示
Vue.prototype.Warning = function(msg) { Vue.prototype.Warning = function (msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "warning" type: "warning"
}); });
}, },
//Confirm //Confirm
Vue.prototype.Confirm = function(msg, callback) { Vue.prototype.Confirm = function (msg, callback) {
this.$confirm(msg, "提示", { this.$confirm(msg, "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}) })
.then(() => { .then(() => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(); callback();
}
})
.catch(() => {
this.Info("已取消操作");
});
},
//压缩图片
//path : 图片路径
//type : m_filt 填充 m_w 宽度固定 高度不固定 m_h 高度固定 宽度不固定
// w : 宽
// h : 高
Vue.prototype.compressImg = function(path, type, w, h) {
let url = this.domainManager().UploadUrl;
let poise = 'width=';
w = w ? w : ''
h = h ? h : ''
if (type === 'w') {
poise = 'width'
} else if (type === 'h') {
poise = 'height'
}
return path.split('?')[0] + '?width=' + w;
}
//打开新窗口连接
Vue.prototype.OpenNewUrl = function(URL) {
if (URL != '') {
window.open('http://' + URL, '_blank');
} }
})
.catch(() => {
this.Info("已取消操作");
});
},
//压缩图片
//path : 图片路径
//type : m_filt 填充 m_w 宽度固定 高度不固定 m_h 高度固定 宽度不固定
// w : 宽
// h : 高
Vue.prototype.compressImg = function (path, type, w, h) {
let url = this.domainManager().UploadUrl;
let poise = 'width=';
w = w ? w : ''
h = h ? h : ''
if (type === 'w') {
poise = 'width'
} else if (type === 'h') {
poise = 'height'
}
return path.split('?')[0] + '?width=' + w;
}
//打开新窗口连接
Vue.prototype.OpenNewUrl = function (URL) {
if (URL != '') {
window.open('http://' + URL, '_blank');
}
}
Vue.prototype.apipost = function (cmd, msg, successCall, faildCall) {
if (msg == null || msg == "") {
msg = {}
}
var apiurl = this.domainManager().PostUrl;
var timestamp = (new Date()).valueOf();
this.apiurl = apiurl;
var token = "";
var key = "";
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token;
key = this.getLocalStorage().secretKey;
} }
Vue.prototype.apipost = function(cmd, msg, successCall, faildCall) {
if (msg == null || msg == "") {
msg = {}
}
var apiurl = this.domainManager().PostUrl;
var timestamp = (new Date()).valueOf();
this.apiurl = apiurl;
var token = "";
var key = "";
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token;
key = this.getLocalStorage().secretKey;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var postData = {
"msg": msg,
"cmd": cmd,
"timestamp": timestamp,
"token": token,
"sign": md5Str
}
if (localStorage.g && localStorage.g != 'undefined') {
// postData.groupId = parseInt(JSON.parse(localStorage.g).i)
postData.groupId = 2;
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
})
} else if (res.data.resultCode == 10005) {
this.$router.go(-1)
} else {
successCall(res)
}
}, faildCall)
},
Vue.prototype.apiJavaPost = function(cmd, msg, successCall, faildCall) {
if (msg == null || msg == "") {
msg = {}
}
var apiurl = this.domainManager().javaUrl + cmd;
var timestamp = (new Date()).valueOf();
this.apiurl = apiurl;
var token = "";
var key = "";
let zcuserInfo = localStorage.zcuserInfo ? JSON.parse(localStorage.zcuserInfo) : ''
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token;
key = this.getLocalStorage().secretKey;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`msg=YXZCGL2020&timestamp=${timestamp}&token=${token}&key=${key}`);
// var md5Str = md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var postData = { var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
"msg": msg, var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
"timestamp": timestamp,
"token": token,
"sign": md5Str
}
if (localStorage.g && localStorage.g != 'undefined') {
// postData.groupId = parseInt(JSON.parse(localStorage.g).i)
postData.groupId = 2;
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
})
} else if (res.data.resultCode == 10005) {
this.$router.go(-1)
} else {
successCall(res)
}
}, faildCall)
},
Vue.prototype.getLocalStorage = function() {
var localStorageData = window.localStorage["zcuserInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData);
} else {
return null;
}
},
//上传文件到本地服务器
Vue.prototype.UploadSelfFileT = function(path, files, successCall, ocr) {
if (files && files.length > 0) {
let nameList = new Array()
for (let index = 0; index < files.length; index++) {
nameList.push(this.random_string());
}
let that = this;
co(function*() {
for (let index = 0; index < files.length; index++) {
let fileName = nameList[index]
fileName = path + fileName + "." + files[index].name.split('.').pop()
var formData = new FormData();
var uploadUrl = that.domainManager().UploadUrl + "/Upload?filePath=" + path + '&ocr=' + ocr;
formData.append("myfile", files[index]);
that.$http.post(uploadUrl, formData, {})
.then(res => {
successCall(res);
})
}
}).catch(function(err) {
}); var postData = {
} "msg": msg,
"cmd": cmd,
"timestamp": timestamp,
"token": token,
"sign": md5Str
}
if (localStorage.g && localStorage.g != 'undefined') {
// postData.groupId = parseInt(JSON.parse(localStorage.g).i)
postData.groupId = 2;
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
} }
Vue.prototype.random_string = function(len) { })
len = len || 32; .then(res => {
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
var maxPos = chars.length; this.$router.push({
var pwd = ''; path: '/login'
for (let i = 0; i < len; i++) { })
pwd += chars.charAt(Math.floor(Math.random() * maxPos)); } else if (res.data.resultCode == 10005) {
} this.$router.go(-1)
return pwd; } else {
}, successCall(res)
//验证只能输入2位小数
Vue.prototype.checkPrice = function(item, filed) {
var value = "";
if (typeof item[filed] == "string") {
value = item[filed];
} else {
value = item[filed].toString();
}
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
value = value
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".");
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
if (value.indexOf(".") < 0 && value != "") {
//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
value = parseFloat(value);
}
item[filed] = value;
} }
//验证只能输入整数 }, faildCall)
Vue.prototype.checkInteger = function(item, filed) { },
var value = ""; Vue.prototype.apiJavaPost = function (cmd, msg, successCall, faildCall) {
if (typeof item[filed] == "string") { if (msg == null || msg == "") {
value = item[filed]; msg = {}
}
var apiurl = this.domainManager().javaUrl + cmd;
var timestamp = (new Date()).valueOf();
this.apiurl = apiurl;
var token = "";
var key = "";
let zcuserInfo = localStorage.zcuserInfo ? JSON.parse(localStorage.zcuserInfo) : ''
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token;
key = this.getLocalStorage().secretKey;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`msg=YXZCGL2020&timestamp=${timestamp}&token=${token}&key=${key}`);
// var md5Str = md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var postData = {
"msg": msg,
"timestamp": timestamp,
"token": token,
"sign": md5Str
}
if (localStorage.g && localStorage.g != 'undefined') {
// postData.groupId = parseInt(JSON.parse(localStorage.g).i)
postData.groupId = 2;
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
})
} else if (res.data.resultCode == 10005) {
this.$router.go(-1)
} else { } else {
value = item[filed].toString(); successCall(res)
} }
value = value.replace(this.$commonUtils.Regex.isInteger, ""); }, faildCall)
item[filed] = value; },
Vue.prototype.getLocalStorage = function () {
var localStorageData = window.localStorage["zcuserInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData);
} else {
return null;
} }
},
//上传文件到本地服务器
Vue.prototype.UploadSelfFileT = function (path, files, successCall, ocr) {
if (files && files.length > 0) {
let nameList = new Array()
for (let index = 0; index < files.length; index++) {
nameList.push(this.random_string());
}
let that = this;
co(function* () {
for (let index = 0; index < files.length; index++) {
let fileName = nameList[index]
fileName = path + fileName + "." + files[index].name.split('.').pop()
var formData = new FormData();
var uploadUrl = that.domainManager().UploadUrl + "/Upload?filePath=" + path + '&ocr=' + ocr;
formData.append("myfile", files[index]);
that.$http.post(uploadUrl, formData, {})
.then(res => {
successCall(res);
})
}
}).catch(function (err) {
});
}
}
Vue.prototype.random_string = function (len) {
len = len || 32;
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
var maxPos = chars.length;
var pwd = '';
for (let i = 0; i < len; i++) {
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
},
//验证只能输入2位小数
Vue.prototype.checkPrice = function (item, filed) {
var value = "";
if (typeof item[filed] == "string") {
value = item[filed];
} else {
value = item[filed].toString();
}
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
value = value
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".");
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
if (value.indexOf(".") < 0 && value != "") {
//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
value = parseFloat(value);
}
item[filed] = value;
}
//验证只能输入整数
Vue.prototype.checkInteger = function (item, filed) {
var value = "";
if (typeof item[filed] == "string") {
value = item[filed];
} else {
value = item[filed].toString();
}
value = value.replace(this.$commonUtils.Regex.isInteger, "");
item[filed] = value;
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment