|
@@ -1228,9 +1228,20 @@ func changePointDecimalPlaces(str string, changeNum int, numberType string, isPe
|
|
|
if isPercent {
|
|
|
if numberType == "number" { //百分数转成小数
|
|
|
val = val / 100
|
|
|
- decimalPlaces += 2
|
|
|
- if decimalPlaces > 0 {
|
|
|
- decimalPlaces = 0
|
|
|
+ if decimalPlaces > 2 {
|
|
|
+ decimalPlaces += 2
|
|
|
+ } else if decimalPlaces == 1 {
|
|
|
+ decimalPlaces += 1
|
|
|
+ } else if decimalPlaces == 0 {
|
|
|
+ if len(str) == 1 {
|
|
|
+ decimalPlaces = 2
|
|
|
+ } else if len(str) == 2 {
|
|
|
+ if str[1] == '0' {
|
|
|
+ decimalPlaces = 1
|
|
|
+ } else {
|
|
|
+ decimalPlaces = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
isPercent = false
|
|
|
}
|
|
@@ -1238,6 +1249,8 @@ func changePointDecimalPlaces(str string, changeNum int, numberType string, isPe
|
|
|
if numberType == "percent" {
|
|
|
if decimalPlaces > 2 {
|
|
|
decimalPlaces -= 2
|
|
|
+ } else if decimalPlaces == 1 {
|
|
|
+ decimalPlaces = 0
|
|
|
}
|
|
|
val = val * 100
|
|
|
}
|