<template>
	<view>
		<scroll-view scroll-y class="page">
			<cu-custom bgColor="bg-gradual-pink" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">用户详情</block>
				
			</cu-custom>
			<!-- list列表 -->
			<view class="cu-list menu">
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.1s'}]">
					<view class="content">
						<text class="text-grey">头像</text>
					</view>
					<view class="action">
						<view class="cu-avatar round sm" :style="{backgroundImage: 'url(' + personalMsg.avatar + ')'}"></view>
					</view>
				
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
					<view class="content">
						<text class="text-grey">账号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.username}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
					<view class="content">
						<text class="text-grey">工号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.workNo}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.4s'}]">
					<view class="content">
						<text class="text-grey">姓名</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.realname}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.5s'}]">
					<view class="content">
						<text class="text-grey">性别</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.sex}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.6s'}]">
					<view class="content">
						<text class="text-grey">英文名</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.egName}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.7s'}]">
					<view class="content">
						<text class="text-grey">职位</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.post}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.8s'}]">
					<view class="content">
						<text class="text-grey">部门</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.orgCodeTxt}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.9s'}]">
					<view class="content">
						<text class="text-grey">邮箱</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.email}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1s'}]">
					<view class="content">
						<text class="text-grey">手机号码</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.phone}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.1s'}]">
					<view class="content">
						<text class="text-grey">出生日期</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.birthday}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.2s'}]">
					<view class="content">
						<text class="text-grey">入职日期</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.entryDate}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.3s'}]">
					<view class="content">
						<text class="text-grey">紧急联系人</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.urgentName}}</text>
					</view>
				</view>
				
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.4s'}]">
					<view class="content">
						<text class="text-grey">联系人电话</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.urgentPhone}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.5s'}]">
					<view class="content">
						<text class="text-grey">当前可用年假</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.availableDay/24}}天</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.6s'}]">
					<view class="content">
						<text class="text-grey">当前剩余调休</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.leaveDate}}小时</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.7s'}]">
					<view class="content">
						<text class="text-grey">考勤记录</text>
					</view>
					<view class="action">
						<span style="float: right;" v-if='personalMsg.sum=="2"' @click="sign()">本月无异常</span>
						 <span style="float: right;color: red;" v-if='personalMsg.sum=="1"' @click="sign()">
							本月有异常
						</span>
					</view>
				</view>
			</view>
	
		</scroll-view>
	</view>
