From fe40a18398daf6198e4ca6445b3ac42b2e80470d Mon Sep 17 00:00:00 2001 From: zhang_li <2235006734@qqq.com> Date: Wed, 24 Apr 2024 10:37:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E9=AA=8C=E6=A8=A1=E6=9D=BF=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/validator.ts | 14 +++++++++++++- .../basicDataManage/inspectionTemplate/addForm.vue | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/utils/validator.ts b/src/utils/validator.ts index 3588e20a2..7d981354b 100644 --- a/src/utils/validator.ts +++ b/src/utils/validator.ts @@ -315,7 +315,18 @@ export function validateTwoNum(rule, value, callback) { } callback() } +// 小数点前位数不得大于6位 +export function validateNumSix(rule, value, callback) { + if (value) { + if (value.split('.')[0].length > 6) {// 校验value值不能大于10000 + callback(new Error('版本号小数点前位数不得大于6')) + }else{ + callback() + } + } + callback() +} // 数字格式 小数点后两位 小数点前保留五位 export function validateTwoNumThree(rule, value, callback) { @@ -792,5 +803,6 @@ export default { validateChargeperson, validateYS, validateMaxNumber5, - validatePercent + validatePercent, + validateNumSix } diff --git a/src/views/qms/basicDataManage/inspectionTemplate/addForm.vue b/src/views/qms/basicDataManage/inspectionTemplate/addForm.vue index 61f9e699b..cd63b2c85 100644 --- a/src/views/qms/basicDataManage/inspectionTemplate/addForm.vue +++ b/src/views/qms/basicDataManage/inspectionTemplate/addForm.vue @@ -434,7 +434,7 @@ import * as DynamicRuleApi from '@/api/qms/dynamicRule' //动态修改规则 import { DynamicRule } from '@/views/qms/basicDataManage/dynamicRule/dynamicRule.data' //动态修改规则 import * as SelectedSetApi from '@/api/qms/selectedSet' //选择集 import { SelectedSet } from '@/views/qms/basicDataManage/selectedSet/selectedSet.data' //选择集 -import { validateInteger,validateTwoNum,validateMaxNumber5 } from '@/utils/validator' +import { validateInteger,validateTwoNum,validateMaxNumber5,validateNumSix } from '@/utils/validator' const message = useMessage() // 消息弹窗 const props = defineProps({ @@ -501,6 +501,7 @@ const rules = ref({ description: [{ required: true, message: '请填写描述', trigger: 'blur' }], version: [ { required: true, message: '请填写版本', trigger: 'blur' }, + { validator:validateNumSix, message: '版本号小数点前位数不得大于6', trigger: 'blur'}, { validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'} ], inspectionCode: [{ required: true, message: '请选择检验方案模板', trigger: 'blur' }], @@ -562,6 +563,7 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any formType.value = type if (row) { data.value = JSON.parse(JSON.stringify(row)) + data.value.version = String(data.value.version) let list = await InspectionProcessPageApi.getListByTempleteCode(row.code) list.forEach((item, index) => { editableTabsValue.value = index + 1