Browse Source

fix:保留小数后两位

chenxinlei 2 years ago
parent
commit
e3c4ac4d42
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/views/index/index.vue

+ 4 - 5
src/views/index/index.vue

@@ -221,7 +221,6 @@ export default {
       this.$baseNotify('测试消息提示', 'test', 'success', 'bottom-right')
     },
     getSummaries(param) {
-      console.log(11111);
       const { columns, data } = param;
       const sums = [];
       columns.forEach((column, index) => {
@@ -232,16 +231,16 @@ export default {
         else if (index === 3) {
           let totle = 0
           data.forEach(item => {
-            totle = totle + Number(item.generatingcapacity)
+            totle += Number(item.generatingcapacity)
           })
-          sums[index] = totle;
+          sums[index] = totle.toFixed(2);
         }
         else if (index === 4) {
           let totle = 0
           data.forEach(item => {
-            totle = totle + Number(item.outagehours)
+            totle += Number(item.outagehours)
           })
-          sums[index] = totle;
+          sums[index] = totle.toFixed(2);
         } else {
           sums[index] = '--';
         }