<template>
	<view class='page'>
		<view class="top_container" style="padding-right: 30upx;clear: both;overflow: auto;">
			<view class="report_status" style="float: left;">
				<text class="magtext">面试阶段: 第{{this.thisIndex}}轮</text>
			</view>
			<view style="float: right;">  
				<!-- <view class="btn"   @click="approval()">面试意见</view> -->
				<button type="primary" style="font-size: 12px;" @click="approval()" :disabled="showBtn">面试意见</button>
			</view>
		</view>
		<view class="detail_name_container">
			<view :class="[current_num==1?'current':'']" @click="changecurrent(1)">应聘人信息</view>
		</view>
		<view v-if="current_num==1">
			<view class="myContainer myContentBox">
<!-- 				<view class="top_container">基本信息</view> -->
				<view class="list_item">
					<view class="list_item_name">应聘部门</view>
					<view class="list_item_content content_right">{{overTimeApply.deptName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">应聘岗位</view>
					<view class="list_item_content content_right">{{overTimeApply.matchPositionName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">姓名</view>
					<view class="list_item_content content_right">{{overTimeApply.candidateName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">性别</view>
					<view class="list_item_content content_right">{{overTimeApply.genderName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">年龄</view>
					<view class="list_item_content content_right">{{overTimeApply.age||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">身份证号</view>
					<view class="list_item_content content_right">{{overTimeApply.idNumber||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">手机号</view>
					<view class="list_item_content content_right">{{overTimeApply.mobilePhone||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">最高学历</view>
					<view class="list_item_content content_right">{{overTimeApply.highestEducationName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">毕业院校</view>
					<view class="list_item_content content_right">{{overTimeApply.graduateSchool||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">所学专业</view>
					<view class="list_item_content content_right">{{overTimeApply.major||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">家庭住址</view>
					<view class="list_item_content content_right">{{overTimeApply.address||''}}</view>
				</view>

			</view>
			<view class="myCon myContentBox">
				<view class="top_container">备注信息</view>
				<view class="resultContent">{{overTimeApply.candidateRemarks}}</view>
				<view>
					<view class="list_item">
						<view class="list_item_name">操作：</view> 
						<view class="buttonstyle"><button type="primary" @click="preview()" style="width: 100%;font-size: 12px;">简历查看</button></view>
					</view>
				</view>
			</view>
		</view>
		<view class="goHome" @click='goMain("workInfo")'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	import uniSteps from '@/components/uni-steps/uni-steps.vue'
	import {
		config
	} from '../../request/js/config.js'
	export default{
		components: {
			uniSteps
		},
		data(){
			return {
				thisIndex: '',
				config:config,
				current_num:1,
				interviewId:'',
				overTimeApply:{},
				initFileList:[],
				active: 1,
				approvalList:[],
				canModify: '',
				num:1,
				name: '',
				showBtn:false,
			}
		},
		onLoad(option) {
			  this.interviewId=option.interviewId;
			  var _this = this;
			  uni.getStorage({
			  	key: 'userInfo',
			  	success: function (res) {
			  		_this.name = res.data.name
			  	}
			  });
			   var _this = this;
			   this.$http.request({
			     url: '/apis/interviewRecord/detail/'+option.interviewId,
				 method:'GET',
			     // params: {
			     //   id:option.id
			     // },
			   }).then(res=>{
					if(res.data.code == 0){
						this.overTimeApply=res.data.headInfo;
						this.initFileList = res.data.bodyInfo;
						for (var i= 0; i < this.initFileList.length; i++) { 
							// console.log(this.initFileList[i].interviewerName)
							// console.log(this.name)
							// console.log(this.initFileList[i].interviewerName.indexOf(this.name) != -1)
						    if(this.initFileList[i].interviewerName.indexOf(this.name) != -1) {
								this.thisIndex = i+1
								this.canModify = this.initFileList[i].canModify
								console.log(this.canModify)
								if(!this.canModify) {
									this.showBtn = true
									uni.showToast({
										title: '面试进程还未到您能参与的面试节点，暂不能填写面试意见',
										duration: 	1000,
										icon:"none"
									});
								}
							}
						 }
						//这边根据详情返回的审批id 获取审批的流程。
						// this.$http.request({
						//   url: '/apis/dingding/getHistoryByProcessId',
						//   params: {
						//     processId:_this.overTimeApply.processInstanceId
						//   },
						// }).then(res=>{
						// 	if(res.data.code == 0){
						// 		res.data.activitiList.forEach(function(val,index){
						// 			var myjson = {
						// 				title: val.userName+val.dealName+(val.reason?('~不通过，原因：'+val.reason):''),
						// 				desc: val.dealTime?('时间：'+val.dealTime):'时间：-'
						// 			}
						// 			if(val.isDealed){
						// 				_this.active = index;
						// 			}
						// 			_this.approvalList.push(myjson);
						// 		});
						// 	}
						// }).catch(err=>{
						// 	  uni.showToast({
						// 		title: '获取信息失败',
						// 		duration: 	1000,
						// 		icon:"none"
						// 	  });
						// });
					} 
			   })
			
		},
		methods:{
			// 查看简历
			preview() {
				let filePathArr = []
				if(this.overTimeApply&&this.overTimeApply.resumeFile.length>0) {
					// this.overTimeApply.resumeFile.forEach(item => {
					// 	console.log(item.filePath)
					// 	filePathArr.push(config.imgURL+item.filePath)						
					// })
					// alert(filePathArr)
					// console.log(filePathArr)
					console.log(this.overTimeApply.resumeFile[0].filePath)
					// uni.downloadFile({
					  // url: this.overTimeApply.resumeFile[0].filePath,
					  // success: function (res) {
						 //  console.log(res)
					  //   var filePath = res.tempFilePath;
					    uni.openDocument({
					      filePath: config.imgURL+this.overTimeApply.resumeFile[0].filePath,
					      success: function (res) {
					        console.log('打开文档成功');
					      }
					    });
					  // }
					// });
				} else {
					uni.showToast({
						title: '还未上传简历',
						duration: 	1000,
						icon:"none"
					});
				}
				
			},
			
			//点击审批
			approval(){
				uni.navigateTo({
				    url: "interviewOptions?id="+this.interviewId
				});
			},
			//回复
			sendMsg(){
				uni.navigateTo({
				    url: "sendMsg?id="+this.interviewId
				});
			},
			changecurrent(num){
				this.current_num=num;
			}
		},
		// onBackPress(options) { //取消默认的返回事件.
		// 	uni.navigateTo({
		// 		url: "extraWork"
		// 	});
		// 	return true;
		// }
	}
</script>

<style scoped>
	
	.btn{
		width: 160upx;
		height:68upx;
		text-align: center;
		line-height: 68upx;
		border-radius: 10upx;
		background-color: #3382FF;
		color: #fff;
		font-size: 28upx;
		float: left;
		margin-right: 30upx;
	}
	.buttonstyle {
		float: right;
	}
	
</style>

