瀏覽代碼

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

yusheng 11 月之前
父節點
當前提交
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] = '';