fix(测试跟踪): 测试计划报告,功能用例结果统计,统计结果为负数

--bug=1032979 --user=陈建星 【测试跟踪】测试计划-报告统计-功能用例统计分析-比例显示负数 https://www.tapd.cn/55049933/s/1437550
This commit is contained in:
AgAngle 2023-11-17 13:47:09 +08:00 committed by 刘瑞斌
parent 9273f459dd
commit d69cd76d09

View File

@ -106,16 +106,10 @@ export default {
}
let dataPercentObj = {};
let percentCount = 0;
for (let i = 0; i < data.length; i++) {
let dataName = data[i].name;
let value = data[i].value;
let percent = 100 - percentCount;
if (i !== data.length - 1) {
percent = new Number(((value / total) * 100).toFixed(0));
percentCount += percent;
}
dataPercentObj[dataName] = percent;
dataPercentObj[dataName] = new Number(((value / total) * 100).toFixed(2));
}
this.options.legend.formatter = (name) => {
let target = 0;
@ -124,13 +118,26 @@ export default {
target = data[i].value;
}
}
return name + " | " + target + " " + dataPercentObj[name] + "%";
return name + " | " + target + " " + this.formatNumber( dataPercentObj[name], 2) + "%";
};
this.options.series[0].label.formatter = (params) => {
return title + "\n" + count;
};
},
formatNumber(num, decimalPlaces) {
let fixedNum = num.toFixed(decimalPlaces); // 使 toFixed
let parts = fixedNum.split("."); //
// 0
if (parts.length > 1 && parts[1].length < decimalPlaces) {
parts[1] = parts[1].padEnd(decimalPlaces, "0");
}
//
return parts.join(".");
}
},
};
</script>