<template>
  <div class="app-container">
    <el-form label-width="100px">
      <el-row>
        <el-col :span="5">
          <el-form-item label="关键字搜索">
            <el-input v-model="KEYWORDS" placeholder="搜索关键字" />
          </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="DEPARTMENT_NAME" label="监管部门" show-overflow-tooltip />
      <el-table-column prop="MANAGE_CORPS_NAME" label="监理单位" show-overflow-tooltip />
      <el-table-column prop="UNITS_PIC_NAME" label="相关方单位负责人" show-overflow-tooltip />
      <el-table-column prop="UNITS_PHONE" label="电话" show-overflow-tooltip />
      <el-table-column label="操作" align="center" width="100">
        <template slot-scope="{row}">
          <el-button icon="el-icon-view" size="mini" @click="goDetail(row.OUTSOURCED_ID)">查看</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></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: '',
      varList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getRowKey(row) {
      return row.OUTSOURCED_ID
    },
    // 搜索
    getQuery() {
      this.$refs.multipleTable.clearSelection()
      this.getList()
    },
    goKeyReset() {
      this.KEYWORDS = ''
      this.getQuery()
    },
    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/outsourced/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          KEYWORDS: this.KEYWORDS
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 查看
    goDetail(ID) {
      this.$parent.OUTSOURCED_ID = ID
      this.$parent.activeName = 'recordList'
    }
  }
}

</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>

