处理数据
This commit is contained in:
@@ -31,12 +31,13 @@ export default {
|
|||||||
},
|
},
|
||||||
getValue(item) {
|
getValue(item) {
|
||||||
let result = this.info[item.prop]
|
let result = this.info[item.prop]
|
||||||
if (item.unit == "%") result = (result * 100 || 0) + "%"
|
if (item.unit == "%") result = (result * 100 || 0).toFixed(2) + "%"
|
||||||
if (item.calc) result = item.calc()
|
if (item.calc) result = item.calc()
|
||||||
|
if (/^-?\d+(\.\d+)?$/.test(result)) result = Number(result).toFixed(2)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
getIncrement(item) {
|
getIncrement(item) {
|
||||||
let result = this.info[item.prop + "Diff"] || ""
|
let result = Number(this.info[item.prop + "Diff"] || 0).toFixed(2) || ""
|
||||||
if (result > 0) result = "↑" + result
|
if (result > 0) result = "↑" + result
|
||||||
else if (result < 0) result = "↓" + result
|
else if (result < 0) result = "↓" + result
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user