Browse Source

检验方案校验位数以及校验问题

master_hella_20240701
zhang_li 6 months ago
parent
commit
b42681c178
  1. 20
      src/utils/validator.ts
  2. 4
      src/views/qms/inspectionJob/addForm.vue
  3. 4
      src/views/qms/inspectionJob/inspectionJobMain.data.ts
  4. 2
      src/views/qms/inspectionRecord/addForm.vue
  5. 8
      src/views/qms/inspectionRecord/inspectionRecordMain.data.ts
  6. 6
      src/views/qms/inspectionTemplate/addForm.vue
  7. 14
      src/views/qms/sampleCode/sampleCode.data.ts

20
src/utils/validator.ts

@ -315,6 +315,23 @@ export function validateTwoNum(rule, value, callback) {
}
callback()
}
// 数字格式 小数点后六位
export function validateSixNum(rule, value, callback) {
if (value) {
const numReg = /^\d+(\.\d+)?$/
const numTwoReg = /^\d*\.{0,6}\d{0,6}$/
if (numReg.test(value)) {
if (numTwoReg.test(value)) {
callback()
} else {
callback(new Error('小数点后最多6位'))
}
} else {
callback(new Error('请输入数字'))
}
}
callback()
}
// 小数点前位数不得大于6位
export function validateNumSix(rule, value, callback) {
if (value) {
@ -804,5 +821,6 @@ export default {
validateYS,
validateMaxNumber5,
validatePercent,
validateNumSix
validateNumSix,
validateSixNum
}

4
src/views/qms/inspectionJob/addForm.vue

@ -367,7 +367,7 @@
item.inspectionJobCharacteristicsUpdateReqVO = item.inspectionJobCharacteristicsRespVO
//
allSamplePieceSize.value += parseFloat((parseFloat(item.inspectionJobCharacteristicsUpdateReqVO.sampleQty) * parseFloat(item.inspectionJobCharacteristicsUpdateReqVO.samplePieceSize)).toFixed(2))
allSamplePieceSize.value += parseFloat((parseFloat(item.inspectionJobCharacteristicsUpdateReqVO.sampleQty) * parseFloat(item.inspectionJobCharacteristicsUpdateReqVO.samplePieceSize)).toFixed(6))
// rules.value['inspectionJobCharacteristicsUpdateReqVO.quantifyCapping'][0].required = true
if (!item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList) {
//
@ -430,7 +430,7 @@
if (data.value.packageList[i].sampleAmount == null) {
if (allSamplePieceSize.value > data.value.packageList[i].amount) {
data.value.packageList[i].sampleAmount = data.value.packageList[i].amount
allSamplePieceSize.value = parseFloat((allSamplePieceSize.value - data.value.packageList[i].amount).toFixed(2))
allSamplePieceSize.value = parseFloat((allSamplePieceSize.value - data.value.packageList[i].amount).toFixed(6))
} else {
data.value.packageList[i].sampleAmount = allSamplePieceSize.value
allSamplePieceSize.value = 0

4
src/views/qms/inspectionJob/inspectionJobMain.data.ts

@ -2,7 +2,7 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter2 } from '@/utils/formatTime'
import { validateHanset, validateEmail } from '@/utils/validator'
import { dateFormatter } from '@/utils/formatTime'
import { validateTwoNum } from '@/utils/validator'
import { validateTwoNum,validateSixNum} from '@/utils/validator'
const { t } = useI18n() // 国际化
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
const resultEntryMethodList = getStrDictOptions(DICT_TYPE.INSPECTION_CHARACTERISTICS_RESULT_ENTRY)
@ -610,5 +610,5 @@ export const InspectionJobPackage = useCrudSchemas(reactive<CrudSchema[]>([
//表单校验
export const InspectionJobPackageRules = reactive({
sampleAmount: [required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}]
{ validator:validateSixNum, trigger: 'blur'}]
})

2
src/views/qms/inspectionRecord/addForm.vue

@ -244,7 +244,7 @@ const tableFormBlur = (field, val,row)=>{
row.qualifiedAmount = 0
}else{
row.qualifiedAmount = row.amount - val
row.qualifiedAmount = row.qualifiedAmount.toFixed(2)
row.qualifiedAmount = row.qualifiedAmount.toFixed(6)
}
}

8
src/views/qms/inspectionRecord/inspectionRecordMain.data.ts

@ -716,18 +716,18 @@ export const InspectionRecordPackage = useCrudSchemas(reactive<CrudSchema[]>([
export const InspectionRecordPackageRules = reactive({
qualifiedAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
{ validator:validateTwoNum, message: '小数点后最多6位', trigger: 'blur'}
],
frozenAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
{ validator:validateTwoNum, message: '小数点后最多6位', trigger: 'blur'}
],
destroyAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
{ validator:validateTwoNum, message: '小数点后最多6位', trigger: 'blur'}
],
noQualifiedAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
{ validator:validateTwoNum, message: '小数点后最多6位', trigger: 'blur'}
],
})

6
src/views/qms/inspectionTemplate/addForm.vue

@ -815,7 +815,7 @@ const submitForm = async () => {
)
if (arr && arr.length > 0) {
const str = arr.map((item) => item.description).join(',')
message.error(`${str}是否设定上线,是否设定下限,是否设定目标值至少一项为是`)
message.error(`${str}工序是否设定上线,是否设定下限,是否设定目标值至少一项为是`)
return
}
// ,,
@ -833,7 +833,7 @@ const submitForm = async () => {
)
if (arr1 && arr1.length > 0) {
const str = arr1.map((item) => item.description).join(',')
message.error(`${str}上限值,下限值,目标值小数位数不可以大于小数位`)
message.error(`${str}工序上限值,下限值,目标值小数位数不可以大于小数位`)
return
}
//
@ -851,7 +851,7 @@ const submitForm = async () => {
console.log(99,arr2)
if (arr2 && arr2.length > 0) {
const str = arr2.map((item) => item.description).join(',')
message.error(`${str}上限值应大于目标值大于下限值`)
message.error(`${str}工序上限值应大于目标值大于下限值`)
return
}
if (formType.value == 'create') {

14
src/views/qms/sampleCode/sampleCode.data.ts

@ -8,13 +8,13 @@ export const SampleCodeRules = reactive({
code: [required],
batchLowLimiting: [{ validator:validateNum, message: '请输入整数', trigger: 'blur'}],
batchUpperLimiting: [{ required:true, message: '该项为必填', trigger: 'blur'}, { validator:validateNum, message: '请输入整数', trigger: 'blur'}],
s1: [{ required }],
s2: [{ required }],
s3: [{ required }],
s4: [{ required }],
g1: [{ required }],
g2: [{ required }],
g3: [{ required }]
s1: [ required ],
s2: [required ],
s3: [ required ],
s4: [ required ],
g1: [ required ],
g2: [ required ],
g3: [ required ]
})
const samplingSchemeList = await getSamplingScheme()
export const SampleCode = useCrudSchemas(reactive<CrudSchema[]>([

Loading…
Cancel
Save