This commit is contained in:
‘937886381’
2026-01-07 16:47:49 +08:00
parent 51e66cf6e1
commit b76f3bfd37
164 changed files with 4179 additions and 2297 deletions

View File

@@ -84,10 +84,18 @@ export default {
}
})
},
getRateFlag(rate) {
if (isNaN(rate) || rate === null || rate === undefined) return 0;
return +(rate >= 100 || rate === 0); // + 号将布尔值转为数字true→1false→0
},
getRateFlag(rate, real, target) {
if (isNaN(rate) || rate === null || rate === undefined) return 0;
// 1. 完成率 >= 100 => 达标
if (rate >= 100) return 1;
// 2. 完成率 = 0 且 (目标值=0 或 实际值=目标值=0) => 达标
if (rate === 0 && target === 0) return 1;
// 其他情况 => 未达标
return 0;
},
updateChart(data) {
// 修复核心:正确获取默认值(调用 factory 函数)
@@ -104,12 +112,12 @@ export default {
// 整合flag字段
this.ytdIncomeData = {
...incomeItem,
flag: this.getRateFlag(incomeItem.rate)
flag: this.getRateFlag(incomeItem.rate, incomeItem.real, incomeItem.budget)
};
this.ytdCostData = {
...costItem,
flag: this.getRateFlag(costItem.rate)
flag: this.getRateFlag(costItem.rate, costItem.real, costItem.budget)
};
console.log('累计收入数据:', this.ytdIncomeData);