From e2120a1b42dfb9d35a68a3484822e27fa842cdc8 Mon Sep 17 00:00:00 2001 From: zhaoyiran Date: Fri, 15 Nov 2024 16:12:54 +0800 Subject: [PATCH] =?UTF-8?q?YT-1019=E9=87=87=E8=B4=AD=E4=BB=B6=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=96=B0=E5=A2=9E=E4=B8=AD=E6=95=B0=E9=87=8F=E4=B8=BA?= =?UTF-8?q?0=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/validator.ts | 10 ++++++++++ .../purchasePackage/purchasePackage.data.ts | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/validator.ts b/src/utils/validator.ts index 83e031265..46d266b35 100644 --- a/src/utils/validator.ts +++ b/src/utils/validator.ts @@ -814,6 +814,16 @@ export function validateSampleCode(rule, value, callback){ } } +// 校验正数 +export function validatePositiveNumber(rule, value, callback){ + const numericValue = Number(value); + if (numericValue > 0) { + callback(); + } else { + callback(new Error('必须是一个正数')); + } +} + export default { validateCode, validateEmail, diff --git a/src/views/wms/basicDataManage/labelManage/purchasePackage/purchasePackage.data.ts b/src/views/wms/basicDataManage/labelManage/purchasePackage/purchasePackage.data.ts index 75021aa2e..e35cc5bcd 100644 --- a/src/views/wms/basicDataManage/labelManage/purchasePackage/purchasePackage.data.ts +++ b/src/views/wms/basicDataManage/labelManage/purchasePackage/purchasePackage.data.ts @@ -11,6 +11,7 @@ import { SupplierdeliverRecordMain } from "@/views/wms/purchasereceiptManage/sup import * as SupplierdeliverRecordMainApi from "@/api/wms/supplierdeliverRecordMain"; import * as ItemPackageApi from "@/api/wms/itempackage"; import {Itempackaging} from "@/views/wms/basicDataManage/itemManage/itempackage/itempackage.data"; +import {validatePositiveNumber} from "@/utils/validator"; // 表单校验 export const PackageRules = reactive({ @@ -610,7 +611,8 @@ export const PackageRulesInventor = reactive({ { required: true, message: '请选择物料代码', trigger: 'change' } ], qty: [ - { required: true, message: '请输入数量', trigger: 'blur' } + { required: true, message: '请输入数量', trigger: 'blur' }, + { validator:validatePositiveNumber, message: '必须是一个正数', trigger: 'change'} ], toDockCode: [ { required: true, message: '请选择月台代码', trigger: 'change' }