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