diff --git a/src/views/dish/dish/index.vue b/src/views/dish/dish/index.vue index f2fb7ad2..f366a79d 100644 --- a/src/views/dish/dish/index.vue +++ b/src/views/dish/dish/index.vue @@ -1661,6 +1661,7 @@ } }) }else{ + //littleWeight largeWeight baseForm.littleWeight baseForm.largeWeight param.littlePrice = Number(param.littlePrice)*100; param.largePrice = Number(param.largePrice)*100; param.littleMaterialCost = Number(param.littleMaterialCost)*100; @@ -1682,22 +1683,31 @@ } }) } - // console.log(param.materialList) - if (this.title === "新增") { - addMenuDishesApi(param).then(response => { - this.openDish = false; - this.$modal.msgSuccess("新增成功"); - this.getList(); - }); - this.btnLoading=false; - } else { - editMenuDishesApi(param).then(response => { - this.openDish = false; - this.$modal.msgSuccess("修改成功"); - this.getList(); - }); - this.btnLoading=false; - } + let sumWeight = 0 + param.materialList.forEach(item=>{ + sumWeight = item.weight+sumWeight; + }) + if(sumWeight>param.weight){ + this.btnLoading=false + sumWeight=0 + this.$modal.msgError("组成成分总克数不可大于菜品份量"); + return false + } + if (this.title === "新增") { + addMenuDishesApi(param).then(response => { + this.openDish = false; + this.$modal.msgSuccess("新增成功"); + this.getList(); + }); + this.btnLoading=false; + } else { + editMenuDishesApi(param).then(response => { + this.openDish = false; + this.$modal.msgSuccess("修改成功"); + this.getList(); + }); + this.btnLoading=false; + } } } })