Newer
Older
iris_temperature_front_gz / src / views / dashboard / components / tempSevenDay.vue
IRIS on 28 Jun 2020 1 KB 首页加图表
<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>