SunZehao vor 9 Monaten
Ursprung
Commit
65b2a7310e
1 geänderte Dateien mit 74 neuen und 71 gelöschten Zeilen
  1. 74 71
      src/components/assessment/benchmarkingIndicBasicPage.vue

+ 74 - 71
src/components/assessment/benchmarkingIndicBasicPage.vue

@@ -83,7 +83,7 @@
                         </el-table-column>
                         <el-table-column prop="city" label="上期" v-if="showType === '3'" align="center">
                             <template #default="scope">
-                                <span>{{scope.row[it.code]}}</span>
+                                <span>{{scope.row[it.code+'_h']}}</span>
                             </template>
                         </el-table-column>
                     </el-table-column>
@@ -96,8 +96,8 @@
 
 <script>
     import seachs from '../seachGroup.vue'
-    // import baxicjson from '../basicJSON.json'
-    // import baxic2json from '../basic2JSON.json'
+    import baxicjson from '../basicJSON.json'
+    import baxic2json from '../basic2JSON.json'
     import {
         apiPostbenchmarkBasicList,
         apiPostbenchmarkcontemporaneousData,
@@ -127,8 +127,8 @@
                 winPix: window.devicePixelRatio,
                 innerWidth: window.innerWidth,
                 showType: '1',
-                // baxicjson: baxicjson,
-                // baxic2json: baxic2json
+                baxicjson: baxicjson,
+                baxic2json: baxic2json
             }
         },
         created() {
@@ -250,49 +250,95 @@
                         endTime: that.resAnnual[1]
                     }
                 }
-                if (type === '1') {
-                    apiPostbenchmarkBasicList(params).then(datas => {
-                        that.changeData(datas)
-                    })
-                } else if (type === '2') {
-                    apiPostbenchmarkcontemporaneousData(params).then(datas => {
-                        that.changeData(datas)
-                    })
-                } else if (type === '3') {
-                    apiPostbenchmarkpreviousPeriodData(params).then(datas => {
-                        that.changeData(datas)
-                    })
-                }
+                apiPostbenchmarkBasicList(params).then(datas => {
+                    if (type === '1') {
+                        that.changeLineData(datas, type)
+                    } else {
+                        that.changeBarData(datas, type)
+                    }
+                })
+                // if (type === '1') {
+
+                //     // that.changeLineData(that.baxicjson)
+                // } else if (type === '2') {
+                //     apiPostbenchmarkcontemporaneousData(params).then(datas => {
+                //         that.changeData(datas, type)
+                //     })
+                //     // that.changeBarData(that.baxic2json, type)
+                // } else if (type === '3') {
+                //     apiPostbenchmarkpreviousPeriodData(params).then(datas => {
+                //         that.changeData(datas, type)
+                //     })
+                // }
             },
-            changeData(showData) {
+            changeLineData(showData) {
                 if (showData.data.title) {
-                    that.benchmarkBasicHeader = showData.data.title
+                    this.benchmarkBasicHeader = showData.data.title
                 }
                 if (showData.data.list) {
-                    that.benchmarkBasicPageData = showData.data.list
+                    this.benchmarkBasicPageData = showData.data.list
                     let xaxisArr = []
                     let seriesArr = []
-                    that.benchmarkBasicPageData.forEach(it => {
+                    this.benchmarkBasicPageData.forEach(it => {
                         xaxisArr.push(it.time)
                     })
-                    that.benchmarkBasicHeader.forEach(iv => {
+                    this.benchmarkBasicHeader.forEach(iv => {
                         if (iv.code !== 'time') {
                             let seriesitemArr = []
-                            that.benchmarkBasicPageData.forEach(item => {
+                            this.benchmarkBasicPageData.forEach(item => {
                                 seriesitemArr.push(item[iv.code])
                             })
                             let obj = {
                                 name: iv.name,
-                                type: type === '1' ? 'line' : 'bar',
+                                type: 'line',
+                                symbol: 'none',
                                 data: seriesitemArr
                             }
-                            if (type === '1') {
-                                obj.symbol = 'none'
+                            seriesArr.push(obj)
+                        }
+                    })
+                    this.getEchartsData(xaxisArr, seriesArr)
+                }
+            },
+            changeBarData(showData, type) {
+                if (showData.data.title) {
+                    this.benchmarkBasicHeader = showData.data.title
+                }
+                if (showData.data.list) {
+                    this.benchmarkBasicPageData = showData.data.list
+                    let xaxisArr = []
+                    let seriesArr = []
+                    this.benchmarkBasicPageData.forEach(it => {
+                        xaxisArr.push(it.time)
+                    })
+                    this.benchmarkBasicHeader.forEach(iv => {
+                        if (iv.code !== 'time') {
+                            let seriesitemArrB = []
+                            let seriesitemArrT = []
+                            let seriesitemArrS = []
+                            this.benchmarkBasicPageData.forEach(item => {
+                                seriesitemArrB.push(item[iv.code + '_b'])
+                                if (type === '2') {
+                                    seriesitemArrT.push(item[iv.code + '_t'])
+                                } else {
+                                    seriesitemArrS.push(item[iv.code + '_h'])
+                                }
+                            })
+                            let obj = {
+                                name: iv.name + '本期',
+                                type: 'bar',
+                                data: seriesitemArrB
+                            }
+                            let obj1 = {
+                                name: iv.name + type === '2' ? '同期' : '上期',
+                                type: 'bar',
+                                data: type === '2' ? seriesitemArrT : seriesitemArrS
                             }
                             seriesArr.push(obj)
+                            seriesArr.push(obj1)
                         }
                     })
-                    that.getEchartsData(xaxisArr, seriesArr)
+                    this.getEchartsData(xaxisArr, seriesArr)
                 }
             },
             //获取echarts数据
@@ -322,49 +368,6 @@
                     chat.resize()
                 })
             },
-            getPowerBar(xAxis, series) {
-                let option = {
-                    tooltip: {
-                        trigger: 'axis',
-                        axisPointer: {
-                            type: 'shadow'
-                        }
-                    },
-                    grid: {
-                        left: '2%',
-                        right: '2%',
-                        bottom: '5%',
-                        height: '90px',
-                        containLabel: true
-                    },
-                    legend: {
-                        right: '20',
-                        top: '20',
-                        itemWidth: 5,
-                        itemHeight: 5,
-                        data: ['日发电量', '上网电量', '购网电量']
-                    },
-                    xAxis: [{
-                        type: 'category',
-                        axisTick: {
-                            show: false
-                        },
-                        data: xAxis
-                    }],
-                    yAxis: [{
-                        type: 'value'
-                    }],
-                    series: series
-                };
-                // 基于准备好的dom,初始化echarts实例
-                let dom = document.getElementById('basicEcharts');
-                dom.removeAttribute("_echarts_instance_") ? dom.removeAttribute("_echarts_instance_") : ''
-                let myChart = this.$echarts.init(dom);
-                myChart.setOption(option);
-                window.addEventListener("resize", function () {
-                    myChart.resize()
-                })
-            },
             getTime(date) {
                 var y = date.getFullYear();
                 var m = date.getMonth() + 1;