<template>
  <div class="app-warp">
    <div class="app-structure">
      <el-page-header content="记录详情" @back="goBack"/>
      <div class="app-container">
        <el-table
          v-loading="listLoading"
          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 show-overflow-tooltip prop="CORPINFO_NAME" label="培训机构名称"/>
          <el-table-column show-overflow-tooltip prop="CREATTIME" label="导入时间"/>
          <el-table-column show-overflow-tooltip prop="ENTERPRISE_NAME" label="被培训企业"/>
          <el-table-column show-overflow-tooltip prop="DEPARTMENT_NAME" label="部门"/>
          <el-table-column show-overflow-tooltip prop="POST_NAME" label="工种"/>
          <el-table-column label="操作" align="center" width="80">
            <template slot-scope="{row}">
              <el-button type="text" @click="fnView(row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="page-btn-group">
          <div>
            <el-button icon="el-icon-arrow-left" @click="goBack">返回</el-button>
          </div>
          <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList"/>
        </div>
      </div>
    </div>
    <el-dialog :visible.sync="dialog.visible" title="查看">
      <el-form ref="form" :model="dialog.form" label-width="150px" disabled>
        <el-row>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="USER_ID_CARD">
              <el-input v-model="dialog.form.USER_ID_CARD" placeholder="请输入身份证号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="姓名" prop="NAME">
              <el-input v-model="dialog.form.NAME" placeholder="请输入姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号" prop="PHONE">
              <el-input v-model="dialog.form.PHONE" placeholder="请输入手机号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="学历" prop="CULTURAL_LEVEL">
              <el-select v-model="dialog.form.CULTURAL_LEVEL" style="width: 100%;">
                <el-option v-for="item in degreeOfEducationList" :key="item.DICTIONARIES_ID" :value="item.DICTIONARIES_ID" :label="item.NAME"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业" prop="MAJOR">
              <el-input v-model="dialog.form.MAJOR" placeholder="请输入专业"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工作单位" prop="ENTERPRISE_NAME">
              <el-input v-model="dialog.form.ENTERPRISE_NAME" placeholder="请输入工作单位"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职务/职称" prop="DUTIES">
              <el-input v-model="dialog.form.DUTIES" placeholder="请输入职务/职称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="部门" prop="DEPARTMENT_NAME">
              <el-input v-model="dialog.form.DEPARTMENT_NAME" placeholder="请输入部门"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工种" prop="POST_NAME">
              <el-input v-model="dialog.form.POST_NAME" placeholder="请输入工种"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人员类型" prop="PERSONNEL_TYPE">
              <el-select v-model="dialog.form.PERSONNEL_TYPE" style="width: 100%;">
                <el-option v-for="item in personnelTypeList" :key="item.DICTIONARIES_ID" :value="item.DICTIONARIES_ID" :label="item.NAME"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer">
        <el-button @click="dialog.visible = false">关闭</el-button>
      </span>
    </el-dialog>
  </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: 10
      },
      total: 0,
      varList: [],
      degreeOfEducationList: [],
      personnelTypeList: [],
      dialog: {
        visible: false,
        form: {}
      }
    }
  },
  inject: ['setActiveName', 'parentObj'],
  created() {
    this.listLoading = false
    this.getList()
    this.getDict('d7d80f08d73a4accbccf4fd3d8d1d867', 'degreeOfEducationList')
    this.getDict('0b62f92b0b624aab8e89a77304a64d5e', 'personnelTypeList')
  },
  methods: {
    getDict(DICTIONARIES_ID, list) {
      requestFN('/dictionaries/getLevels', {
        DICTIONARIES_ID
      }).then((data) => {
        this[list] = data.list
      })
    },
    getQuery() {
      this.getList()
    },
    getList() {
      requestFN(`/student/getLogs?showCount=${this.listQuery.limit}&currentPage=${this.listQuery.page}`, {
        USER_ID: this.parentObj.USER_ID
      }).then(data => {
        this.varList = data.list
        this.total = data.page.totalResult
        this.listLoading = false
      })
    },
    fnView(row) {
      this.dialog.form = row
      this.dialog.visible = true
    },
    goBack() {
      this.setActiveName('List')
    }
  }
}

</script>
<style scoped lang="scss">
table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;

  th, td {
    background-color: #f9f9f9;
    padding: 0.9rem 0.8rem;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid #eaeaea;

    &:nth-child(2) {
      background-color: red;
      color: #FFFFFF;
    }

    &:nth-child(3) {
      background-color: #039d03;
      color: #FFFFFF;
    }
  }
}
</style>
