Commit 6bd1734b authored by Mac's avatar Mac

收款单

parent 46f98eac
......@@ -273,6 +273,35 @@ export default{
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
},
//验证只能输入整数【负数:isMinus传true】
Vue.prototype.checkInteger = function (item, filed, isMinus) {
var value = "" + item[filed]; //转字符串
var t = value.charAt(0);
value = value.replace(this.$commonUtils.Regex.isInteger, "");
//是否允许负数
if (isMinus && t == '-') {
value = '-' + value;
}
item[filed] = value;
},
//验证只能输入2位小数【负数:isMinus传true】
Vue.prototype.checkPrice = function (item, filed, isMinus) {
var value = "" + item[filed]; //转字符串
var t = value.charAt(0);
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 (isMinus && t == '-') {
value = '-' + value;
}
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