<template>
	<view>
		<view class="uni-common-mt">
			<view class="uni-list">
				<view class="uni-list-cell" hover-class="uni-list-cell-hover">
					<view class="uni-padding-wrap">
						<view class="uni-flex uni-row">
							<view class="mydefineText" style="width: 200upx;">员工工号</view>
							<view class="mydefineText rightText">{{deviceInfo.employeeCode}}</view>
						</view>
					</view>
				</view>
				<view class="uni-list-cell" hover-class="uni-list-cell-hover">
					<view class="uni-padding-wrap">
						<view class="uni-flex uni-row">
							<view class="mydefineText" style="width: 200upx;">员工姓名</view>
							<view class="mydefineText rightText">{{deviceInfo.employeeName}}</view>
						</view>
					</view>
				</view>
				<view class="uni-list-cell" hover-class="uni-list-cell-hover">
					<view class="uni-padding-wrap">
						<view class="uni-flex uni-row">
							<view class="mydefineText" style="width: 200upx;">部门</view>
							<view class="mydefineText rightText">{{deviceInfo.deptName}}</view>
						 </view>
					</view>
				 </view>
				 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
				 	<view class="uni-padding-wrap">
				 		<view class="uni-flex uni-row">
				 			<view class="mydefineText" style="width: 200upx;">任职岗位</view>
				 			<view class="mydefineText rightText">{{deviceInfo.employeePostName}}</view>
				 		 </view>
				 	</view>
				  </view>
				  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
				  	<view class="uni-padding-wrap">
				  		<view class="uni-flex uni-row">
				  			<view class="mydefineText" style="width: 200upx;">员工状态</view>
				  			<view class="mydefineText rightText">{{deviceInfo.employmentStateName}}</view>
				  		 </view>
				  	</view>
				   </view>
				   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
				   	<view class="uni-padding-wrap">
				   		<view class="uni-flex uni-row">
				   			<view class="mydefineText" style="width: 200upx;">用工类型</view>
				   			<view class="mydefineText rightText">{{deviceInfo.employmentTypeName}}</view>
				   		 </view>
				   	</view>
				    </view>
					<view class="uni-list-cell" hover-class="uni-list-cell-hover">
						<view class="uni-padding-wrap">
							<view class="uni-flex uni-row">
								<view class="mydefineText" style="width: 200upx;">身份证号</view>
								<view class="mydefineText rightText">{{deviceInfo.idNumber}}</view>
							 </view>
						</view>
					 </view>
					 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
					 	<view class="uni-padding-wrap">
					 		<view class="uni-flex uni-row">
					 			<view class="mydefineText" style="width: 200upx;">职称</view>
					 			<view class="mydefineText rightText">{{deviceInfo.employeeTitle}}</view>
					 		 </view>
					 	</view>
					  </view>
					  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
					  	<view class="uni-padding-wrap">
					  		<view class="uni-flex uni-row">
					  			<view class="mydefineText" style="width: 200upx;">职级</view>
					  			<view class="mydefineText rightText">{{deviceInfo.employeeLevel}}</view>
					  		 </view>
					  	</view>
					   </view>
					   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
					   	<view class="uni-padding-wrap">
					   		<view class="uni-flex uni-row">
					   			<view class="mydefineText" style="width: 200upx;">手机号码</view>
					   			<view class="mydefineText rightText">{{deviceInfo.mobilePhone}}</view>
					   		 </view>
					   	</view>
					    </view>
						<view class="uni-list-cell" hover-class="uni-list-cell-hover">
							<view class="uni-padding-wrap">
								<view class="uni-flex uni-row">
									<view class="mydefineText" style="width: 200upx;">出生日期</view>
									<view class="mydefineText rightText">{{deviceInfo.employeeBirthday}}</view>
								 </view>
							</view>
						 </view>
						 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
						 	<view class="uni-padding-wrap">
						 		<view class="uni-flex uni-row">
						 			<view class="mydefineText" style="width: 200upx;">性别</view>
						 			<view class="mydefineText rightText">{{deviceInfo.employeeGenderName}}</view>
						 		 </view>
						 	</view>
						  </view>
						  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
						  	<view class="uni-padding-wrap">
						  		<view class="uni-flex uni-row">
						  			<view class="mydefineText" style="width: 200upx;">最高学历</view>
						  			<view class="mydefineText rightText">{{deviceInfo.highestEducationName}}</view>
						  		 </view>
						  	</view>
						   </view>
						   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
						   	<view class="uni-padding-wrap">
						   		<view class="uni-flex uni-row">
						   			<view class="mydefineText" style="width: 200upx;">入职日期</view>
						   			<view class="mydefineText rightText">{{deviceInfo.entryDate}}</view>
						   		 </view>
						   	</view>
						    </view>
						   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
						   	<view class="uni-padding-wrap">
						   		<view class="uni-flex uni-row">
						   			<view class="mydefineText" style="width: 200upx;">民族</view>
						   			<view class="mydefineText rightText">{{deviceInfo.employeeNation}}</view>
						   		 </view>
						   	</view>
						    </view>
							<view class="uni-list-cell" hover-class="uni-list-cell-hover">
								<view class="uni-padding-wrap">
									<view class="uni-flex uni-row">
										<view class="mydefineText" style="width: 200upx;">婚姻状态</view>
										<view class="mydefineText rightText">{{deviceInfo.maritalStatusName}}</view>
									 </view>
								</view>
							 </view>
							 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
							 	<view class="uni-padding-wrap">
							 		<view class="uni-flex uni-row">
							 			<view class="mydefineText" style="width: 200upx;">户口类型</view>
							 			<view class="mydefineText rightText">{{deviceInfo.registeredTypeName}}</view>
							 		 </view>
							 	</view>
							  </view>
							  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
							  	<view class="uni-padding-wrap">
							  		<view class="uni-flex uni-row">
							  			<view class="mydefineText" style="width: 200upx;">户口所在地</view>
							  			<view class="mydefineText rightText">{{deviceInfo.registeredAddress}}</view>
							  		 </view>
							  	</view>
							   </view>
							   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
							   	<view class="uni-padding-wrap">
							   		<view class="uni-flex uni-row">
							   			<view class="mydefineText" style="width: 200upx;">籍贯</view>
							   			<view class="mydefineText rightText">{{deviceInfo.nativPlace}}</view>
							   		 </view>
							   	</view>
							    </view>
								<view class="uni-list-cell" hover-class="uni-list-cell-hover">
									<view class="uni-padding-wrap">
										<view class="uni-flex uni-row">
											<view class="mydefineText" style="width: 200upx;">政治面貌</view>
											<view class="mydefineText rightText">{{deviceInfo.politicalOutlookName}}</view>
										 </view>
									</view>
								 </view>
								 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
								 	<view class="uni-padding-wrap">
								 		<view class="uni-flex uni-row">
								 			<view class="mydefineText" style="width: 200upx;">入党时间</view>
								 			<view class="mydefineText rightText">{{deviceInfo.joiningPartyDate}}</view>
								 		 </view>
								 	</view>
								  </view>
								  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
								  	<view class="uni-padding-wrap">
								  		<view class="uni-flex uni-row">
								  			<view class="mydefineText" style="width: 200upx;">个人社保号</view>
								  			<view class="mydefineText rightText">{{deviceInfo.socialNumber}}</view>
								  		 </view>
								  	</view>
								   </view>
								   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
								   	<view class="uni-padding-wrap">
								   		<view class="uni-flex uni-row">
								   			<view class="mydefineText" style="width: 200upx;">公积金账号</view>
								   			<view class="mydefineText rightText">{{deviceInfo.providentAccount}}</view>
								   		 </view>
								   	</view>
								    </view>
									<view class="uni-list-cell" hover-class="uni-list-cell-hover">
										<view class="uni-padding-wrap">
											<view class="uni-flex uni-row">
												<view class="mydefineText" style="width: 200upx;">工资卡号</view>
												<view class="mydefineText rightText">{{deviceInfo.salaryCard}}</view>
											 </view>
										</view>
									 </view>
									 <view class="uni-list-cell" hover-class="uni-list-cell-hover">
									 	<view class="uni-padding-wrap">
									 		<view class="uni-flex uni-row">
									 			<view class="mydefineText" style="width: 200upx;">住房补贴账号</view>
									 			<view class="mydefineText rightText">{{deviceInfo.subsidyAccount}}</view>
									 		 </view>
									 	</view>
									  </view>
									  <view class="uni-list-cell" hover-class="uni-list-cell-hover">
									  	<view class="uni-padding-wrap">
									  		<view class="uni-flex uni-row">
									  			<view class="mydefineText" style="width: 200upx;">合同签订单位</view>
									  			<view class="mydefineText rightText">{{deviceInfo.signingUnit}}</view>
									  		 </view>
									  	</view>
									   </view>
									   <view class="uni-list-cell" hover-class="uni-list-cell-hover">
									   	<view class="uni-padding-wrap">
									   		<view class="uni-flex uni-row">
									   			<view class="mydefineText right" style="width: 600upx;">照片</view>
									   			<view class="img-wrap">
									   				<view class="img-box" v-if="deviceInfo.portrait">
									   					<img :src="config.imgURL+JSON.parse(deviceInfo.portrait)" />
									   				</view>
													<view class="img-box">
														
													</view>
									   			</view>
									   		 </view>
									   	</view>
									    </view>
			</view>
		</view>

		<view class="goHome" @click='goMain()'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	import {
		config
	} from '../../request/js/config.js'
	export default {  
		data() {
			return {
				id:'',
				config:config,
				deviceInfo:{}
			}
		},
		onLoad(options) {
			this.id = Number(options.id)
			//获取档案的基本信息。
			this.$http.request({
				url: '/apis/employeeInfo/detail/'+this.id,
				method: 'get',
			}).then(res=>{
				console.log(res)
				if(res.data.code == 0 && res.data.data){
					// var useTime = res.data.data.using_time;  //开始使用时间。
					// var service_year = res.data.data.service_year;	//使用年限。
					// var end_year = '';
					// if(useTime && service_year){
					// 	end_year = this.addDate(useTime,'y',service_year);
					// }
					// console(res.data.data.employeeInfoDO)
					this.deviceInfo = res.data.data.employeeInfoDO;
					this.deviceInfo.employeeBirthday = this.deviceInfo.employeeBirthday.substr(0,10)
					this.deviceInfo.entryDate = this.deviceInfo.entryDate.substr(0,10)
					// this.deviceInfo.end_year = end_year;
				}
			}).catch(err=>{
			});
		},
		methods: {
			    /**
			     * 对日期进行加减操作 该方法不会修改传入的Date对象
			     * @param date 如果为null 则表示为当前日期
			     * @param unit 单位 y:年 M:月 d:日 h:小时 m:分钟 s:秒
			     * @param value 增加的数值 可以为负数
			     * @return 返回值为修改后的新的Date对象
			     */
			    addDate:function(date,unit,value){
					date =  new Date(date.replace(/-/g, "/"));
			        var units = {
			            y:'FullYear',
			            M:'Month',
			            d:'Date',
			            h:'Hours',
			            m:'Minutes',
			            s:'Seconds'
			        }
			
			        try{
			            if(units[unit]){
			                date['set'+units[unit]](date['get'+units[unit]]() + parseInt(value));
			            }
			        }catch (e){
			            console.error(e);
			        }  
					var day1 = new Date();
					var time = date.getFullYear()+"-" + this.minTenAndZero(date.getMonth()+1) + "-" + this.minTenAndZero(date.getDate())+
						 " " + this.minTenAndZero(date.getHours()) + ":" + this.minTenAndZero(date.getMinutes()) + ":" + this.minTenAndZero(date.getSeconds()); 
			        return time;
			    },
				minTenAndZero:function(value){
				    return value<10?('0'+value):value;
				}
		}
	}
</script>

<style>
	.mydefineText {
		margin: 7px 5px;
		height: 70upx;
		line-height: 70upx;
		color: #999;
		font-size: 28upx;
	}
	.rightText{
		text-align: right;
		color: #333;
		-webkit-flex: 1;
		flex: 1;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden
	}
	.red{color: #f00;}
</style>
