|
@@ -1261,19 +1261,23 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
|
|
|
err = fmt.Errorf("日期计算配置json解析失败失败: %s, Err:%s", config, err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ hasPercent := false
|
|
|
+ if styleConf.Nt == "percent" || isPercent {
|
|
|
+ hasPercent = true
|
|
|
+ }
|
|
|
if styleConf.Pn != 0 || styleConf.Nt != "" {
|
|
|
val := changePointDecimalPlaces(val, styleConf.Pn, styleConf.Nt, isPercent)
|
|
|
cell.ShowFormatValue = val
|
|
|
// 修复历史数据,没有保存小数位数, 重置小数位数
|
|
|
- styleConf.Decimal = new(int)
|
|
|
- hasPercent := false
|
|
|
- if styleConf.Nt == "percent" || isPercent {
|
|
|
- hasPercent = true
|
|
|
+ if styleConf.Pn > 0 {
|
|
|
+ styleConf.Decimal = new(int)
|
|
|
+ *styleConf.Decimal = getDecimalLen(val, hasPercent)
|
|
|
+ styleConf.Pn = 0
|
|
|
+ } else if styleConf.Decimal != nil {
|
|
|
+ cell.ShowFormatValue = roundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
|
|
|
}
|
|
|
- *styleConf.Decimal = getDecimalLen(val, hasPercent)
|
|
|
- styleConf.Pn = 0
|
|
|
} else if styleConf.Decimal != nil {
|
|
|
- cell.ShowFormatValue = roundNumber(cell.ShowValue, *styleConf.Decimal)
|
|
|
+ cell.ShowFormatValue = roundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
|
|
|
} else {
|
|
|
cell.ShowFormatValue = cell.ShowValue
|
|
|
}
|
|
@@ -1302,8 +1306,7 @@ func getDecimalLen(str string, isPercent bool) (decimalPlaces int) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func roundNumber(num string, decimalPlaces int) string {
|
|
|
- hasPercent := false
|
|
|
+func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
|
|
|
if strings.Contains(num, "%") {
|
|
|
hasPercent = true
|
|
|
num = strings.Trim(num, "%")
|