<template>
	<view class="hzIndex">
		<hzHeader title="出行报备详情"></hzHeader>
		<view class="hzContent"  style="padding-top: 200upx;">
		<view class="details">
			<view class="detail_msg">
				<view class="info-item">
					<text class="label">报备时间： </text>
					<text class="infoSpan">{{formatDate(item.GMT_CREATED)}}</text>
				</view> 
				<view class="info-item">
					<text class="label">姓　　名： </text>
					<text class="infoSpan">{{item.USER_NAME}}</text>
				</view> 
				<view @click="callPhone(item.PHONE)" class="info-item">
					<text  class="label">联系方式： </text>
					<text class="infoSpan" >{{ item.PHONE }}</text>
				</view>
				<view class="info-item">
					<text  class="label">部　　门： </text>
					<text class="infoSpan">{{ item.ORG_NAME }}</text>
				</view> 
				<view class="info-item">
					<text  class="label">目的地： </text>
					<text class="infoSpan">{{ item.TRAVEL_PLACE }}</text>
				</view>
				<view class="info-item">
					<text  class="label">出行日期： </text>
					<text class="infoSpan">{{ item.TRAVEL_DATE.replace("|"," 至 ") }}</text>
				</view>
				<view class="info-item">
					<text  class="label">出行方式： </text>
					<text class="infoSpan">{{ item.TRAVEL_METHOD}}</text>
				</view>
				<view class="info-item" v-if="item.TRAVEL_METHOD!='自驾'">
					<text  class="label">车次航班： </text>
					<text class="infoSpan">{{ item.TRAVEL_METHOD_INFO}}</text>
				</view>
				<view class="info-item">
					<text  class="label">返程方式： </text>
					<text class="infoSpan">{{ item.TRAVEL_METHOD_BACK}}</text>
				</view>
				<view class="info-item" v-if="item.TRAVEL_METHOD_BACK!='自驾'">
					<text  class="label">返程车次航班： </text>
					<text class="infoSpan">{{ item.TRAVEL_METHOD_INFO_BACK}}</text>
				</view>
				<view class="info-item" >
					<text  class="label">出行类型： </text>
					<text class="infoSpan">{{ item.TRAVEL_TYPE}}</text>
				</view>
				<view class="info-item">
					<text  class="label">出行事由： </text>
					<text class="infoSpan">{{ item.REASON }}</text>
				</view>
				
				<!-- <view class="img-box" >
					<image  :src="formatImgUrl(item.APPROVAL_FORM)" mode=""  @click="vbPicture(new Array(formatImgUrl(item.APPROVAL_FORM)))"></image>
				</view> -->
			</view> 
			
		</view>
		<view >
			<view class="details">
				<YSteps lineNum='0' color='#fff' backgroundColor='#4db4ea' :infoList='process'></YSteps>
			</view>
		</view>
		<view  class="occupied" style="height: 180upx;"></view>
		<view v-if="queryType==1 && examineButton" style="position: fixed;bottom:0upx;height: 50upx;width: 100%;z-index: 9999;"><!-- uni-popup ref="butPopup" type="bottom" -->
			
			<view>
				<view class="footer-btn footer-btn-two batchBtn" >
					<view style="background: #f2f2f2;color: #00C277;"  class="btn btn-col btn1" @click="circulation()">拒绝</view>
					<view  class="btn btn-col1 btn2" @click="submit(1)">通过</view>
				</view>
			</view>
		</view>
		<!-- <view class="footer-btn" v-if="queryType==1 && item.report_status==0||item.report_status==1" @click="circulation()">
			<view class="btn">回复</view>
		</view> -->
		<uni-popup ref="popup" type="center" style="">
			<view style="background: white;width: 80%;height: 540upx;width: 600upx;position: relative;border-radius: 10upx;padding: 14upx;">
				<view style="color: #333;font-size: 30upx;font-weight: bold;padding: 10upx 0px;">
					<text>审核内容：</text>
				</view>
				<view style="width: 100%;border: 1px solid #E5E5E5;margin-top: 20upx;padding: 20upx;height: 300upx;color: #666;border-radius: 10upx;">
					<textarea style="width: 100%;height: 100%;" v-model="replyContent"  placeholder="请输入审核内容"/>
				</view>
				<view class="footer-btn footer-btn-two" style="position: absolute;margin-bottom: 20upx;">
					<view class="btn btn-col" style="width:40%;margin-left:7%;margin-right: 6%;border-radius: 10upx;" @click="closeCirculation()">取消</view>
					<view class="btn btn-col1" style="width:40%;border-radius: 10upx" @click="submit(2)">确定</view>
				</view>
			</view>
		</uni-popup>
		</view>
	</view>
