Explorar o código

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

yusheng hai 10 meses
pai
achega
ac817bc0c9
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  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] = '';