diff --git a/src/utils/validator.ts b/src/utils/validator.ts index 7d981354b..8a9d70261 100644 --- a/src/utils/validator.ts +++ b/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 } diff --git a/src/views/qms/inspectionJob/addForm.vue b/src/views/qms/inspectionJob/addForm.vue index aaa8f4bb8..3c1069f03 100644 --- a/src/views/qms/inspectionJob/addForm.vue +++ b/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 diff --git a/src/views/qms/inspectionJob/inspectionJobMain.data.ts b/src/views/qms/inspectionJob/inspectionJobMain.data.ts index 0a658181a..a9d51f446 100644 --- a/src/views/qms/inspectionJob/inspectionJobMain.data.ts +++ b/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([ //表单校验 export const InspectionJobPackageRules = reactive({ sampleAmount: [required, - { validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}] + { validator:validateSixNum, trigger: 'blur'}] }) diff --git a/src/views/qms/inspectionRecord/addForm.vue b/src/views/qms/inspectionRecord/addForm.vue index 4891365bc..c430495c8 100644 --- a/src/views/qms/inspectionRecord/addForm.vue +++ b/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) } } diff --git a/src/views/qms/inspectionRecord/inspectionRecordMain.data.ts b/src/views/qms/inspectionRecord/inspectionRecordMain.data.ts index 07e3085c3..01de70af0 100644 --- a/src/views/qms/inspectionRecord/inspectionRecordMain.data.ts +++ b/src/views/qms/inspectionRecord/inspectionRecordMain.data.ts @@ -716,18 +716,18 @@ export const InspectionRecordPackage = useCrudSchemas(reactive([ 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'} ], }) diff --git a/src/views/qms/inspectionTemplate/addForm.vue b/src/views/qms/inspectionTemplate/addForm.vue index 3ac8f2979..d19caa8db 100644 --- a/src/views/qms/inspectionTemplate/addForm.vue +++ b/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') { diff --git a/src/views/qms/sampleCode/sampleCode.data.ts b/src/views/qms/sampleCode/sampleCode.data.ts index 5c9b96ee3..3c7a5eaee 100644 --- a/src/views/qms/sampleCode/sampleCode.data.ts +++ b/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([