keyinput() {
let t
= this.adjustForm
.adjustCash
.charAt(0);
if(t
!= '-' && this.adjustForm
.types
=== 1){
this.adjustForm
.types
= '';
}
this.adjustForm
.adjustCash
= this.adjustForm
.adjustCash
.replace(/[^\d\.]/g,"");
if(String(t
) =='-' && this.adjustForm
.adjustCash
.charAt(0)!='-'){
this.adjustForm
.adjustCash
= '-'+this.adjustForm
.adjustCash
;
}
let index
= this.adjustForm
.adjustCash
.indexOf('.');
if(index
!= -1){
this.adjustForm
.adjustCash
= this.adjustForm
.adjustCash
.substring(0,index
+3);
}
},
keyblur() {
let num
= this.adjustForm
.adjustCash
;
if(num
=== '') return;
let v
= parseInt(this.adjustForm
.adjustCash
)+'';
if(String(num
).indexOf('-') == 0 || String(num
).indexOf('+') == 0){
v
=v
.replace(/^[\-\+]+/,'');
}
if(!/^[+-]?\d*\.?\d{1,3}$/.test(num
)) {
this.adjustForm
.adjustCash
= ''
this.$message({
message
: '请输入正确的数字',
duration
: 3000,
type
: 'warning'
});
}else if(v
.length
> 8) {
this.adjustForm
.adjustCash
= ''
this.$message({
message
: '整数部分不能超过8位',
duration
: 3000,
type
: 'warning'
});
}else {
this.adjustForm
.adjustCash
= (+num
).toFixed(2)
}
if(!/^[+-]?\d*\.?\d{1,3}$/.test(num
)){
this.adjustForm
.adjustCash
= '';
this.$message({
message
: '请输入正确的数字',
duration
: 3000,
type
: 'warning'
});
}
}
转载请注明原文地址: https://www.6miu.com/read-5029507.html