zmc
2023-12-07 d1ccf7e1835b3c583da16d90a286e749d5e27c84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<script>
import exceptionApi from '@/api/exceptionApi.js'
import lineChart from '@/utils/chartFunction/lineChart.js'
import time from '@/utils/time.js'
// import time from '@/utils/time.js'
import FYLineChart from '@/components/chart/FYLineChart.vue'
export default {
  props: {
    fetchParams: {
      type: Object,
      default: {
        siteName: null,
        mnCode: null,
        beginTime: null,
        endTime: null
      }
    }
  },
  components: {
    FYLineChart
  },
  data() {
    return {
      chart: {
        // 日均值 折线图结果
        chartDataAvg: {},
        // 日有效率 折线图结果
        chartDataValid: {},
        // 无数据配置时间段
        areaColor: []
      }
    }
  },
  watch: {
    fetchParams: {
      handler() {
        if(this.fetchParams.siteName != '' && this.fetchParams.siteName != null){
          this.fetchDayAnalysisData()
        }
      },
      deep: true
    }
  },
  mounted() {
  },
  methods: {
    //  根据目前站点,月份,查折线图日统计数据
    fetchDayAnalysisData() {
      exceptionApi.analysisdata(
          this.fetchParams.siteName,
          this.fetchParams.beginTime,
          this.fetchParams.endTime,
          'day'
        )
        .then(response => {
          const chartData = response
          if (chartData.length == 0) {
            return
          }
 
          const timeArr = chartData.map(item => {
            return item.lst
          })
          
          // 无数据的时间段
          let noDataTimeInterval = time.getMissingDays(this.fetchParams.beginTime, this.fetchParams.endTime,timeArr)
          // 无数据配置时间段
          this.chart.areaColor = lineChart.getMarkArea(noDataTimeInterval)
          this.setChart(chartData, this.fetchParams.beginTime, this.fetchParams.endTime)
   
        })
    },
 
    /**
     * 组件折线图的配置项
     * @param: 
     * @returns:
     */
    setChart(cData, bt, et) {
      if (cData.length!=0) {
        // 构建折线图x,y数据
        let obj = lineChart.getLineChartXYData(cData, bt, et)
        this.chart.chartDataAvg = {
          x: obj.xData,
          y: obj.yAvg
        }
        this.chart.chartDataValid = {
          x: obj.xData,
          y: obj.yValid
        }
      }
    },
  }
}
</script>
 
<template>
  <el-row :gutter="20">
    <el-col :span="12">
      <el-card shadow="never">
        <FYLineChart
          title="日均值"
          :chartData="chart.chartDataAvg"
          yName="mg/m³"
          seriesName="日均值"
          :areaColor="chart.areaColor"
        />
      </el-card>
    </el-col>
 
    <el-col :span="12">
      <el-card shadow="never">
        <FYLineChart
          title="日有效率"
          :chartData="chart.chartDataValid"
          yName="%"
          seriesName="日有效率"
          :areaColor="chart.areaColor"
        />
      </el-card>
    </el-col>
  </el-row>
</template>
 
<style scoped></style>