<template>
  <ve-line :data="chartData" :title="title" :settings="chartSettings"/>
</template>

<script>
import { countbyDay } from '@/api/statistics'
export default {
  name: 'TempSevenDay',
  data() {
    this.title = {
      text: '七日测温趋势'
    }
    this.chartSettings = {
      labelMap: {
        'temp': '测温人数'
      },
      metrics: ['temp'],
      dimension: ['date']
    }
    return {
      chartData: {
        columns: ['date', 'temp'],
        rows: []
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  activated() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      // const startDate = new Date(new Date().getTime() - 24 * 7 * 60 * 60 * 1000).toLocaleDateString().split('/').join('-')
      // const endDate = new Date().toLocaleDateString().split('/').join('-')
      const startDate = '2020-05-10'
      const endDate = '2020-05-16'
      const listQuery = {
        startDate: startDate,
        endDate: endDate
      }
      debugger
      countbyDay(listQuery).then(response => {
        const data = response.data
        if (data.length !== 0) {
          this.chartData.rows = data
        }
      })
    }
  }
}
</script>
