<template>
  <div class="app-container">
    <el-row>
      <el-form :model="query" :inline="true" label-width="auto">
        <el-form-item label="开始日期">
          <el-date-picker
            v-model="query.beginDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始日期"/>
        </el-form-item>
        <el-form-item label="结束日期">
          <el-date-picker
            v-model="query.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束日期"/>
        </el-form-item>
        <el-button type="primary" icon="el-icon-edit">统计</el-button>
        <el-button type="primary" icon="el-icon-refresh-right" @click="clearDate">清空</el-button>
        <el-button type="primary" icon="el-icon-document">报表</el-button>
      </el-form>
    </el-row>
    <el-row>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane name="list">
          <span slot="label"><i class="el-icon-s-fold"/> 列表模式</span>
          <high-freq-list :list="list"/>
        </el-tab-pane>
        <el-tab-pane name="chart">
          <span slot="label"><i class="el-icon-s-data"/> 图表模式</span>
          <high-freq-chart :list="list"/>
        </el-tab-pane>
      </el-tabs>
    </el-row>
  </div>
</template>

<script>
import HighFreqList from './highFreqList'
import HighFreqChart from './highFreqChart'

export default {
  name: 'HighFreq',
  components: { HighFreqList, HighFreqChart },
  data() {
    return {
      activeName: 'list', // 默认tab
      dialogVisible: false,
      query: {
        beginDate: '',
        endDate: ''
      },
      list: [
        {
          eorc: '事件',
          caseTypeName: '市容环境',
          caseTypeDetailName: '乱堆物堆料',
          upNum: 21917,
          precent: 53.6
        },
        {
          eorc: '事件',
          caseTypeName: '街面秩序',
          caseTypeDetailName: '无照经营游商',
          upNum: 5522,
          precent: 13.5
        },
        {
          eorc: '事件',
          caseTypeName: '街面秩序',
          caseTypeDetailName: '非机动车乱停放',
          upNum: 4313,
          precent: 10.5
        }
      ]
    }
  },
  mounted() {

  },
  methods: {
    clearDate() {
      this.query.beginDate = ''
      this.query.endDate = ''
    },
    handleClick(tab, event) {
      this.activeName = tab.name
      if (tab.name === 'chart') {
        setTimeout(() => {
          tab.$children[0].chart.resize()
        }, 50)
      }
    }
  }
}
</script>

<style scoped>
</style>
