给商品和计量单位增加对小数比例的兼容

This commit is contained in:
季圣华
2023-03-08 21:39:23 +08:00
parent 84026b5f9c
commit 00cabc2612
3 changed files with 98 additions and 67 deletions

View File

@@ -54,6 +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 {mixinDevice} from '@/utils/mixin'
export default {
name: "UnitModal",
@@ -124,20 +125,41 @@
that.confirmLoading = false;
return;
}
if(formData.otherUnit && !formData.ratio) {
that.$message.warning('抱歉比例不能为空');
that.confirmLoading = false;
return;
if(formData.otherUnit) {
if(!formData.ratio) {
that.$message.warning('抱歉比例不能为空');
that.confirmLoading = false;
return;
}
if(!isDecimalTwo(formData.ratio)) {
that.$message.warning('抱歉比例只能为数字最多两位小数')
that.confirmLoading = false
return
}
}
if(formData.otherUnitTwo && !formData.ratioTwo) {
that.$message.warning('抱歉比例2不能为空');
that.confirmLoading = false;
return;
if(formData.otherUnitTwo) {
if(!formData.ratioTwo) {
that.$message.warning('抱歉比例2不能为空');
that.confirmLoading = false;
return;
}
if(!isDecimalTwo(formData.ratioTwo)) {
that.$message.warning('抱歉比例2只能为数字最多两位小数')
that.confirmLoading = false
return
}
}
if(formData.otherUnitThree && !formData.ratioThree) {
that.$message.warning('抱歉比例3不能为空');
that.confirmLoading = false;
return;
if(formData.otherUnitThree) {
if(!formData.ratioThree) {
that.$message.warning('抱歉比例3不能为空');
that.confirmLoading = false;
return;
}
if(!isDecimalTwo(formData.ratioThree)) {
that.$message.warning('抱歉比例3只能为数字最多两位小数')
that.confirmLoading = false
return
}
}
if(!formData.otherUnitTwo && formData.otherUnitThree) {
that.$message.warning('抱歉需要先输入副单位2再输入副单位3');