<template>
  <div class="mod-config" >
    <el-card class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="handleGetTableList()">
        <query-form @submit="submit"  v-on:listenQuery="initPage"/>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%">
      <el-table-column
        prop="staffName"
        header-align="center"
        align="center"
        width="120"
        label="姓名">
      </el-table-column>

      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        width="120"
        label="当前进度">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 0" size="small" type="danger">未提交</el-tag>
          <el-tag v-if="scope.row.status === 4" size="small" type="success">已完成</el-tag>
          <el-tag v-if="scope.row.status === 1 || scope.row.status === 3 || scope.row.status === 5 || scope.row.status === 6" size="small" type="primary">审核中</el-tag>
        </template>
      </el-table-column>

      <el-table-column
        prop="departmentName"
        header-align="center"
        align="center"
        width="200"
        label="部门">
      </el-table-column>

      <el-table-column
        prop="position"
        header-align="center"
        align="center"
        width="200"
        :show-overflow-tooltip="true"
        label="职位">
      </el-table-column>

      <el-table-column
        prop="version"
        header-align="center"
        align="center"
        width="200"
        :show-overflow-tooltip="true"
        label="业务得分70%">
      </el-table-column>

      <el-table-column
        prop="deployTime"
        header-align="center"
        align="center"
        width="200"
        label="价值观得分30%">
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        width="120"
        label="总分">
      </el-table-column>

      <el-table-column
        header-align="center"
        align="center"
        width="120"
        label="等级">
      </el-table-column>

    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    </el-card>
  </div>
</template>

<script>
  import { apiResultReport } from '@/api/api_report'
  import queryForm from './componments/query-form'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        imageSrc: '',
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        selectionDataList: [],
        departmentId: '',
        selectMonthTime: '',
        staffName: null,
        level: null,
        status: null,
        type: 1
      }
    },
    created () {
    },
    activated () {
    },
    components: {
      queryForm
    },
    methods: {
      // 获取数据列表
      async handleGetTableList () {
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        apiResultReport({
          'currPage': this.pageIndex,
          'pageSize': this.pageSize,
          'departmentId': this.departmentId,
          'selectMonthTime': this.selectMonthTime,
          'status': this.status,
          'staffName': this.staffName,
          'level': this.level,
          'type': this.type
        }).then(res => {
          if (res && res.code === 0) {
            this.dataList = res.page.list
            this.totalPage = res.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          setTimeout(() => {
            loading.close()
          }, 500)
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.handleGetTableList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.handleGetTableList()
      },
      submit (data) {
        this.departmentId = data.departmentId
        this.selectMonthTime = data.selectMonthTime
        this.staffName = data.staffName
        this.level = data.level
        this.status = data.status
        this.type = data.type
        this.handleGetTableList()
      },
      initPage () {
        this.pageIndex = 1
        this.pageSize = 10
        console.log('int page')
      }
    }
  }
</script>
<style>
</style>