</template>

<script>
	import {
		travelReportDetail,travelExamine
	} from '@/common/api.js';
	import {
		callbackRequest,
		callbackRequestNoLoading ,
		getStorage,
		alertTip,
		formatDate,
		sureAlterTip,
		convertImgToBase64,
		vbPicture,
		callPhone,wxSdk,
		formatImgUrl
	} from '@/common/util.js';
	import UniPopup from "@/components/uni-popup/uni-popup.vue"
	import YSteps from '@/components/Y-Steps/Y-Steps.vue'
	export default {
		components: {
			UniPopup,
			YSteps
		},
		data() {
			return {
				callPhone:callPhone,
				vbPicture:vbPicture,
				formatImgUrl:formatImgUrl,
				userInfo:getStorage('userInfo'),
				formatDate:formatDate,
				item: {},
				id:0,
				queryType:0,
				replyContent:'',
				userId: getStorage('userInfo').id,
				imgs:[],
				showAlert:false,
				userTypes:[],
				houseType:[],
				examineBatch:'',
				examineButton:true,
				process: []
			}
		},
		onLoad(option) {
			this.item = JSON.parse(option.item);
			this.id = this.item.UUID;
			this.queryType = option.queryType||0;
			this.examineBatch = option.examineBatch || 1;
			this.travelReportDetail();
		},
		methods: {
			travelReportDetail(){
				let _this = this;
				let params = {
					method: travelReportDetail,
					data: {
						userId: getStorage('userInfo').userId,
						travelId:_this.id,
					}
				};
				callbackRequest(params).then(res => {
					res = res.data;
					if (res.returnCode == 1) {
						_this.item = res.returnData[0];
						let details = res.returnData[0].detail||[]
						for(let i=0;i<details.length;i++){
							let obj = details[i];
							if(_this.examineBatch == obj.EXAMINE_BATCH){
								_this.examineButton = false;
							}
						}
						_this.process=[];
						if(_this.process.length==0){
							let pObj0 = {
								date: '经办人',
								info: _this.item.USER_NAME+' 发起申请',
								time: formatDate( _this.item.GMT_CREATED,'dateTime')
							}
							_this.process.push(pObj0);
						}
						if(details.length>0){
							for(let i=0;i<details.length;i++){
								let pObj = {
									date: details[i].DESCRIPTION,
									info: details[i].USER_NAME+"　"+(details[i].EXAMINE_STATE==1?"同意":"拒绝　"+(details[i].EXAMINE_OPINION||'')),
									time: formatDate(details[i].EXAMINE_TIME,'dateTime')
								}
								_this.process.push(pObj);
							}
						}
					} else {
						alertTip(res.returnMsg);
					}
				});
			},
			circulation(){
				this.$refs.popup.open();
				//this.closeButPopup();
			},
			closeCirculation(){
				this.$refs.popup.close()
			},
			submit(examineState){
				//examineState  1通过，2不通过
				let params = {
					"method": travelExamine,
					"data":{
						travelId: this.item.UUID,
						userId:getStorage('userInfo').id,
						userName:getStorage('userInfo').userName,
						examineState:examineState+'',
						examineOpinion:this.replyContent,
						examineBatch:this.examineBatch+''
					}
				};
				callbackRequest(params).then(res => {
					res = res.data;
					if (res.returnCode == 1) {
						alertTip(res.returnMsg);
						this.closeCirculation();
						this.travelReportDetail();
					} else {
						alertTip(res.returnMsg);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/css/common.scss';
	.batchBtn{
		position: absolute;height: 140upx; background: white;padding-top: 30upx;
		.btn1{
			width:40%;margin-left:7%;margin-right: 6%;border-radius: 10upx;
		}
		.btn2{
			width:40%;border-radius: 10upx;
		}
		.btn3{
			width: 28%;margin-left: 4%;border-radius: 10upx;
		}
		.btn4{
			width: 28%;margin-left: 4%;border-radius: 10upx;
		}
		.btn5{
			width: 28%;margin-left: 4%;border-radius: 10upx;
			background: #348CF2;
		}
	}
	.img-box {
		overflow: hidden;
		padding-top: 20rpx;
		padding-bottom: 10rpx;
	
		.img-item {
			float: left;
			width: 200upx;
			height: 200upx;
			border: 1px solid #ddd;
			margin: 0 22rpx 20upx 0upx;
			position: relative;
			box-sizing: border-box;
	
			.img {
				display: block;
				width: 100%;
				height: 100%;
			}
	
			.remove-btn {
				position: absolute;
				top: -18upx;
				right: -18upx;
				width: 44upx;
				height: 44upx;
				z-index: 2;
			}
		}
	
		.upload-btn {
			.img {
				width: 60upx;
				height: 60upx;
				margin: 70upx auto 0;
			}
		}
	}
 
	.details{
		// height: 550upx;
		background: white;
		margin: 15upx;
		border-radius: 15upx;
		.detail_header {
			border-bottom: #f8f8f8 5upx solid;
			height: 90upx;
			line-height: 90upx;
			margin: 15upx;
			border-radius: 10upx;
			.blueSign {
				height: 28upx;
				width: 5upx;
				background: #00c277;
				display: inline-block;
				margin-left: 20upx;
			}
			.font-tilte {
				font-weight:bold;
				margin-left: 20upx;
			}
		}
		.detail_msg {
			margin-left: 20upx;
			border-radius: 10upx;
			font-size: 24upx;
			.info-item{
				border-bottom:1px solid #f8f8f8;
				padding:20upx 10upx;
				line-height: 50upx;
				.label{
					display:inline-block;
					min-width:150upx;
					width: auto;
					font-size:28upx;
					color:#333;
					font-weight:bold;
				}
			}
			.status {
				.infoSpan{
					color: #00c277;
				}
				.infoSpan2{
					color: red;
				}
			}
			.img-box {
				// background: #fff;
				image{
					width: 200upx;
					height: 200upx;
					margin:20upx 20upx 0 0;
				}
			}
		}
	}

	.common-shade{
		position:fixed;
		top:0;
		left:0;
		width:100%;
		height:100vh;
		background: rgba(0,0,0,0.7);
		z-index:9999;
	}
	
	.box {
		display: flex;
		display: -webkit-flex;
	}
	
	.box-row-reverse {
		flex-direction: row;
	}
	
	/*上下排列*/
	.box-column {
		flex-direction: column;
	}
	
	/*上下排列*/
	.box-left {
		justify-content: flex-start;
	}
	
	/*居右*/
	.box-right {
		justify-content: flex-end;
	}
	
	/*居左*/
	.box-center {
		justify-content: center;
	}
	
	/*居中*/
	.box-between {
		justify-content: space-between;
	}
	
	/*两端对齐*/
	.box-align-center {
		align-items: center;
	}
	
	.box-wrap {
		flex-wrap: wrap;
	}
</style>
