<template>
	<view>
		<view class="content" style="padding: 10px;">
			<view class="card">
				<view class="text_content">
					<view class="title title_left">基础信息</view>
<!--					<view class="title_right" @click="fnGoEditUserInfo">修改</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">
								<u--image :src="item" width="100rpx" height="100rpx" style="margin-left: 10rpx;"
									@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">
								<u--image :src="item" width="100rpx" height="100rpx" style="margin-left: 10rpx;"
									@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 v-if = "info.DEPART_STATE == '0'" class="title_right" @click="goEdit">修改</view>-->
<!--					<view v-else class="title_right_red">已离职</view>-->
          <view class="title_right_red" v-if="info.DEPART_STATE != '0'">已离职</view>
				</view>
				<u-cell-group>
					<u-cell title="岗位名称" :value="info.POST_ID"></u-cell>
<!--					<u-cell title="本企业从业开始日期" :value="info.CORP_START_DATE"></u-cell>-->
<!--					<u-cell title="本岗位从业开始日期" :value="info.ENTRY_DATE"></u-cell>-->
					<u-cell title="是否签署劳动合同" :value="info.IS_SIGN_LABOR == '0' ? '否' : '是'"></u-cell>
					<u-cell title="劳动合同附件" v-show="info.IS_SIGN_LABOR === '1'">
						<template #value>
							<view v-for="(item,index) in contractFile" :key="index"
								style="display: flex;justify-content: space-between">
								<u--image :src="item" width="100rpx" height="100rpx" style="margin-left: 10rpx;"
									@click="fnPreview(contractFile)"></u--image>
							</view>
						</template>
					</u-cell>
					<u-cell title="是否缴纳工伤保险" :value="info.IS_INJURIES_PAY == '0' ? '否' : '是'"></u-cell>
					<u-cell title="工伤有效期" v-show="info.IS_INJURIES_PAY === '1'" :value="info.IS_INJURIES_PAY_TIME">
					</u-cell>
					<u-cell title="工伤保险凭证" v-show="info.IS_INJURIES_PAY === '1'">
						<template #value>
							<view v-for="(item,index) in workInsurancePhotoFile" :key="index"
								style="display: flex;justify-content: space-between">
								<u--image :src="item" width="100rpx" height="100rpx" style="margin-left: 10rpx;"
									@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">
								<u--image :src="item" width="100rpx" height="100rpx" style="margin-left: 10rpx;"
									@click="fnPreview(insuranceFile)"></u--image>
							</view>
						</template>
					</u-cell>
					<u-cell title="是否参加三级安全培训" :value="info.IS_LEVEL_THREE == '0' ? '否' : '是'"></u-cell>
					<u-cell title="是否特殊工种" :value="info.IS_SPECIAL_JOB == '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
			// if (query.DEPART_STATE != '0') {
			// 	this.DEPART_STATE = query.DEPART_STATE
			// }
			this.fnGetData()
		},
		computed: {
			userInfo() {
				return this.$store.getters.getUserInfo
			}
		},
		methods: {
			fnGoEditUserInfo() {
				uni.$u.route({
					url: '/pages/mine/information/update'
				})
			},
			// goEdit() {
			// 	uni.$u.route({
			// 		url: '/pages/related_party_units/edit',
			// 		params: {
			// 			EMPLOYMENT_APPLY_MANAGEMENT_ID: this.EMPLOYMENT_APPLY_MANAGEMENT_ID,
			// 			CORPINFO_ID: this.CORPINFO_ID,
			// 			DEPART_STATE: this.DEPART_STATE
			// 		}
			// 	})
			// },
			reloadx() {
				this.contractFile = []
				this.insuranceFile = []
				this.userCardIDPhotoFile = []
				this.socialPhotoFile = []
				this.workInsurancePhotoFile = []
				this.fnGetData()
			},
			async fnGetData() {
				let resData = await getUserInfo({
					// CORPINFO_ID:this.userInfo.CORPINFO_ID,
					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)
          console.log(this.info.userPhoto)
        }

			},
			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>
