Newer
Older
qd_cnooc_front / src / views / dataManage / deviceData / watchSevenDay.vue
[wangxitong] on 17 Mar 2022 1 KB 添加三级分区
<template>
  <el-dialog :visible.sync="dialogFormVisible" title="" append-to-body>
    <ve-line :data="chartData" :title="title" :settings="chartSettings"/>
  </el-dialog>
</template>

<script>
import { getDayTime } from '@/utils/dateutils'
import { alarmStaticByDay } from '@/api/dataStatics'

export default {
  name: 'WatchSevenDay',
  data() {
    this.title = {
      text: '7日曲线图'
    }
    this.chartSettings = {
      labelMap: {
        'alarmTimes': '用水量'
      },
      metrics: ['alarmTimes'],
      dimension: ['date']
    }
    return {
      dialogFormVisible: false, // 对话框是否显示
      listQuery: {
        deviceType: '',
        beginTime: '',
        endTime: ''
      },
      chartData: {
        columns: ['date', 'alarmTimes'],
        rows: []
      }
    }
  },
  mounted() {
    this.fetchData()
    // 模拟数据
    // this.chartData.rows = [
    //   { 'date': '9月20日', 'alarmTimes': 153, 'alarmWells': 43 },
    //   { 'date': '9月21日', 'alarmTimes': 150, 'alarmWells': 30 },
    //   { 'date': '9月22日', 'alarmTimes': 143, 'alarmWells': 23 },
    //   { 'date': '9月23日', 'alarmTimes': 173, 'alarmWells': 23 },
    //   { 'date': '9月24日', 'alarmTimes': 272, 'alarmWells': 52 },
    //   { 'date': '9月25日', 'alarmTimes': 253, 'alarmWells': 53 }
    // ]
  },
  methods: {
    initDialog: function(dialogFormVisible, row = null) {
      this.dialogFormVisible = dialogFormVisible
      this.fetchData() // 传row
    },
    fetchData() {
      const beginTime = getDayTime(new Date().getTime() - 24 * 7 * 60 * 60 * 1000).Format('yyyy-MM-dd hh:mm:ss')
      const endTime = new Date().Format('yyyy-MM-dd hh:mm:ss')
      this.listQuery.beginTime = beginTime
      this.listQuery.endTime = endTime
      alarmStaticByDay(this.listQuery).then(response => {
        this.chartData.rows = response.data
      })
    }
  }
}
</script>