修bug
This commit is contained in:
@@ -225,11 +225,11 @@ export default {
|
||||
|
||||
// 保存配方
|
||||
const handleSaveRecipe = async () => {
|
||||
// 验证占比总和是否为100
|
||||
// 验证占比总和是否不超过100
|
||||
const totalPercentage = localIngredientDetails.value.reduce((sum, ing) => sum + ing.percentage, 0);
|
||||
|
||||
if (Math.abs(totalPercentage - 100) > 0.001) { // 允许浮点数误差
|
||||
ElMessage.error(`原料总占比必须为100%,当前为${totalPercentage.toFixed(2)}%`);
|
||||
if (totalPercentage > 100.001) { // 允许浮点数误差
|
||||
ElMessage.error(`原料总占比不能超过100%,当前为${totalPercentage.toFixed(2)}%`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user