<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>
          <dept-access-list :list="list"/>
        </el-tab-pane>
        <el-tab-pane name="chart">
          <span slot="label"><i class="el-icon-s-data"/> 图表模式</span>
          <dept-access-chart :list="list"/>
        </el-tab-pane>
      </el-tabs>
      <el-button type="text" class="rule-button">考核规则</el-button>
    </el-row>
  </div>
</template>

<script>
import DeptAccessList from './deptAccessList'
import DeptAccessChart from './deptAccessChart'

export default {
  name: 'DeptAccess',
  components: { DeptAccessList, DeptAccessChart },
  data() {
    return {
      activeName: 'list', // 默认tab
      query: {
        beginDate: '',
        endDate: ''
      },
      list: [
        {
          deptName: '城管监察二大队',
          lastCarryOver: 2,
          shouldProcess: 166
        },
        {
          deptName: '渣土站',
          lastCarryOver: 0,
          shouldProcess: 21
        }
      ]
    }
  },
  mounted() {

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

<style scoped>
.rule-button{
  position: absolute;
  top: 0;
  right: 10px;
  /* color: red; */
}
</style>
