<template>
  <el-dialog :loading="loading" :visible.sync="visible" :append-to-body="true" :before-close="handleClose" title="查看">

    <table class="table-ui" style="margin-bottom: 20px;">
      <tr>
        <th>服务分公司</th>
        <td>{{ info.FIRST_PARTY_NAME }}</td>
        <th>用工形式</th>
        <td>
          <span v-if="info.EMPLOYMENT_TYPE === 0">劳务承包</span>
          <span v-if="info.EMPLOYMENT_TYPE === 1">劳务派遣</span>
        </td>
      </tr>

      <tr>
        <th>选取形式</th>
        <td>
          <span v-if="info.SELECT_TYPE === 0">招标</span>
          <span v-if="info.SELECT_TYPE === 1">竞争性谈判</span>
        </td>
        <th>服务有效期</th>
        <td> {{ info.START_TIME }} -- {{ info.END_TIME }}</td>
      </tr>

      <tr v-if="info.AUDIT_DESCR">
        <th >分公司意见</th>
        <td colspan="3">{{ info.AUDIT_DESCR }} </td>
      </tr>
    </table>

    <div class="level-title">
      <h1>流动人员列表</h1>
    </div>
    <el-table :data="flowUserData" border style="width: 100%" height="500px">
      <el-table-column prop="USERNAME" label="用户名" width="180"/>
      <el-table-column prop="NAME" label="姓名" width="180"/>
      <el-table-column prop="DEPARTMENT_NAME" label="部门"/>
<!--      <el-table-column prop="POST_NAME" label="工种"/>-->
      <el-table-column prop="POST_NAME" label="年份">
        <span>{{ new Date(info.START_TIME).getFullYear() }}</span>
      </el-table-column>
      <el-table-column prop="POST_NAME" label="年度入场培训">
        <!-- <span>已培训</span>-->
        <template slot-scope="{row}">
          <span v-if="row.STATUS === 0">未培训</span>
          <span v-if="row.STATUS === 1">培训中</span>
          <span v-if="row.STATUS === 2">已培训</span>
          <span v-if="row.STATUS === -1">培训未通过</span>
        </template>
      </el-table-column>
    </el-table>

    <div class="level-title" style="margin-top: 20px">
      <h1>固定人员列表</h1>
    </div>
    <el-table :data="unFlowUserData" border style="width: 100%" height="500px">
      <el-table-column prop="USERNAME" label="用户名" width="180"/>
      <el-table-column prop="NAME" label="姓名" width="180"/>
      <el-table-column prop="DEPARTMENT_NAME" label="部门"/>
<!--      <el-table-column prop="POST_NAME" label="工种"/>-->
      <el-table-column prop="POST_NAME" label="年份">
        <span>{{ new Date(info.START_TIME).getFullYear() }}</span>
      </el-table-column>
      <el-table-column prop="POST_NAME" label="年度入场培训">
        <!-- <span>已培训</span>-->
        <template slot-scope="{row}">
          <span v-if="row.STATUS === 0">未培训</span>
          <span v-if="row.STATUS === 1">培训中</span>
          <span v-if="row.STATUS === 2">已培训</span>
          <span v-if="row.STATUS === -1">培训未通过</span>
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleClose">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import waves from '@/directive/waves' // waves directive
import { requestFN } from '@/utils/request'
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包

export default {
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      visible: false,
      loading: false,
      SERVICE_COMPANY_MAP_ID: '',
      info: {},
      flowUserData: [],
      unFlowUserData: []
    }
  },
  methods: {
    init(e) {
      this.visible = true
      this.SERVICE_COMPANY_MAP_ID = e.SERVICE_COMPANY_MAP_ID
      this.getData()
    },
    getData() {
      this.loading = true
      requestFN(
        '/service_corp/getInfo',
        {
          SERVICE_COMPANY_MAP_ID: this.SERVICE_COMPANY_MAP_ID
        }
      ).then((data) => {
        this.loading = false
        this.info = data.info
        this.flowUserData = data.flowUserData
        this.unFlowUserData = data.unFlowUserData
      }).catch((e) => {
        this.loading = false
      })
    },

    handleClose() {
      this.visible = false
    }

  }
}

</script>
