<!--
 * @Description: 坐席效能统计
 * @Author: 王晓颖
 * @Date: 2020-04-28 15:08:24
 -->
<template>
  <app-container>
    <div>
      <search-area :need-clear="false" :need-search-more="false" :size="size" type="default" search-more-type="default" @search="search">
        <!--一般查询条件-->
        <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-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'

export default {
  name: 'CaseStatisticYear',
  components: { DeptSelect, AppContainer, SearchItem, SearchArea, NormalTable },
  data() {
    return {
      listQuery: {
        startTime: '',
        endTime: '',
        deptId: ''
      },
      timeRange: [], // 查询日期范围
      columns: [
        {
          text: '姓名',
          value: 'userName'
        },
        {
          text: '坐席号',
          value: 'seat'
        },
        {
          text: '接入话务量',
          value: 'callInCount'
        },
        {
          text: '呼出话务量',
          value: 'callOutCount'
        },
        {
          text: '总话务量',
          value: 'callTotalCount'
        },
        {
          text: '受理事件数',
          value: 'acceptCount'
        },
        {
          text: '直接回复数',
          value: 'directReplyCount'
        },
        {
          text: '交办数',
          value: 'assignCount'
        },
        {
          text: '暂存数',
          value: 'storagyCount'
        },
        {
          text: '回访重办数',
          value: 'returnDoCount'
        },
        {
          text: '会签数',
          value: 'countersignCount'
        },
        {
          text: '在线接入时长（分）',
          value: 'onLineInTime'
        },
        {
          text: '在线呼出时长（分）',
          value: 'redoOneCount'
        },
        {
          text: '在线空闲时长（分）',
          value: 'onLineFreeTime'
        },
        {
          text: '总在线时长（分）',
          value: 'redoOneCount'
        },
        {
          text: '总忙置时长（分）',
          value: 'onLineFreeTime'
        },
        {
          text: '总签入时长（分）',
          value: 'onLineFreeTime'
        }
      ], // 显示列
      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.rows
          this.total = response.data.total
          this.data = [
            { userName: '社管局', seat: 20, delayOneCount: 0, delayTwoCount: 0, normalfinished: 20, delayfinished: 0, onCount: 0, acceptCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
            { userName: '城管执法分局', seat: 21, delayOneCount: 0, delayTwoCount: 0, normalfinished: 21, delayfinished: 0, onCount: 0, acceptCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
            { userName: '蓉江新区交通大队', seat: 10, delayOneCount: 0, delayTwoCount: 0, normalfinished: 10, delayfinished: 0, onCount: 0, acceptCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
            { userName: '环卫所', seat: 5, delayOneCount: 0, delayTwoCount: 0, normalfinished: 5, delayfinished: 0, onCount: 0, acceptCount: 0, feedBackCount: 0, delayOneUrgeCount: 0, delayTwoUrgeCount: 0, delayTwoMoreUrgeCount: 0, redoOneCount: 0, redoTwoCount: 0 },
            { userName: '住建局', seat: 3, delayOneCount: 0, delayTwoCount: 0, normalfinished: 3, delayfinished: 0, onCount: 0, acceptCount: 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()
    }
  }
}
</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>
