Commit a27b4b6e authored by 孙浩's avatar 孙浩

标签二表单验证

parent ca4568ea
......@@ -827,7 +827,8 @@ export default {
],
limitTwo: [
{ required: true, message: '请输入检验标准', trigger: 'blur' },
{ pattern: /^(0|[1-9]\d*)(\.\d+)?$/, message: '请输入有效的数字', trigger: 'change' }
{ pattern: /^(0|[1-9]\d*)(\.\d+)?$/, message: '请输入有效的数字', trigger: 'change' },
{ validator: this.validateMethod2, trigger: 'blur' }
],
limitThree: [
{ required: true, message: '请输入检验标准', trigger: 'blur' },
......@@ -1044,12 +1045,22 @@ export default {
methods: {
// 校验方法1
validateMethod1(rule, value, callback) {
console.log('')
if (value && value !== '' && this.inspectJbAl2o3List.limitTwo && this.inspectJbAl2o3List.limitTwo !== '') {
if (Number(this.inspectJbAl2o3List.limitOne) < Number(this.inspectJbAl2o3List.limitTwo)) {
callback()
} else {
callback(new Error('标准1要大于'))
callback(new Error('检验标准1要小于检验标准2'))
}
} else {
callback()
}
},
validateMethod2(rule, value, callback) {
if (value && value !== '' && this.inspectJbAl2o3List.limitOne && this.inspectJbAl2o3List.limitOne !== '') {
if (Number(this.inspectJbAl2o3List.limitOne) < Number(this.inspectJbAl2o3List.limitTwo)) {
callback()
} else {
callback(new Error('检验标准2要大于检验标准1'))
}
} else {
callback()
......
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