fix(mealSurplus): 修复进度条计算,负值边界保护防止溢出显示

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-11 11:58:54 +08:00
co-authored by Claude Opus 4.7
parent 902e3115d8
commit 8f92dbea26
@@ -189,7 +189,8 @@ export default {
// 营养秤实时数据
if (res.data.nutritionList && res.data.nutritionList.length) {
res.data.nutritionList.map(function(item) {
item.progress = item.madeWeightKg ? ((1 - item.remainWeightKg / item.madeWeightKg) * 100) + '%' : '0%';
var pct = item.totalServeKg ? (1 - item.remainWeightKg / item.totalServeKg) * 100 : 0;
item.progress = Math.max(0, Math.min(100, pct)) + '%';
return item;
});
_this.nutritionList = res.data.nutritionList;