Newer
Older
iris_temperature_front_gz / src / views / dashboard / components / tempAnalysis.vue
IRIS on 28 Jun 2020 1 KB 首页加图表
<template>
  <ve-histogram :data="chartData" :title="title" :legend-visible="isLegendVisible" :tooltip-visible="isTipShow" :settings="chartSettings" :extend="chartExtends"/>
</template>

<script>
import { peopleCountByDevice } from '@/api/statistics'
// import { jobStaticsByDept } from '@/api/dataStatics'

export default {
  name: 'TempAnalysis',
  data() {
    this.title = {
      text: '测温情况分析'
    }
    this.chartSettings = {
      labelMap: {
        'normal': '体温正常',
        'abnormal': '体温异常'
      },
      stack: { '体温': ['normal', 'abnormal'] }
    }
    this.chartExtends = {
      color: ['#36a3f7', '#f4516c'],
      barWidth: 20,
      xAxis: {
        axisLabel: {
          interval: 0,
          rotate: 45 // 代表逆时针旋转45度
        }
      }
    }
    return {
      isLegendVisible: true,
      isTipShow: true,
      chartData: {
        columns: ['deviceName', 'normal', 'abnormal'],
        rows: []
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  activated() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      // const beginTime = (new Date().toLocaleDateString().split('/').join('-')) + ' 00:00:00'
      // const endTime = new Date().toLocaleDateString().split('/').join('-') + ' 23:59:59'
      const startTime = '2020-06-01 00:00:00'
      const endTime = '2020-06-20 00:00:00'
      const listQuery = {
        startTime: startTime,
        endTime: endTime
      }
      peopleCountByDevice(listQuery).then(response => {
        const data = response.data
        if (data.length === 0) {
          var data0 = {}
          data0['deviceName'] = ''
          data0['abnormal'] = 0
          data0['normal'] = 0
          data.push(data0)
        }
        this.chartData.rows = data
      })
    }
  }
}
</script>