zmc
2023-12-07 d1ccf7e1835b3c583da16d90a286e749d5e27c84
src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue
@@ -1,16 +1,16 @@
<script>
import exceptionApi from '@/api/exceptionApi.js'
import lineChart from '@/utils/chartFunction/lineChart.js'
import index from '@/utils/risk_estimate_common_function/index.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: {
        name: null,
        number: null,
        siteName: null,
        mnCode: null,
        beginTime: null,
        endTime: null
      }
@@ -34,7 +34,7 @@
  watch: {
    fetchParams: {
      handler() {
        if(this.fetchParams.name != '' && this.fetchParams.name != null){
        if(this.fetchParams.siteName != '' && this.fetchParams.siteName != null){
          this.fetchDayAnalysisData()
        }
      },
@@ -46,40 +46,40 @@
  methods: {
    //  根据目前站点,月份,查折线图日统计数据
    fetchDayAnalysisData() {
      exceptionApi
        .analysisdata(
          this.fetchParams.name,
      exceptionApi.analysisdata(
          this.fetchParams.siteName,
          this.fetchParams.beginTime,
          this.fetchParams.endTime,
          'day'
        )
        .then((response) => {
          const chartData = response.data.data
          console.log('数据为',chartData);
          if (response.data.data.length == 0) {
        .then(response => {
          const chartData = response
          if (chartData.length == 0) {
            return
          }
          chartData.sort(time.compareByScore)
          // 分析数据中的最早时间
          let begin = chartData[0].lst
          // 分析数据中的最晚时间
          let end = chartData[chartData.length - 1].lst
          const timeArr = chartData.map(item => {
            return item.lst
          })
          // 无数据的时间段
          let noDataTimeInteval = lineChart.backNoDataInteval(begin, end)
          let noDataTimeInterval = time.getMissingDays(this.fetchParams.beginTime, this.fetchParams.endTime,timeArr)
          // 无数据配置时间段
          this.chart.areaColor = lineChart.getMarkArea(noDataTimeInteval)
          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)
        console.log('设置:',obj);
        this.chart.chartDataAvg = {
          x: obj.xData,
          y: obj.yAvg