<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-custom__evaluatedeptcount}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <div>
          <el-form-item label="街道"><el-input v-model="dataForm.deptName" 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="deptName" width="200" label="街道名称" header-align="center" align="left"></el-table-column>
        <el-table-column prop="officerCount" label="干部人数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="beEvaluatedCount" 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="likeCount" 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 :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="officerAction(scope.row.deptId)">查看</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'
import EvaluateOfficerCountList from './evaluateofficercount'
export default {
  mixins: [mixinViewModule],
  name: 'EvaluateDeptCountList',
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/custom/evaluatedept/countPage',
        getDataListIsPage: true,
        exportURL: '/custom/evaluatedept/countExport'
      },
      dataForm: {
        deptName: '',
        sort: '',
        startTime: '',
        endTime: ''
      },
      pickerBeginDateBefore: {
        disabledDate: (time) => {
          let beginDateVal = this.dataForm.startTime
          if (beginDateVal) {
            return time.getTime() > new Date(beginDateVal).getTime()
          }
        }
      },
      pickerBeginDateAfter: {
        disabledDate: (time) => {
          let EndDateVal = this.dataForm.endTime
          if (EndDateVal) {
            return time.getTime() < new Date(EndDateVal).getTime()
          }
        }
      }
    }
  },
  created: function () {
    this.getDataList();
  },
  methods: {
    officerAction (deptId) {
      this.$parent.selectComponent = 'EvaluateOfficerCountList'
      this.$router.push({ path: '/custom-evaluatecount', query: { deptId: deptId } })
    }
  }
}
</script>
