mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-09-20 11:52:02 +08:00
fix(grade): 修复格式化利率函数以确保正确计算和返回值
- 更新 formatRate 函数,确保在输入无效时返回 '0'。 - 调整返回值格式,将利率乘以 100 并保留两位小数,优化输出结果。
This commit is contained in:
@@ -199,7 +199,10 @@ function formatMoney(val: number | string) {
|
||||
|
||||
function formatRate(val: number | string | undefined) {
|
||||
const num = Number(val || 0)
|
||||
return Number.isFinite(num) ? num.toFixed(2).replace(/\.?0+$/, '') || '0' : '0'
|
||||
if (!Number.isFinite(num)) {
|
||||
return '0'
|
||||
}
|
||||
return (num * 100).toFixed(2).replace(/\.?0+$/, '') || '0'
|
||||
}
|
||||
|
||||
function buildGradeRule(grade: any) {
|
||||
|
||||
Reference in New Issue
Block a user