From e0bf75d6a6c7a6fae6f79ac79de741d22c9fe9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Thu, 9 Mar 2023 22:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E7=9A=84=E6=A0=A1=E9=AA=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?3=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jshERP-web/src/utils/validate.js | 10 ++++++++++ jshERP-web/src/views/system/modules/UnitModal.vue | 14 +++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/jshERP-web/src/utils/validate.js b/jshERP-web/src/utils/validate.js index aa725f2d..1c400719 100644 --- a/jshERP-web/src/utils/validate.js +++ b/jshERP-web/src/utils/validate.js @@ -38,3 +38,13 @@ export function isDecimalTwo (s) { let reg = /^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^([^0][0-9]+|0)$/ return reg.test(s) } + +/** + * 三位小数 + * @param {*} s + */ +export function isDecimalThree (s) { + let reg = /^(([^0][0-9]+|0)\.([0-9]{1,3})$)|^([^0][0-9]+|0)$/ + return reg.test(s) +} + diff --git a/jshERP-web/src/views/system/modules/UnitModal.vue b/jshERP-web/src/views/system/modules/UnitModal.vue index a73b4a1a..4c8c5d2a 100644 --- a/jshERP-web/src/views/system/modules/UnitModal.vue +++ b/jshERP-web/src/views/system/modules/UnitModal.vue @@ -54,7 +54,7 @@ import pick from 'lodash.pick' import {addUnit,editUnit,checkUnit } from '@/api/api' import {autoJumpNextInput} from "@/utils/util" - import {isDecimalTwo} from "@/utils/validate" + import {isDecimalThree} from "@/utils/validate" import {mixinDevice} from '@/utils/mixin' export default { name: "UnitModal", @@ -131,8 +131,8 @@ that.confirmLoading = false; return; } - if(!isDecimalTwo(formData.ratio)) { - that.$message.warning('抱歉,比例只能为数字,最多两位小数!') + if(!isDecimalThree(formData.ratio)) { + that.$message.warning('抱歉,比例只能为数字,最多三位小数!') that.confirmLoading = false return } @@ -143,8 +143,8 @@ that.confirmLoading = false; return; } - if(!isDecimalTwo(formData.ratioTwo)) { - that.$message.warning('抱歉,比例2只能为数字,最多两位小数!') + if(!isDecimalThree(formData.ratioTwo)) { + that.$message.warning('抱歉,比例2只能为数字,最多三位小数!') that.confirmLoading = false return } @@ -155,8 +155,8 @@ that.confirmLoading = false; return; } - if(!isDecimalTwo(formData.ratioThree)) { - that.$message.warning('抱歉,比例3只能为数字,最多两位小数!') + if(!isDecimalThree(formData.ratioThree)) { + that.$message.warning('抱歉,比例3只能为数字,最多三位小数!') that.confirmLoading = false return }