<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-custom__evaluateofficercount}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-button type="primary" @click="backToDeptList">返回</el-button>
        </el-form-item>
        <div>
          <el-form-item label="干部"><el-input v-model="dataForm.fullName" placeholder="请输入姓名" clearable></el-input></el-form-item>
          <el-form-item label="排序">
            <el-select v-model="dataForm.sort" placeholder="排序" clearable>
              <el-option label="点赞最多" :value="1"></el-option>
              <el-option label="吐槽最多" :value="2"></el-option>
              <el-option label="点赞最少" :value="3"></el-option>
              <el-option label="吐槽最少" :value="4"></el-option>
            </el-select></el-form-item>
        </div>
        <div class="block">
          <el-form-item label="时间"
                        prop="startTime">
            <el-date-picker v-model="dataForm.startTime"
                            type="date"
                            :picker-options="pickerBeginDateBefore"
                            value-format="yyyy-MM-dd"
                            format="yyyy-MM-dd"
                            placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="至"
                        label-width="25px"
                        prop="endTime">
            <el-date-picker v-model="dataForm.endTime"
                            type="date"
                            :picker-options="pickerBeginDateAfter"
                            value-format="yyyy-MM-dd"
                            format="yyyy-MM-dd"
                            placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button @click="getDataList()">{{ $t('query') }}</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-if="$hasPermission('epdc:evaluateDeptCount:export')" type="primary" @click="exportHandle()">{{ $t('export') }}</el-button>
          </el-form-item>
        </div>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column label="序号" header-align="center" align="center" width="50px">
          <template slot-scope="scope">
            {{scope.$index+1}}
          </template>
        </el-table-column>
        <el-table-column prop="fullName" label="姓名" header-align="center" align="center"></el-table-column>
        <el-table-column prop="sex" label="性别" :formatter="formatSex" header-align="center" align="center"></el-table-column>
        <el-table-column prop="position" label="单位职位" header-align="center" align="center"></el-table-column>
        <el-table-column prop="evaluatePeopleCount" label="评价总人数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="evaluateCount" label="评价总次数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="likesCount" label="点赞次数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="likesOptionCount" label="点赞选项次数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="opposeCount" label="吐槽次数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="opposeOptionCount" label="吐槽选项次数" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('custom:evaluateCount:lookOfficer')" type="text" size="small" @click="detailAction(scope.row.id)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  name: 'EvaluateOfficerCountList',
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/custom/evaluateofficer/countPage',
        getDataListIsPage: true,
        exportURL: '/custom/evaluateofficer/countExport'
      },
      dataForm: {
        deptId: '',
        fullName:'',
        sort: '',
        startTime: '',
        endTime: ''
      }
    }
  },
  mounted () {
    this.dataForm.deptId = this.$route.query.deptId
    this.getDataList()
  },
  methods: {
    backToDeptList () {
      this.$emit('refreshDataList')
      this.$parent.selectComponent = 'EvaluateDeptCountList'
      this.$router.push({ path: '/custom-evaluatecount'})
    },
    detailAction (id) {
      this.$parent.selectComponent = 'EvaluateInfoList'
      this.$router.push({ path: '/custom-evaluatecount', query: { id: id,deptId:this.dataForm.deptId } })
    },
    formatSex: function (row, column) {
      let state = row.sex
      if (state === '0') {
        return '女'
      } else if (state === '1') {
        return '男'
      }
    }
  }
}
</script>
