Browse Source

校验样本字码

hella_online_20240829
zhaoyiran 5 months ago
parent
commit
418390738f
  1. 13
      src/utils/validator.ts
  2. 4
      src/views/qms/aql/aql.data.ts

13
src/utils/validator.ts

@ -788,6 +788,19 @@ export function validatePercent(rule, value, callback){
}
}
export function validateSampleCode(rule, value, callback){
if (value) {
const orgReg =/[A-Z]/
if (orgReg.test(value)) {
callback()
} else {
callback(new Error('样本字码错误'))
}
} else {
callback()
}
}
export default {
validateCode,
validateEmail,

4
src/views/qms/aql/aql.data.ts

@ -1,13 +1,13 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import { getSamplingScheme } from "@/api/qms/aql";
import { validateNum } from "@/utils/validator";
import {validateNum, validateSampleCode} from "@/utils/validator";
// 表单校验
export const AqlRules = reactive({
code: [required],
inspectionQualification: [required],
sampleCharacterCode: [required, {max: 1, message: '长度不得超过1个字符', trigger: 'blur' }],
sampleCharacterCode: [required, {max: 1, message: '长度不得超过1个字符', trigger: 'blur' }, {validator: validateSampleCode, message: '请输入1个大写字母', trigger: 'blur' }],
sampleQty: [required,{ validator: validateNum, message: '请输入整数', trigger: 'blur' }],
a0separator010: [required,{ validator: validateNum, message: '请输入整数', trigger: 'blur' }],
r0separator010: [required,{ validator: validateNum, message: '请输入整数', trigger: 'blur' }],

Loading…
Cancel
Save