<template>
  <view>
    <view class="content" style="padding: 10px;">
      <view class="card">
        <view class="text_content">
          <view class="title title_left">基础信息</view>
        </view>
        <u-cell-group>
          <u-cell title="照片">
            <template #value>
              <u--image :src="info.userPhoto" shape="circle" width="100rpx" height="100rpx"></u--image>
            </template>
          </u-cell>
          <u-cell title="姓名" :value="info.NAME"></u-cell>
          <u-cell title="性别" :value="info.SEX === '1' ? '女' : '男'">
            <template #value>
              {{ info.SEX === '1' ? '女' : '' }}
              {{ info.SEX === '0' ? '男' : '' }}
            </template>
          </u-cell>
          <u-cell title="出生年月" :value="info.DATE_OF_BIRTH"></u-cell>
          <u-cell title="年龄" :value="info.AGE"></u-cell>
          <u-cell title="身份证" :value="info.CARD_ID"></u-cell>
          <u-cell title="身份证照片">
            <template #value>
              <view v-for="(item,index) in userCardIDPhotoFile" :key="index"
                    style="display: flex;justify-content: space-between;margin-left: 10rpx;">
                <u--image :src="item" width="100rpx" height="100rpx"
                          @click="fnPreview(userCardIDPhotoFile)"></u--image>
              </view>
            </template>
          </u-cell>
          <u-cell title="民族" :value="info.NATIONALITY_NAME"></u-cell>
          <u-cell title="户口所在地">
            <template #value>
              <u--text :lines="2" align="right" :text="info.HKLOCAL"></u--text>
            </template>
          </u-cell>
          <u-cell title="现住址">
            <template #value>
              <u--text :lines="2" align="right" :text="info.ADDRESS"></u--text>
            </template>
          </u-cell>
          <u-cell title="联系电话" :value="info.PHONE"></u-cell>
          <u-cell title="婚姻状况" :value="info.MARITALSTATUS_NAME"></u-cell>
          <u-cell title="政治面貌" :value="info.POLITICAL_STATUS_NAME"></u-cell>
          <u-cell v-if="info.POLITICAL_STATUS == 'zhonggongdangyuan'" title="入党时间"
                  :value="info.POLITICAL_TIME"></u-cell>


          <u-cell title="社会保障号" :value="info.SOCIAL_NUMBER"></u-cell>
          <u-cell title="社会保障卡照片">
            <template #value>
              <view v-for="(item,index) in socialPhotoFile" :key="index"
                    style="display: flex;justify-content: space-between;margin-left: 10rpx;">
                <u--image :src="item" width="100rpx" height="100rpx"
                          @click="fnPreview(socialPhotoFile)"></u--image>
              </view>
            </template>
          </u-cell>
          <u-cell title="是否流动人员" :value="info.isflow === '0' ? '否' : '是'"></u-cell>
        </u-cell-group>
      </view>
    </view>
    <view class="content" style="padding: 10px">
      <view class="card">
        <view class="text_content">
          <view class="title title_left">企业就职信息</view>
          <view class="title_right_red" v-if="info.departState !== '0'">已离职</view>
        </view>
        <u-cell-group>
          <u-cell title="岗位名称" :value="info.postId"></u-cell>
          <u-cell title="是否签署劳动合同" :value="info.isSignLabor === '0' ? '否' : '是'"></u-cell>
          <u-cell title="劳动合同附件" v-show="info.isSignLabor === '1'">
            <template #value>
              <view v-for="(item,index) in contractFile" :key="index"
                    style="display: flex;justify-content: space-between;margin-left: 10rpx;">
                <u--image :src="item" width="100rpx" height="100rpx"
                          @click="fnPreview(contractFile)"></u--image>
              </view>
            </template>
          </u-cell>
          <u-cell title="是否缴纳工伤保险" :value="info.isInjuriesPay === '0' ? '否' : '是'"></u-cell>
          <u-cell title="工伤有效期" v-show="info.isInjuriesPay === '1'" :value="info.IS_INJURIES_PAY_TIME">
          </u-cell>
          <u-cell title="工伤保险凭证" v-show="info.isInjuriesPay === '1'">
            <template #value>
              <view v-for="(item,index) in workInsurancePhotoFile" :key="index"
                    style="display: flex;justify-content: space-between;margin-left: 10rpx;">
                <u--image :src="item" width="100rpx" height="100rpx"
                          @click="fnPreview(workInsurancePhotoFile)"></u--image>
              </view>
            </template>
          </u-cell>
          <u-cell title="是否缴纳商业保险" :value="info.ispay === '0' ? '否' : '是'"></u-cell>
          <u-cell title="商业保险单号" v-show="info.ispay === '1'" :value="info.ISPAY_NUMBER"></u-cell>
          <u-cell title="保险附件" v-show="info.ispay === '1'">
            <template #value>
              <view v-for="(item,index) in insuranceFile" :key="index"
                    style="display: flex;justify-content: space-between;margin-left: 10rpx;">
                <u--image :src="item" width="100rpx" height="100rpx"
                          @click="fnPreview(insuranceFile)"></u--image>
              </view>
            </template>
          </u-cell>
          <u-cell title="是否参加三级安全培训" :value="info.isLevelThree === '0' ? '否' : '是'"></u-cell>
          <u-cell title="是否特殊工种" :value="info.isSpecialJob === '0' ? '否' : '是'"></u-cell>
        </u-cell-group>
      </view>
    </view>
  </view>

