<template>
  <div class="app-container">
    <el-form label-width="80px">
      <el-row>
        <el-col :span="4">
          <el-form-item label="阶段时间">
            <el-select v-model="EVALUATE_STAGE_TIME" placeholder="请选择阶段时间" style="width: 100%;">
              <el-option v-for="item in stageTimeList" :key="item.EVALUATE_STAGE_ID" :label="item.EVALUATE_STAGE_START_TIME+'/'+item.EVALUATE_STAGE_END_TIME" :value="item.EVALUATE_STAGE_START_TIME+'/'+item.EVALUATE_STAGE_END_TIME"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="兑换状态">
            <el-select v-model="EVALUATE_STAGE_EXCHANGE_STATUS" placeholder="请选择兑换状态" style="width: 100%;">
              <el-option label="未兑换" value="0"/>
              <el-option label="已兑换" value="1"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="10px">
            <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getQuery">
              搜索
            </el-button>
            <el-button v-waves class="filter-item" type="success" icon="el-icon-refresh" @click="goKeyReset">
              重置
            </el-button>
            <el-button v-waves class="filter-item" type="success" icon="el-icon-s-data" @click="sumDetail">
              合计
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div>
      <el-table v-loading="listLoading" ref="multipleTable" :row-key="getRowKey" :data="varList" border tooltip-effect="dark" style="width: 100%">
        <el-table-column type="index" label="序号" width="55" align="center" show-overflow-tooltip/>
        <el-table-column width="500" prop="EVALUATE_STAGE_TIME" label="时间" show-overflow-tooltip/>
        <el-table-column prop="HIDDEN_COUNTS" label="隐患数" show-overflow-tooltip/>
        <el-table-column prop="FX_COUNTS" label="发现数" show-overflow-tooltip/>
        <el-table-column prop="ZG_COUNTS" label="整改数" show-overflow-tooltip/>
        <el-table-column prop="CQ_COUNTS" label="超期数" show-overflow-tooltip/>
        <el-table-column prop="REWARD" label="奖励金额" show-overflow-tooltip/>
        <el-table-column prop="PUNISH" label="处罚金额" show-overflow-tooltip/>
        <el-table-column prop="EXCHANGE_REWARD_SCORE" label="兑换奖励金额" show-overflow-tooltip/>
        <el-table-column prop="EXCHANGE_PUNISH_SCORE" label="兑换处罚金额" show-overflow-tooltip/>
        <el-table-column label="兑换状态" show-overflow-tooltip>
          <template slot-scope="{row}">
            <template v-if="row.EVALUATE_STAGE_EXCHANGE_STATUS=='1'"><span>已兑换</span></template>
            <template v-if="row.EVALUATE_STAGE_EXCHANGE_STATUS=='0'"><span>未兑换</span></template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="操作" width="140" align="center" show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-button icon="el-icon-thumb" type="primary" size="mini" @click="handleCheck(row)">查看
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="page-btn-group">
        <div/>
        <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
      </div>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves'

export default {
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      // 查询属性
      stageTimeList: [], // 阶段时间
      // 列表
      varList: [], // 查询返回的数据
      // 接口参数
      EVALUATE_STAGE_EXCHANGE_STATUS: '', // 兑换状态
      EVALUATE_STAGE_TIME: '', // 阶段时间
      // 页面参数
      listLoading: false, // 是否加载
      listQuery: {
        page: 1,
        limit: 20
      }, // 分页参数
      total: 0, // 总数
      page: []// 分页对象
    }
  },
  created() {
    this.getParam()
    this.getList()
  },
  methods: {
    // 查询
    getQuery() {
      this.getList()
    },
    // 重置
    goKeyReset() {
      // 接口参数
      this.EVALUATE_STAGE_EXCHANGE_STATUS = '' // 兑换状态
      this.EVALUATE_STAGE_TIME = '' // 阶段时间
      this.getList()
    },
    // 行数据的Key用来优化Table的渲染
    getRowKey(row) {
      return row.EVALUATE_STAGE_ID
    },
    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/hidden_evaluate/selectCountsStageInfoList?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          TYPE: '1',
          EVALUATE_STAGE_TIME: this.EVALUATE_STAGE_TIME,
          EVALUATE_STAGE_EXCHANGE_STATUS: this.EVALUATE_STAGE_EXCHANGE_STATUS
        }
      ).then((data) => {
        console.log(data.varList)
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 获取参数列表
    getParam() {
      this.listLoading = true
      requestFN(
        '/hidden_evaluate/selectStageInfoListByCorpinfoId',
        {}
      ).then((data) => {
        this.listLoading = false
        this.stageTimeList = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 操作
    handleCheck(row) {
      this.$parent.activeName = 'detail'
      this.$parent.EVALUATE_STAGE_TIME = row.EVALUATE_STAGE_TIME
      this.$parent.EVALUATE_STAGE_ID = row.EVALUATE_STAGE_ID
    },
    sumDetail() {
      this.$parent.activeName = 'sumDetail'
    }
  }
}
</script>

<style>
</style>
