<template>
  <div class="app-container">
    <div class="reform-article">
      <div class="reform-table">
        <table class="table-ui" style="margin-bottom: 20px;">
          <div class="level-title">
            <h1>人员信息</h1>
          </div>
          <tr>
            <th style="width: 200px">照片</th>
            <td style="width: 400px">
              <span v-if="imgUrl != ''">
                <div class="img-flex">
                  <viewer>
                    <img :src="imgUrl" width="40" height="40" style="object-fit: cover;">
                  </viewer>
                </div>
              </span>
              <span v-else/>
            </td>
            <th style="width: 200px">姓名</th>
            <td>{{ dataForm.NAME }}</td>
            <th width="200px">性别</th>
            <td>{{ dataForm.SEX === '0' ? '男' : '女' }}</td>
          </tr>
          <tr>
            <th>出生年月</th>
            <td>{{ dataForm.DATE_OF_BIRTH }}</td>
            <th>年龄</th>
            <td>{{ dataForm.AGE }}</td>
            <th>手机号</th>
            <td>{{ dataForm.PHONE }}</td>
          </tr>
          <tr>
            <th>身份证</th>
            <td>{{ dataForm.CARD_ID }}</td>
            <th>身份证照片</th>
            <!--if条件不可删除-->
            <td v-if="userCardIDPhotoFile.length>0" colspan="3">
              <span>
                <div class="img-flex">
                  <viewer>
                    <img
                      v-for="item in userCardIDPhotoFile"
                      :src="config.fileUrl + item.FILEPATH"
                      :key="item.IMGFILES_ID"
                      width="40"
                      height="40"
                      style="object-fit: cover;">
                  </viewer>
                </div>
              </span>
            </td>
          </tr>

          <tr>
            <th>民族</th>
            <td>{{ dataForm.minzuName }}</td>
            <th>婚姻状况</th>
            <td>{{ dataForm.MARITALSTATUS === '0' ? '未婚' : '已婚' }}</td>
            <th>政治面貌</th>
            <td>{{ dataForm.zzName }} {{
              dataForm.zzName == '中共党员' ? '入党时间' + dataForm.POLITICAL_TIME : ''
            }}
            </td>
          </tr>

          <tr>
            <th>户口所在地</th>
            <td>{{ dataForm.HKLOCAL }}</td>
            <th>现住址</th>
            <td>{{ dataForm.ADDRESS }}</td>
            <th>联系电话</th>
            <td>{{ dataForm.PHONE }}</td>
          </tr>
          <tr>
            <th>文化程度</th>
            <td>{{ dataForm.DEGREE_OF_EDUCATION_NAME }}</td>
            <th>岗位名称(工种)</th>
            <td colspan="3">{{ dataForm.POST_ID }}</td>
          </tr>
          <tr>
            <th>是否缴纳社保</th>
            <td :colspan="dataForm.IS_SOCIAL === '1' ? '':5">{{ formatLabel(dataForm.IS_SOCIAL) }}</td>
            <th v-if="dataForm.IS_SOCIAL === '1'">社会保障号码</th>
            <td v-if="dataForm.IS_SOCIAL === '1'">{{ dataForm.SOCIAL_NUMBER }}</td>
            <th v-if="dataForm.IS_SOCIAL === '1'">社保卡照片</th>
            <td v-if="dataForm.IS_SOCIAL === '1'&& socialPhotoFile.length>0" colspan="3">
              <span>
                <div class="img-flex">
                  <viewer>
                    <img
                      v-for="item in socialPhotoFile"
                      :src="config.fileUrl + item.FILEPATH"
                      :key="item.IMGFILES_ID"
                      width="40"
                      height="40"
                      style="object-fit: cover;">
                  </viewer>
                </div>
              </span>
            </td>
          </tr>
          <tr>
            <th>是否按期缴纳工伤保险</th>
            <td :colspan="dataForm.IS_INJURIES_PAY === '1' ? '':5">{{ formatLabel(dataForm.IS_INJURIES_PAY) }}</td>
            <th v-if="dataForm.IS_INJURIES_PAY === '1'">工伤保险有效期</th>
            <td v-if="dataForm.IS_INJURIES_PAY === '1'">{{ dataForm.IS_INJURIES_PAY_TIME }}</td>
            <th v-if="dataForm.IS_INJURIES_PAY === '1'">工伤保险凭证</th>
            <td v-if="dataForm.IS_INJURIES_PAY === '1'">
              <span>
                <viewer>
                  <img
                    v-for="item in gongshangbaoxianFile"
                    :src="config.fileUrl + item.FILEPATH"
                    :key="item.IMGFILES_ID"
                    width="40"
                    height="40"
                    style="object-fit: cover;">
                </viewer>
              </span>
            </td>
          </tr>
          <tr>
            <th>是否缴纳商业保险</th>
            <td :colspan="dataForm.ISPAY === '1' ? '' : 5">
              {{ formatLabel(dataForm.ISPAY) }}
            </td>
            <th v-if="dataForm.ISPAY === '1'">商业保险附件</th>
            <td v-if="dataForm.ISPAY === '1'">
              <span>
                <viewer>
                  <img
                    v-for="item in insuranceFileList"
                    :src="config.fileUrl + item.FILEPATH"
                    :key="item.IMGFILES_ID"
                    width="40"
                    height="40"
                    style="object-fit: cover;">
                </viewer>
              </span>
            </td>
            <th v-if="dataForm.ISPAY === '1'">商业保险单号</th>
            <td v-if="dataForm.ISPAY === '1'">{{ dataForm.ISPAY_NUMBER }}</td>
          </tr>
          <tr>
            <th>是否签订劳动合同</th>
            <td :colspan="dataForm.IS_SIGN_LABOR === '1' ? '' : 5">
              {{ formatLabel(dataForm.IS_SIGN_LABOR) }}
            </td>
            <th v-if="dataForm.IS_SIGN_LABOR === '1'">劳动合同附件</th>
            <td v-if="dataForm.IS_SIGN_LABOR === '1'" colspan="3">
              <span>
                <viewer>
                  <img
                    v-for="item in contractFileList"
                    :src="config.fileUrl + item.FILEPATH"
                    :key="item.IMGFILES_ID"
                    width="40"
                    height="40"
                    style="object-fit: cover;">
                </viewer>
              </span>
            </td>
          </tr>
          <tr/><tr>
            <th>是否参加三级安全培训</th>
            <td >{{ formatLabel(dataForm.IS_LEVEL_THREE) }}</td>
            <th>三级安全培训照片</th>
            <td v-if="photosOfLevel.length>0" colspan="3">
              <span>
                <div class="img-flex">
                  <viewer>
                    <img
                      v-for="item in photosOfLevel"
                      :src="config.fileUrl + item.FILEPATH"
                      :key="item.IMGFILES_ID"
                      width="40"
                      height="40"
                      style="object-fit: cover;">
                  </viewer>
                </div>
              </span>
            </td>
          </tr>
          <tr>
            <th>是否特殊工种</th>
            <td >{{ formatLabel(dataForm.IS_SPECIAL_JOB) }}</td>
            <th>是否流动人员</th>
            <td colspan="3">{{ formatLabel(dataForm.ISFLOW) }}</td>
          </tr>
        </table>
      </div>
    </div>

    <div class="ui-foot" style="margin-left: -20px;bottom: -8px;">
      <el-button plain type="info" @click="back">返 回</el-button>
    </div>

  </div>