</template>

<script>
import {
  getUserInfo
} from "../../api";

export default {
  data() {
    return {
      info: {},
      empInfo: {},
      userPhoto: {},
      contractFile: [],
      userCardIDPhotoFile: [],
      socialPhotoFile: [],
      insuranceFile: [],
      workInsurancePhotoFile: [],
      EMPLOYMENT_APPLY_MANAGEMENT_ID: '',
      CORPINFO_ID: '',
      DEPART_STATE: ''
    }
  },
  onNavigationBarButtonTap(e) {
    if (e.index === 0) {
      this.goEdit()
    }
  },
  onLoad(query) {
    this.EMPLOYMENT_APPLY_MANAGEMENT_ID = query.EMPLOYMENT_APPLY_MANAGEMENT_ID
    this.CORPINFO_ID = query.CORPINFO_ID
    this.fnGetData()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods: {
    fnGoEditUserInfo() {
      uni.$u.route({
        url: '/pages/mine/information/update'
      })
    },
    reloadx() {
      this.contractFile = []
      this.insuranceFile = []
      this.userCardIDPhotoFile = []
      this.socialPhotoFile = []
      this.workInsurancePhotoFile = []
      this.fnGetData()
    },
    async fnGetData() {
      let resData = await getUserInfo({
        dataType: this.DEPART_STATE,
        CORPINFO_ID: this.CORPINFO_ID,
        EMPLOYMENT_APPLY_MANAGEMENT_ID: this.EMPLOYMENT_APPLY_MANAGEMENT_ID
      })
      this.info = resData.pd
      if (resData.userCardIDPhotoFile) {
        for (let i = 0; i < resData.userCardIDPhotoFile.length; i++) {
          this.userCardIDPhotoFile.push(this.$filePath + resData.userCardIDPhotoFile[i].FILEPATH)
        }
      }
      if (resData.socialPhotoFile) {
        for (let i = 0; i < resData.socialPhotoFile.length; i++) {
          this.socialPhotoFile.push(this.$filePath + resData.socialPhotoFile[i].FILEPATH)
        }
      }
      if (resData.contractFile) {
        for (let i = 0; i < resData.contractFile.length; i++) {
          this.contractFile.push(this.$filePath + resData.contractFile[i].FILEPATH)
        }
      }
      if (resData.insuranceFile) {
        for (let i = 0; i < resData.insuranceFile.length; i++) {
          this.insuranceFile.push(this.$filePath + resData.insuranceFile[i].FILEPATH)
        }
      }
      if (resData.workInsurancePhotoFile) {
        for (let i = 0; i < resData.workInsurancePhotoFile.length; i++) {
          this.workInsurancePhotoFile.push(this.$filePath + resData.workInsurancePhotoFile[i].FILEPATH)
        }
      }
      if (resData.userPhotoFile && resData.userPhotoFile.length > 0) {
        this.$set(this.info, 'userPhoto', this.$filePath + resData.userPhotoFile[0].FILEPATH)
      }

    },
    fnPreview(urls) {
      uni.previewImage({
        urls
      })
    }
  },
}
</script>

<style scoped>
.text_content {
  display: flex;
}

.title_left {
  font-size: 40rpx;
  justify-content: flex-start;
  float: left;
  text-align: left;
  margin-bottom: 12px;
}

.title_right {
  margin-left: auto;
  font-size: 30rpx;
  margin-top: 5px;
}

.title_right_red {
  margin-left: auto;
  color: red;
  font-size: 30rpx;
  margin-top: 5px;
}
</style>
