<template>
  <div class="app-container">
    <el-form label-width="130px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="用户名">
            <el-input v-model="NAME" 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
      ref="multipleTable"
      :data="varList"
      :header-cell-style="{'font-weight': 'bold','color': '#000'}"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row>
      <el-table-column type="index" label="序号" width="50" align="center"/>
      <el-table-column prop="NAME" label="姓名" align="center"/>
      <el-table-column prop="RELEVANT_UNIT_NAME_HIS" label="原企业" align="center"/>
      <el-table-column prop="RELEVANT_UNIT_NAME_NOW" label="入住企业" align="center"/>
      <el-table-column prop="CREATETIME" label="入住时间" align="center"/>
    </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 {
      config: config,
      listQuery: {
        page: 1,
        limit: 10
      },
      total: 0,
      varList: [],
      NAME: ''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getQuery() {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection()
      }
      this.listQuery = {
        page: 1,
        limit: 10
      }
      this.getList()
    },
    goKeyReset() {
      this.NAME = ''
      this.getQuery()
    },
    getList() {
      this.listLoading = true
      requestFN(
        '/xgf/coerce/getCoerceIntakeLoglistPage?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          NAME: this.NAME
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
      })
        .catch((e) => {
          this.listLoading = false
        })
    }
  }
}
</script>

