<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">{{overTimeApply.approveStateName}}</text>
			</view>
			<view style="float: right;">
				<!-- 待审批和 审批中 -->
				<view class="btn" v-if="overTimeApply.approveState==1" @click="approval()">审批</view>
				<!-- <view class="btn"   @click="sendMsg()">回复</view> -->
			</view>
		</view>
		<view class="detail_name_container">
			<view :class="[current_num==1?'current':'']" @click="changecurrent(1)">招聘信息</view>
			<view :class="[current_num==2?'current':'']" @click="changecurrent(2)">审批流程</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.advertiseTypeName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">招聘岗位</view>
					<view class="list_item_content content_right">{{overTimeApply.advertisePositionName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">岗位人数</view>
					<view class="list_item_content content_right">{{overTimeApply.deptCounts||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">岗位编制</view>
					<view class="list_item_content content_right">{{overTimeApply.deptAuthorized||'0'}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">缺编人数</view>
					<view class="list_item_content content_right">{{overTimeApply.authorizedCounts||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">是否编制</view>
					<view class="list_item_content content_right">{{overTimeApply.isAuthorized||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">招聘人数</view>
					<view class="list_item_content content_right">{{overTimeApply.advertiseCounts||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">期望到岗日期</view>
					<view class="list_item_content content_right">{{overTimeApply.comeDate||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">岗位性质</view>
					<view class="list_item_content content_right">{{overTimeApply.positionNatureName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">工资待遇</view>
					<view class="list_item_content content_right">{{overTimeApply.salaryName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">福利待遇</view>
					<view class="list_item_content content_right">{{overTimeApply.welfareTreatmentName||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">工作地点</view>
					<view class="list_item_content content_right">{{overTimeApply.workAddress||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">申请人</view>
					<view class="list_item_content content_right">{{overTimeApply.applicant||''}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">申请日期</view>
					<view class="list_item_content content_right">{{overTimeApply.submitTime||''}}</view>
				</view>
			</view>
			<view class="myCon myContentBox">
				<view class="top_container">备注说明</view>
				<view class="resultContent">{{overTimeApply.remarks}}</view>
				<!-- <view class="img-wrap" v-for="(items,index) in initFileList" :key='index'>
					<view class="img-box">
						<img :src="config.imgURL+items.filePath" />
					</view>
				</view> -->
			</view>
		</view>
		<view v-else-if="current_num==2">
			<view class="myCon myContentBox" v-if="approvalList.length>0">
				<uni-steps :options="approvalList" :active="active" direction="column" />
			</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 {
				config: config,
				current_num: 1,
				id: '',
				overTimeApply: {},
				initFileList: [],
				active: 1,
				approvalList: [],
				num: 1,
				instanceId:'',
				taskId:''
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.num = option.num;
			if (this.id == undefined) {
				uni.reLaunch({
					url: 'extraWork'
				});
				return false;
			}
			var _this = this;
			this.$http.request({
				url: '/apis/advertiseInfo/get/' + option.id,
				method: 'GET',
				// params: {
				//   id:option.id
				// },
			}).then(res => {
				if (res.data.code == 0) {
					this.overTimeApply = res.data.data;
					this.overTimeApply.comeDate = this.overTimeApply.comeDate.substr(0, 10)
					// this.initFileList = res.data.approvedPersons;
					if (res.data.data.taskInfo) {
						this.instanceId = res.data.data.taskInfo.instanceId
						this.taskId = res.data.data.taskInfo.taskId
					}
					//这边根据详情返回的审批id 获取审批的流程。
					if (res.data.data.progressList) {
						res.data.data.progressList.forEach(function(val, index) {
							var myjson = {
								title: val.approveName + (val.approveState ? val.approveState : '') + (
									val.reason ? ('~不通过，原因：' + val.reason) : ''),
								desc: val.approveTime ? ('时间：' + val.approveTime) : '时间：-'
							}
							if (val.isDealed) {
								_this.active = index;
							}
							_this.approvalList.push(myjson);
						});
					}
					// this.$http.request({
					//   url: '/apis/dingding/getHistoryByProcessId',
					//   params: {
					//     processId:_this.overTimeApply.processInstanceId
					//   },
					// }).then(res=>{
					// 	if(res.data.code == 0){
					// 		res.data.data.progressList.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"
					// 	  });
					// });
				}
			}).catch(err => {
				uni.showToast({
					title: '获取信息失败',
					duration: 1000,
					icon: "none"
				});
			});

		},
		methods: {
			//点击审批
			approval() {
				uni.navigateTo({
					url: "approval?id=" +this.id+"&type=" + 12 +"&taskId="+this.taskId+"&instanceId="+this.instanceId
				});
			},
			//回复
			sendMsg() {
				uni.navigateTo({
					url: "sendMsg?id=" + this.id
				});
			},
			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;
	}
</style>
