Преглед изворни кода

优化合计费用显示格式,保留三位小数并移除末尾零

yusheng пре 9 месеци
родитељ
комит
ac817bc0c9
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      src/utils/util.js

+ 3 - 1
src/utils/util.js

@@ -48,7 +48,6 @@ export function copyObj(obj) {
   return newobj;
 }
 
-
 export function getRecords(records) {
   const result = {};
   records.forEach((record) => {
@@ -137,6 +136,9 @@ export function getSummaries(param, key, unit) {
             return prev;
           }
         }, 0);
+        sums[index] = parseFloat(sums[index])
+          .toFixed(3)
+          .replace(/\.?0+$/, '');
         sums[index] += ' ' + unit + '';
       } else {
         sums[index] = '';