将计量单位比例的校验改为3位小数
This commit is contained in:
parent
4784882112
commit
e0bf75d6a6
@ -38,3 +38,13 @@ export function isDecimalTwo (s) {
|
||||
let reg = /^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^([^0][0-9]+|0)$/
|
||||
return reg.test(s)
|
||||
}
|
||||
|
||||
/**
|
||||
* 三位小数
|
||||
* @param {*} s
|
||||
*/
|
||||
export function isDecimalThree (s) {
|
||||
let reg = /^(([^0][0-9]+|0)\.([0-9]{1,3})$)|^([^0][0-9]+|0)$/
|
||||
return reg.test(s)
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
import pick from 'lodash.pick'
|
||||
import {addUnit,editUnit,checkUnit } from '@/api/api'
|
||||
import {autoJumpNextInput} from "@/utils/util"
|
||||
import {isDecimalTwo} from "@/utils/validate"
|
||||
import {isDecimalThree} from "@/utils/validate"
|
||||
import {mixinDevice} from '@/utils/mixin'
|
||||
export default {
|
||||
name: "UnitModal",
|
||||
@ -131,8 +131,8 @@
|
||||
that.confirmLoading = false;
|
||||
return;
|
||||
}
|
||||
if(!isDecimalTwo(formData.ratio)) {
|
||||
that.$message.warning('抱歉,比例只能为数字,最多两位小数!')
|
||||
if(!isDecimalThree(formData.ratio)) {
|
||||
that.$message.warning('抱歉,比例只能为数字,最多三位小数!')
|
||||
that.confirmLoading = false
|
||||
return
|
||||
}
|
||||
@ -143,8 +143,8 @@
|
||||
that.confirmLoading = false;
|
||||
return;
|
||||
}
|
||||
if(!isDecimalTwo(formData.ratioTwo)) {
|
||||
that.$message.warning('抱歉,比例2只能为数字,最多两位小数!')
|
||||
if(!isDecimalThree(formData.ratioTwo)) {
|
||||
that.$message.warning('抱歉,比例2只能为数字,最多三位小数!')
|
||||
that.confirmLoading = false
|
||||
return
|
||||
}
|
||||
@ -155,8 +155,8 @@
|
||||
that.confirmLoading = false;
|
||||
return;
|
||||
}
|
||||
if(!isDecimalTwo(formData.ratioThree)) {
|
||||
that.$message.warning('抱歉,比例3只能为数字,最多两位小数!')
|
||||
if(!isDecimalThree(formData.ratioThree)) {
|
||||
that.$message.warning('抱歉,比例3只能为数字,最多三位小数!')
|
||||
that.confirmLoading = false
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user