</template>

<script>
import { requestFN } from '@/utils/request'

export default {
  data() {
    return {
      config: config,
      imgUrl: '',
      listLoading: false,
      wenhuachengduList: [],
      postList: [],
      contractFileList: [], // 合同文件
      insuranceFileList: [], // 保险文件
      userPhotoFile: [], // 头像
      userCardIDPhotoFile: [], // 身份证照片
      photosOfLevel: [], // 三级教育培训
      socialPhotoFile: [], // 身份证照片
      gongshangbaoxianFile: [], // 身份证照片
      dataForm: {
        contractFileList: [], // 合同文件
        insuranceFileList: [], // 保险文件
        CARD_ID: '', // 身份证号
        DEPARTMENT_NAME: '', // 部门名称
        CORPINFO_ID: '', // 企业id
        HKLOCAL: '', // 户口所在地
        AGE: '',
        SEX: '',
        ADDRESS: '',
        PHONE: '',
        IS_SOCIAL: '', // 是否缴纳社保
        SOCIAL_NUMBER: '', // 社会保障号码
        IS_LEVEL_THREE: '', // 是否参加三级安全培训
        IS_SPECIAL_JOB: '', // 是否特殊工种
        ISFLOW: '', //
        PHOTO: [],
        IS_INJURIES_PAY: '',
        CORP_START_DATE: '',
        IS_BODY_ADAPT: '',
        IS_SAFETY_TELL: '',
        ISPAY: '',
        IS_SIGN_LABOR: '',
        DEPARTMENT_ID: '',
        POST_ID: '',
        PERSON_WORK_TYPE: '', // 工种
        USERNAME: '',
        NAME: '',
        BZ: '',
        PERSON_TYPE: '',
        PASSWORD: 'Aa@123456789',
        DATE_OF_BIRTH: '', // 出生年月

        DEGREE_OF_EDUCATION: '', // 文化程度
        POST: '', // 职务
        TYPE_OF_WORK: '', // 工种
        ENTRY_DATE: '', // 入职日期
        WORK_DATE: '' // 参加工作日期
      },
      USER_ID: '',
      CORPINFO_ID: ''
    }
  },
  async created() {
    // await this.getTreeList()
    this.getDict()
    this.getList()
  },
  methods: {
    back() {
      this.$parent.activeName = 'List'
    },
    // 转换是否
    formatLabel(value) {
      if (value == '1') {
        return '是'
      } else if (value == '0') {
        return '否'
      } else {
        return ''
      }
    },
    // 获取数据字典数据
    getDict() {
      requestFN(
        'dictionaries/getLevels',
        { DICTIONARIES_ID: 'd7d80f08d73a4accbccf4fd3d8d1d867' }
      ).then((data) => {
        this.wenhuachengduList = data.list
      }).catch((e) => {
        this.listLoading = false
      })
    },
    getList() {
      this.listLoading = true
      requestFN(
        'user/getDetailByUserIdAndCorpInfoId',
        {
          USER_ID: this.$parent.USER_ID,
          CORPINFO_ID: this.$parent.CORPINFO_ID,
          EMPLOYMENT_APPLY_MANAGEMENT_ID: this.$parent.EMPLOYMENT_APPLY_MANAGEMENT_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.dataForm = Object.assign(this.dataForm, data.pd)
        this.userPhotoFile = data.userPhotoFile
        if (this.userPhotoFile.length > 0) {
          this.imgUrl = config.fileUrl + this.userPhotoFile[0].FILEPATH
        }
        this.photosOfLevel = data.photosOfLevel
        this.insuranceFileList = data.insuranceFile
        this.contractFileList = data.contractFile
        this.userCardIDPhotoFile = data.userCardIDPhotoFile
        this.socialPhotoFile = data.socialPhotoFile
        this.gongshangbaoxianFile = data.gongshangbaoxianFile
      }).catch((e) => {
        this.listLoading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
