<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="form" v-model="form">
        <el-row>
          <el-col :span="5">
            <el-form-item label="相关方单位名称:">
              <el-input v-model="form.RELEVANT_UNIT_NAME" placeholder="搜索" class="filter-item" style="width: 200px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <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="reset">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="app-statistical">
      <span>
        培训合格总人数：<i>{{ personCount }}</i>
      </span>
      <span>
        培训合格人员证件即将过期人数：<i>{{ expireSoonPersonCount }}</i>
      </span>
      <span>
        培训合格人员证件已经过期人数：<i>{{ expiredPersonCount }}</i>
      </span>
    </div>
    <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="corpTypeName" label="集团单位" />
      <el-table-column prop="RELEVANT_UNIT_NAME" label="相关方单位名称" />
      <el-table-column label="属地">
        <template slot-scope="{row}">
          <span v-if="row.COMPANY_AREA">
            {{ row.COMPANY_AREA.replaceAll(',',' ') }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="MAIN_DEPARTMENT_NAME" label="股份主管部门" width="200" />
      <el-table-column prop="SUPERVISE_CORPINFO_NAME" label="基层单位主管公司" width="200" />
      <el-table-column prop="SUPERVISE_DEPARTMENT_NAME" label="基层单位主管部门" width="200" />
      <el-table-column prop="userCount" label="人员数"/>
      <el-table-column prop="trainingQualifiedCount" label="参与培训合格人员数"/>
      <el-table-column prop="expireSoonCount" label="证件即将过期人员数"/>
      <el-table-column prop="expiredCount" label="证件已过期人员数"/>

      <el-table-column label="操作" align="left" width="110">
        <template slot-scope="{row}">
          <el-button type="success" icon="el-icon-view" size="mini" @click="handleEdit(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page-btn-group">
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { requestFN } from '@/utils/request'
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
export default{
  components: {Pagination},
  data() {
    return{
      listQuery: {
        page: 1,
        limit: 10
      },
      areaList: [], // 省市县列表
      placeList: [],
      listLoading: true,
      varList: [],
      total: 0,
      title: '',
      isShow: false,
      form: {
        RELEVANT_UNIT_NAME: '',
        CREATE_TIME: '', // 数据创建时间
        CREATOR: '', // 数据创建人
        OPERAT_TIME: '', // 数据更新时间
        OPERATOR: '', // 数据更新人
        ISDELETE: '', // 删除标志位
        CORPINFO_ID: '', // 企业id
        CLASS_NAME: '', // 班级名称
        OPENING_TIME: '', // 开班时间
        PLACE: '', // 培训地点
        TRAINING_TYPE: '', // 培训类型
        CLASS_SIZE: '', // 班级容量
        TRAINEES_NUM: '', // 培训人员数量
        CLASS_STATUS: ''// 班级状态（0-待开班、1-已开班、2-完成）
      },
      personCount: '',
      expireSoonPersonCount: '',
      expiredPersonCount: ''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 搜索
    getQuery() {
      this.$refs.multipleTable.clearSelection()
      this.getList()
    },
    // 重置
    reset() {
      this.form = {
        CLASS_NAME: '', // 班级名称
        OPENING_TIME: '', // 开班时间
        PLACE: '', // 培训地点
        TRAINING_TYPE: '', // 培训类型
        CLASS_SIZE: '', // 班级容量
        TRAINEES_NUM: '', // 培训人员数量
        CLASS_STATUS: ''// 班级状态（0-待开班、1-已开班、2-完成）
      }
      this.getList()
    },
    // 详情
    handleEdit(row) {
      this.$parent.activeName = 'corpUserList'
      this.$parent.CORPINFO_ID = row.CORPINFO_ID
    },
    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/classMessage/cardOverdueList?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page, this.form
      ).then((data) => {
        console.log(data)
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
        this.personCount = data.personCount
        this.expireSoonPersonCount = data.expireSoonPersonCount
        this.expiredPersonCount = data.expiredPersonCount
        this.hasButton()
        this.pd = data.pd
      }).catch((e) => {
        this.listLoading = false
      })
    }
  }


}
</script>

