Explorar o código

数字逗号问题

Shannon_mu hai 1 ano
pai
achega
61413517e6

+ 32 - 24
energyManagement/src/views/refrigeration/energySavingPlatform/dataOverView.vue

@@ -2,7 +2,7 @@
     <div class="date-over-wrap">
         <Label label="数据总览" :icon="icon" />
         <div class="list-wrap">
-            <div class="list-item-wrap" :style="{background : `${item.background}`}" v-for="(item, index) in list" :key="index">
+            <div class="list-item-wrap" :style="{ background: `${item.background}` }" v-for="(item, index) in list" :key="index">
                 <div class="list-item-value">
                     {{ item.value }}
                     <div class="list-item-unit">{{ item.unit }}</div>
@@ -27,66 +27,75 @@ export default {
                 {
                     label: '年度累积用电量',
                     value: '50.52',
-                    unit : 'kw.h',
+                    unit: 'kw.h',
                     icon: require('@assets/img/energyIcon/icon_cop.png'),
-                    background : 'linear-gradient(270deg, #04bce9 0%, #52c1de 100%)'
+                    background: 'linear-gradient(270deg, #04bce9 0%, #52c1de 100%)'
                 },
                 {
                     label: '年度累计冷量',
                     value: '232.88',
-                    unit : 'kwh',
+                    unit: 'kwh',
                     icon: require('@assets/img/energyIcon/icon_ratio2.png'),
-                    background : 'linear-gradient(270deg, #44B6FB 100%, #4D9BFF 0%)'
+                    background: 'linear-gradient(270deg, #44B6FB 100%, #4D9BFF 0%)'
                 },
                 {
                     label: '年度累计节电量',
                     value: '27.13',
-                    unit : 'kw.h',
+                    unit: 'kw.h',
                     icon: require('@assets/img/energyIcon/icon_cop.png'),
-                    background : 'linear-gradient(270deg, #F49153 100%, #F27762 0%)'
+                    background: 'linear-gradient(270deg, #F49153 100%, #F27762 0%)'
                 },
                 {
                     label: '年度累计节碳量',
                     value: '73.78',
-                    unit : '吨',
+                    unit: '吨',
                     icon: require('@assets/img/energyIcon/icon_ratio2.png'),
-                    background : 'linear-gradient(270deg, #44B6FB 100%, #4D9BFF 0%)'
+                    background: 'linear-gradient(270deg, #44B6FB 100%, #4D9BFF 0%)'
                 },
                 {
                     label: '年度累计节电费',
                     value: '32.56',
-                    unit : '元',
+                    unit: '元',
                     icon: require('@assets/img/energyIcon/icon_ratio2.png'),
-                    background : 'linear-gradient(270deg, #D260CD 100%, #914FD1 0%)'
+                    background: 'linear-gradient(270deg, #D260CD 100%, #914FD1 0%)'
                 }
             ]
         };
     },
 
-    mounted() {this.getdata()},
+    mounted() {
+        this.getdata();
+    },
 
     methods: {
-        getdata(){
-            this.$http.get('/sc-energy/board/getProjectDataInfo').then(({data})=>{
-                this.list[0].value = data.powerConsumption;
-                this.list[1].value = data.refrigerationCapacity;
-                this.list[2].value = data.powerSaving;
-                this.list[3].value = data.carbonSaving;
-                this.list[4].value = data.utilities;
-            })
+        formatNum: (str, sun) => {
+            return str
+                .split('')
+                .reverse()
+                .reduce((cur, next, index) => {
+                    return (index % sun ? next : next + ',') + cur;
+                });
+        },
+        getdata() {
+            this.$http.get('/sc-energy/board/getProjectDataInfo').then(({ data }) => {
+                this.list[0].value =  this.formatNum(Math.ceil(data.powerConsumption)+'',3);
+                this.list[1].value =  this.formatNum(Math.ceil(data.refrigerationCapacity)+'',3);
+                this.list[2].value =  this.formatNum(Math.ceil(data.powerSaving)+'',3);
+                this.list[3].value =  this.formatNum(Math.ceil(data.carbonSaving)+'',3);
+                this.list[4].value =  this.formatNum(Math.ceil(data.utilities)+'',3);
+            });
         }
     }
 };
 </script>
 
 <style lang="scss" scoped>
