``
function handlePrice(field){
return function (val,preval) {
let result = Number.parseFloat (val)
const lastDotRe = /^\d+\.$/;
const lastZero = /^\d+\.\d*0$/;
const firstZero = /^0\d*$/;
if( lastDotRe.test(val) || lastZero.test(val) || firstZero.test(val) ) {
result = val
} else if( Number.isNaN(result) || !/^\d+(\.\d+)?$/.test( val ){
result = preVal
}
result = result.toString()
if( result.includes('.')) {
const [i,d] = result.split('.')
if( i.length > 5 || d.length > 2) {
result = preVal
}
}
else{
if( result.length > 5) {
result = preVal
}
}
this.ruleForm[field] = result
}
}
}
export default {
watch:{
'ruleForm.price': handlePrice('price'),
}
}