<template>
  <div class="app-container">
    <el-form label-width="100px">
      <el-row>
        <el-col :span="4">
          <el-form-item label="关键字搜索">
            <el-input v-model="KEYWORDS" placeholder="搜索关键字" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="处罚状态">
            <el-select v-model="HANDLED">
              <el-option value="0" label="待反馈处罚"/>
              <el-option value="1" label="已完成处罚"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <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-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      v-loading="listLoading"
      ref="multipleTable"
      :data="varList"
      :row-key="getRowKey"
      :header-cell-style="{
        'font-weight': 'bold',
        'color': '#000'
      }"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        :reserve-selection="true"
        type="selection"
        width="55"
        align="center"/>
      <el-table-column type="index" label="序号" width="50" align="center" />
      <el-table-column prop="OUTSOURCED_NAME" label="重点工程名称" show-overflow-tooltip />
      <el-table-column prop="REASON" label="处罚原因" show-overflow-tooltip />
      <el-table-column prop="CREATOR_NAME" label="下发人" show-overflow-tooltip />
      <el-table-column prop="UNITS_NAME" label="被处罚单位" show-overflow-tooltip />
      <el-table-column prop="PERSON_NAME" label="被处罚人" show-overflow-tooltip />
      <el-table-column label="处罚处理状态" show-overflow-tooltip>
        <template slot-scope="{row}">
          {{ row.HANDLED === "0" ? "待处理" : "已处理" }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="100">
        <template slot-scope="{row}">
          <el-button type="success" icon="el-icon-view" size="mini" @click="goDetail(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page-btn-group" style="margin-bottom: 50px;">
      <div/>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <div class="ui-foot">
      <el-button plain type="info" @click="goBack">返 回</el-button>
    </div>
</div></template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive
export default {
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20
      },
      total: 0,
      KEYWORDS: '',
      HANDLED: '',
      OUTSOURCED_ID: '',
      varList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getRowKey(row) {
      return row.OUTSOURCED_ID
    },
    // 搜索
    getQuery() {
      this.$refs.multipleTable.clearSelection()
      this.getList()
    },
    goKeyReset() {
      this.KEYWORDS = ''
      this.HANDLED = ''
      this.getQuery()
    },
    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/keyprojectpunish/hiddenList?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          KEYWORDS: this.KEYWORDS,
          HANDLED: this.HANDLED,
          OUTSOURCED_ID: this.$parent.OUTSOURCED_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
      }).catch((e) => {
        this.listLoading = false
      })
    },
    goBack() {
      this.$parent.activeName = 'List'
      this.$parent.OUTSOURCED_ID = ''
    },
    // 查看
    goDetail(row) {
      this.$parent.KEYPROJECTPUNISH_ID = row.KEYPROJECTPUNISH_ID
      this.$parent.HIDDEN_ID = row.HIDDEN_ID
      this.$parent.activeName = 'HiddenInfo'
    }
  }
}

</script>
<style lang="sass" scoped>
  .table-qrcode
    text-align: center
    padding-top: 20px
    width: 100%
    .filter-container
      position: relative
      .filter-flot
        position: absolute
        right: 0
        top: 0
    .uploader
      width: 570px
      display: flex
      align-items: center
    .el-form-item__content
      line-height: 1
</style>