-
 .date-over-wrap {
     height: 100%;
     display: flex;
     flex-direction: column;
     justify-content: center;
-    margin : 0 20px 0 20px
+    margin: 0 20px 0 20px;
 }
 .list-wrap {
     margin-top: 2%;
@@ -113,8 +122,7 @@ export default {
     color: #ffffff;
 
     display: flex;
-    align-items:baseline; 
-
+    align-items: baseline;
 }
 
 .list-item-unit {

+ 40 - 47
energyManagement/src/views/refrigeration/energySavingPlatform/energyAnalyze.vue

@@ -107,15 +107,15 @@ export default {
     },
 
     mounted() {
-        window.addEventListener('resize', ()=>{
-            if(this.$refs.charts){
+        window.addEventListener('resize', () => {
+            if (this.$refs.charts) {
                 this.$refs.charts.echart.resize();
             }
-        })
+        });
     },
 
     methods: {
-        setData({data,standardCop,month}) {
+        setData({ data, month }) {
             this.options.xAxis[0].data = month;
             if (this.type == 1) {
                 this.label = '月度能效趋势';
@@ -138,22 +138,7 @@ export default {
                             }
                         },
                         symbol: 'none',
-                        data: data,
-                        markLine: {
-                            symbol: 'none',
-                            data: [
-                                {
-                                    name: '基准值',
-                                    yAxis: standardCop,
-                                    lineStyle: {
-                                        color: '#27EA83'
-                                    }
-                                }
-                            ],
-                            label: {
-                                show: false
-                            }
-                        }
+                        data: data[0]
                     },
                     {
                         type: 'line',
@@ -161,14 +146,18 @@ export default {
                         name: '基准值',
                         itemStyle: {
                             color: '#27EA83'
-                        }
+                        },
+                        lineStyle: {
+                            type: 'dashed'
+                        },
+                        data: data[1]
                     }
                 ];
-                this.options.yAxis[0].max = 10
+
             } else if (this.type == '2') {
                 this.label = '月度电量分析';
                 this.icon = require('../../../assets/img/energyIcon/icon_dianliang.png');
-                this.options.legend.data = ['用电量', '基准用电量'];   
+                this.options.legend.data = ['用电量', '基准用电量'];
                 this.options.series = [
                     {
                         name: '用电量',
@@ -202,34 +191,38 @@ export default {
                 ];
             }
         },
-        getData(){
+        getData() {
             if (this.type == 1) {
-
-                let month = [],cop=[],standardCop=0;
-                this.$http.get('/sc-energy/board/getMonthlyEnergyTendency').then(({data})=>{
-                    data.map(item=>{
-                        month.push(item.month);
-                        cop.push(item.cop);
-                        standardCop = item.standardCop
+                let month = [],
+                    cop = [],
+                    standardCop = [];
+                this.$http
+                    .get('/sc-energy/board/getMonthlyEnergyTendency')
+                    .then(({ data }) => {
+                        data.map((item) => {
+                            month.push(item.month);
+                            cop.push(item.cop);
+                            standardCop.push(item.standardCop)
+                        });
+                        this.setData({ data: [cop,standardCop], month: month });
                     })
-                    this.setData({data:cop,standardCop:standardCop,month:month})
-                }).catch(() => { });
-
-            }else if (this.type == 2) {
- 
-                let month = [],powerConsumption=[],standardPowerConsumption=[]; 
-                this.$http.get('/sc-energy/board/getMonthlyElectricalAnalysis').then(({data})=>{
-                    data.map(item=>{
-                        month.push(item.month);
-                        powerConsumption.push(item.powerConsumption);
-                        standardPowerConsumption.push(item.standardPowerConsumption)
+                    .catch(() => {});
+            } else if (this.type == 2) {
+                let month = [],
+                    powerConsumption = [],
+                    standardPowerConsumption = [];
+                this.$http
+                    .get('/sc-energy/board/getMonthlyElectricalAnalysis')
+                    .then(({ data }) => {
+                        data.map((item) => {
+                            month.push(item.month);
+                            powerConsumption.push(item.powerConsumption);
+                            standardPowerConsumption.push(item.standardPowerConsumption);
+                        });
+                        this.setData({ data: [powerConsumption, standardPowerConsumption], month: month });
                     })
-                    this.setData({data:[powerConsumption,standardPowerConsumption],month:month})
-                }).catch(() => { });
-                
+                    .catch(() => {});
             }
-   
-            
         }
     }
 };

+ 1 - 1
energyManagement/src/views/refrigeration/energySavingPlatform/energyEfficiencyRatio.vue

@@ -44,7 +44,7 @@ methods: {
     getdata(){
         this.$http.get('/sc-energy/board/getProjectDataInfo').then(({data})=>{
             this.list[0].value = data.cop;
-            this.list[1].value = data.rate * 100 +'%';
+            this.list[1].value = Math.ceil(data.rate * 100) +'%';
         })
     }
 }