</template>
<script>
	import api from '@/api/api'
	export default {
			data() {
				return {
					personalMsg:{
							avatar:'',
							realname:'',
							username:'',
							post:'',
							depart:'',
							phone:'',
							workNo:'',
							birthday:'',
							email:'',
							sex:'',
							egName:'',
							birthDate:'',
							entryDate:'',
							urgentName:'',
							urgentPhone:'',
							availableDay:'',
							orgCodeTxt:'',
							leaveDate:'',
							sum:''
						},
						userUrl:'/sys/user/queryById',
						positionUrl:'/sys/position/list',
						departUrl:'/sys/user/userDepartList'
					};
			},
			created() {
				
				this.loadinfo();
				
			},methods:{
				
				getSubStringText(text,len){
					if(!text || text.length==0){
						return ''
					}
					if(text.length<len){
						return text;
					}
					return text.substr(0,len)+"..."
				},
				rightClick(){
					this.$Router.push({name:'useredit', params:this.personalMsg})
					/* uni.navigateTo({
					    url: '/pages/user/useredit?item='+item
					}); */
				},loadinfo(){
				this.$http.get(this.userUrl,{params:{id:this.$store.getters.tmsUserId}}).then(res=> {
					console.log("用户",res)
					if (res.statusCode==200) {
						let result = res.data.data
						let avatar=(result.avatar && result.avatar.length > 0)? api.getFileAccessHttpUrl(result.avatar):'/static/avatar_boy.png'
						this.personalMsg.avatar = avatar
						this.personalMsg.realname = result.realname
						this.personalMsg.username = result.username
						this.personalMsg.post = result.post
						this.personalMsg.depart = result.departIds
						this.personalMsg.phone=result.phone
						this.personalMsg.workNo=result.workNo
						this.personalMsg.birthday=result.birthday
						this.personalMsg.email=result.email
						if(result.sex==1){
							this.personalMsg.sex='男';
						}else{
							this.personalMsg.sex='女';
						}
						
						this.personalMsg.egName=result.egName
						this.personalMsg.birthDate=result.birthDate
						this.personalMsg.entryDate=result.entryDate
						this.personalMsg.urgentName=result.urgentName
						this.personalMsg.urgentPhone=result.urgentPhone
						if(res.data.sign!="" &&res.data.sign!=undefined){
							this.personalMsg.availableDay=res.data.sign.availableDay
							this.personalMsg.leaveDate=res.data.sign.leaveDate
						}
						this.personalMsg.orgCodeTxt=result.orgCodeTxt
						
						this.personalMsg.sum=res.data.sum
						
						
					}
				}).catch(e=>{
					console.log("请求错误",e)
				})
				},
				/* queryshow(){
				var orgCode=this.$store.getters.orgCode;
				if(orgCode=="A01B92")
					this.isshow=true;
					
				}, */
				/* load(){
					this.$http.get(this.userUrl,{params:{id:this.$store.getters.tmsUserId}}).then(res=>{
						console.log("res",res)
						 
							let perArr = res.data.data;
					        let avatar=(perArr.avatar && perArr.avatar.length > 0)? api.getFileAccessHttpUrl(perArr.avatar):'/static/avatar_boy.png'
							this.personalList.avatar =avatar
							this.personalList.realname = perArr.realname
							this.personalList.username = perArr.username
							this.personalList.post = perArr.post
							this.personalList.depart = perArr.departIds
							this.personalList.phone=perArr.phone
							this.personalList.workNo=perArr.workNo
							this.personalList.birthday=perArr.birthday
							this.personalList.email=perArr.email
							this.personalList.sex=perArr.sex
							this.personalList.egName=perArr.egName
							this.personalList.birthDate=perArr.birthDate
							this.personalList.entryDate=perArr.entryDate
							this.personalList.urgentName=perArr.urgentName
							this.personalList.urgentPhone=perArr.urgentPhone
							this.personalList.id=perArr.id
							if(res.data.sign.length>0&&res.data.sign[0].availableDay!=null){
								this.personalList.availableDay=res.data.sign[0].availableDay
							}
							if(res.data.sign.length>0&&res.data.sign[0].leaveDate!=null){
								this.personalList.leaveDate=res.data.sign[0].leaveDate
							}
							
							this.personalList.orgCodeTxt=perArr.orgCodeTxt
							
							this.personalList.sum=res.data.sum
						
					}).catch(err => {
						console.log(err);
					});
					
				},
				ret(){
					this.$Router.push({name:'teames'})
				}, */
				sign(s){
					this.$store.commit('SET_NPMUSER',{id:s,date:''});
					this.$Router.push({name:'teamusersign'})
				}
				
			}
			
		}
</script>

<style>
	.panl{
		
		 
	}
	.card{
		background-color: #FFFFFF; 
		width: 95%;
		height: 100px;
		margin: 0 auto;
		border-radius:5px 5px 5px 5px;
		box-shadow:0 4px 8px 0 rgba(255, 255, 255, 0.2),0 6px 20px 0 rgba(255, 255, 255, 0.2);
	}
	.imgs{
		width: 60px;
		height: 60px;
		border-radius:50%; 
	}
	.fontColr{
		color: #0081FF;
		font-size: 13px;
	}
	
	.s{
		list-style-type:none;
		margin-left: -20px;
	}
	.fontColrs{
		color: #A3A7B1;
	}
	.ic{
		width: 20px;
		height: 20px;
		
		margin-left: 10px;
	}
	
	.top{
		  background-color: #5677AC;
		  width: 100%;
		  height: 40px;
		 
	}
</style>
