<!--
 * @Description: 部门效能统计
 * @Author: 王晓颖
 * @Date: 2020-04-25 09:37:53
 -->
<template>
  <app-container>
    <div style="margin-bottom:50px;">
      <search-area :need-clear="false" :need-search-more="false" :size="size" type="default" search-more-type="default" @search="search">
        <chart-tools @change="changeTime"/>
        <!--一般查询条件-->
        <search-item>
          <el-date-picker
            v-model="timeRange"
            :size="size"
            type="daterange"
            range-separator="至"
            value-format="yyyy-MM-dd"
            start-placeholder="查询开始日期"
            end-placeholder="查询结束时间"/>
        </search-item>
        <search-item>
          <dept-select v-model="listQuery.deptId" :need-top="false" :size="size" placeholder="选择部门"/>
        </search-item>
      </search-area>
      <normal-table
        :data="data"
        :head="tableOption.head"
        :size="size"
        :query="listQuery"
        :need-page="false"
        :total="total"
        :columns="columns"
        :list-loading="listLoading"
        :options="tableOption.options"
        :tools-option="tableOption.toolsOption"
        @change="changePage"/>

    </div>
  </app-container>
</template>

<script>
import NormalTable from '@/components/NomalTable/index'
import SearchArea from '../../../components/SearchArea/SearchArea'
import SearchItem from '../../../components/SearchArea/SearchItem'
import AppContainer from '../../../components/layout/AppContainer'
import DeptSelect from '../../../components/DeptSelect/index'
import { deptStatistics } from '@/api/statistics'
import ChartTools from '../components/chartTools'
import BorderFrame from '../../../components/frame/borderFrame'

export default {
  name: 'CaseStatisticYear',
  components: { BorderFrame, ChartTools, DeptSelect, AppContainer, SearchItem, SearchArea, NormalTable },
  data() {
    return {
      listQuery: {
        startTime: '',
        endTime: '',
        deptId: ''
      },
      timeRange: [], // 查询日期范围
      columns: [
        {
          text: '部门',
          value: 'deptName'
        },
        {
          text: '交办事件',
          value: 'caseTotalCount'
        },
        {
          text: '按期办结',
          value: 'normalfinished'
        },
        {
          text: '超期办结',
          value: 'delayfinished'
        },
        {
          text: '正在办理',
          value: 'onCount'
        },
        {
          text: '超期未办',
          value: 'delayUnfinishedCount'
        },
        {
          text: '已反馈',
          value: 'feedBackCount'
        },
        {
          text: '超期催办一次',
          value: 'delayOneUrgeCount'
        },
        {
          text: '超期催办两次',
          value: 'delayTwoUrgeCount'
        },
        {
          text: '超期催办三次',
          value: 'delayTwoMoreUrgeCount'
        },
        {
          text: '延期一次',
          value: 'delayOneCount'
        },
        {
          text: '延期二次',
          value: 'delayTwoCount'
        },
        {
          text: '一次重办',
          value: 'redoOneCount'
        },
        {
          text: '二次重办',
          value: 'redoTwoCount'
        }
      ], // 显示列
      data: [], // 列表数据
      total: 0, // 数据总数
      listLoading: true, // 列表加载动画
      tableOption: {
        head: {
          show: false, // 是否需要标题栏，
          text: '数据列表' // 标题名称
        },
        options: {
          needIndex: false // 是否需要序号列
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false // 是否需要刷新按钮
        }
      }, // 表格属性
      size: 'small',
      userList: [] // 用户列表
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    search() {
      this.fetchData()
    },
    fetchData() {
      this.listLoading = true
      deptStatistics(this.listQuery).then(response => {
        if (response.code === 200) {
          this.listLoading = false
          this.data = response.data
          // this.data = [
          //   { deptName: '社管局', caseTotalCount: 20, delayOneCount: 0, delayTwoCount: 0, normalfinished: 20, delayfinished: 0, onCount: 0, delayUnfinishedCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
          //   { deptName: '城管执法分局', caseTotalCount: 21, delayOneCount: 0, delayTwoCount: 0, normalfinished: 21, delayfinished: 0, onCount: 0, delayUnfinishedCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
          //   { deptName: '蓉江新区交通大队', caseTotalCount: 10, delayOneCount: 0, delayTwoCount: 0, normalfinished: 10, delayfinished: 0, onCount: 0, delayUnfinishedCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
          //   { deptName: '环卫所', caseTotalCount: 5, delayOneCount: 0, delayTwoCount: 0, normalfinished: 5, delayfinished: 0, onCount: 0, delayUnfinishedCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
          //   { deptName: '住建局', caseTotalCount: 3, delayOneCount: 0, delayTwoCount: 0, normalfinished: 3, delayfinished: 0, onCount: 0, delayUnfinishedCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 }
          // ]
        }
      })
    },
    // 页数发生变化后的操作，可能是页码变化，可能是每页容量变化，此函数必写
    changePage(val) {
      if (val && val.size) {
        this.listQuery.limit = val.size
      }
      if (val && val.page) {
        this.listQuery.offset = val.page
      }
      this.fetchData()
    },
    changeTime(val) {
      this.timeRange = val
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .table-title{
    text-align: center;
    line-height: 2;
    font-size:18px;
    font-weight: 700;
    background-color: #f0f0f0;

  }
  .level-txt{
    margin-left:20px;
    color: #909399;
    font-size:15px;
    line-height: 32px
  }
</style>
