<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">{{itemd.typeName}}</text>
				</view> 
				<view class="info-item">
					<text class="label">门卡类型： </text>
					<text class="infoSpan">{{itemd.cardType}}</text>
				</view> 
				
				<view class="info-item" v-if="itemd.cardType=='职工卡'">
					<view class="info-item">
						<text class="label">出入区域： </text>
						<uni-table ref="table" border emptyText="暂无更多数据" style="margin-top: 30upx;">
								<uni-tr></uni-tr>
								<uni-tr v-for="(item, index) in accessArea" :key="index">
									<uni-td align="center" width="80">{{ item.address }}</uni-td>
									<uni-td align="center">{{ item.area }}</uni-td>
								</uni-tr>
						</uni-table>
					</view>
					<view>
						<view v-for="(people,peopleIndex) in peopleList0" :key="peopleIndex" >
							<view style="margin: 20rpx 10rpx;font-size: 30rpx;font-weight: bold;border-left:4px solid #0DB0A7;">人员信息{{peopleIndex+1}}</view>
							<view class="form-item">
								<text class="label">人员姓名:</text>
								<text class="infoSpan">{{people.personnel}}</text>
							</view>
							<view class="form-item">
								<text class="label">人员部门:</text>
								<text class="infoSpan">{{people.unit}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系电话:</text>
								<text class="infoSpan">{{people.personnelPhone}}</text>
							</view>
							<view class="info-item" v-if="people.idPhoto">
								<text class="label">登记照片： </text>
								<br/>
								<image class="info-item" v-for="(item, index) in people.idPhoto.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
							<view class="info-item" v-if="people.photo!='null'">
								<text class="label">身份证图片： </text>
								<br/>
								<image v-if="item!=''" class="info-item" v-for="(item, index) in people.photo.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
						</view>
					</view>
				</view> 
				<view class="info-item" v-if="itemd.cardType=='第三方人员'">
					<view>
							<view class="form-item">
								<text class="label">项目归口管理部门:</text>
								<text class="infoSpan">{{item.xmgkOrgName}}</text>
							</view>
							<view class="form-item">
								<text class="label">经办人员:</text>
								<text class="infoSpan">{{item.jbUserName}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系电话:</text>
								<text class="infoSpan">{{item.jbUserPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">申请人姓名:</text>
								<text class="infoSpan">{{item.userInfoVos[0].personnel}}</text>
							</view>
							<view class="form-item">
								<text class="label">所属单位:</text>
								<text class="infoSpan">{{item.userInfoVos[0].unit}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系方式:</text>
								<text class="infoSpan">{{item.userInfoVos[0].personnelPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">申请类别:</text>
								<text class="infoSpan">{{item.applyType}}</text>
							</view>
							<view class="form-item">
								<text class="label">申请期限:</text>
								<text class="infoSpan">{{item.applyTerm}}</text>
							</view>
							<view class="info-item">
								<text class="label">出入区域： </text>
								<uni-table ref="table" border emptyText="暂无更多数据" style="margin-top: 30upx;">
										<uni-tr></uni-tr>
										<uni-tr v-for="(item, index) in accessArea" :key="index">
											<uni-td align="center" width="80">{{ item.address }}</uni-td>
											<uni-td align="center">{{ item.area }}</uni-td>
										</uni-tr>
								</uni-table>
							</view>
							<view class="info-item" v-if="item.userInfoVos[0].idPhoto">
								<text class="label">人脸照片： </text>
								<br/>
								<image class="info-item" v-for="(item, index) in item.userInfoVos[0].idPhoto.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
							<view class="info-item" v-if="item.userInfoVos[0].photo!='null'">
								<text class="label">身份证图片： </text>
								<br/>
								<image v-if="item!=''" class="info-item" v-for="(item, index) in item.userInfoVos[0].photo.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
							<view class="info-item" v-if="item.userInfoVos[0].documentation!='null'">
								<text class="label">身份证图片： </text>
								<br/>
								<image v-if="item!=''" class="info-item" v-for="(item, index) in item.userInfoVos[0].documentation.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
					</view>
				</view> 
				<view class="info-item" v-if="itemd.cardType=='VIP贵宾'">
					<view>
							<view class="form-item">
								<text class="label">经办部门:</text>
								<text class="infoSpan">{{item.xmgkOrgName}}</text>
							</view>
							<view class="form-item">
								<text class="label">经办人员:</text>
								<text class="infoSpan">{{item.jbUserName}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系电话:</text>
								<text class="infoSpan">{{item.jbUserPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">借出时间:</text>
								<text class="infoSpan">{{item.lendTime}}</text>
							</view>
							<view class="form-item">
								<text class="label">归还时间:</text>
								<text class="infoSpan">{{item.backTime}}</text>
							</view>
							<view class="info-item" v-if="item.documentation">
								<text class="label">附件： </text>
								<br/>
								<image class="info-item" v-for="(item, index) in item.documentation.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
							</view>
							<view class="form-item">
								<text class="label">实际归还时间:</text>
								<text class="infoSpan">{{item.backTime}}</text>
							</view>
							<view class="form-item">
								<text class="label">备注:</text>
								<text class="infoSpan">{{item.remark==null?" ":item.remark}}</text>
							</view>
							
					</view>
				</view> 
				<view class="info-item" v-if="itemd.cardType=='临时出入证'">
					<view>
							<view class="form-item">
								<text class="label">项目名称:</text>
								<text class="infoSpan">{{item.proName}}</text>
							</view>
							<view class="form-item">
								<text class="label">项目单位:</text>
								<text class="infoSpan">{{item.proUnit}}</text>
							</view>
							<view class="form-item">
								<text class="label">项目负责人:</text>
								<text class="infoSpan">{{item.proManager}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系电话:</text>
								<text class="infoSpan">{{item.proManagerPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">项目归口管理部门:</text>
								<text class="infoSpan">{{item.proManagerPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">经办人员:</text>
								<text class="infoSpan">{{item.proManagerPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">合同有效期:</text>
								<text class="infoSpan">{{item.contractStartTime}}</text>~<text class="infoSpan">{{item.contractEndTime}}</text>
							</view>
							<view class="info-item">
								<text class="label">出入区域： </text>
								<uni-table ref="table" border emptyText="暂无更多数据" style="margin-top: 30upx;">
										<uni-tr></uni-tr>
										<uni-tr v-for="(item, index) in accessArea" :key="index">
											<uni-td align="center" width="80">{{ item }}</uni-td>
										</uni-tr>
								</uni-table>
							</view>
							<view class="form-item">
								<text class="label">办证人数:</text>
								<text class="infoSpan">{{item.userInfoVos.length}}</text>
							</view>
							<view>
								<view v-for="(people,peopleIndex) in peopleList0" :key="peopleIndex" >
									<view style="margin: 20rpx 10rpx;font-size: 30rpx;font-weight: bold;border-left:4px solid #0DB0A7;">人员信息{{peopleIndex+1}}</view>
									<view class="form-item">
										<text class="label">人员姓名:</text>
										<text class="infoSpan">{{people.personnel}}</text>
									</view>
									
									<view class="info-item" v-if="people.idPhoto">
										<text class="label">登记照片： </text>
										<br/>
										<image class="info-item" v-for="(item, index) in people.idPhoto.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
									</view>
									
								</view>
							</view>
					</view>
				</view> 
				<view class="info-item" v-if="itemd.cardType=='施工出入证'">
					<view>
							<view class="form-item">
								<text class="label">项目归口管理部门:</text>
								<text class="infoSpan">{{item.xmgkOrgName}}</text>
							</view>
							<view class="form-item">
								<text class="label">经办人员:</text>
								<text class="infoSpan">{{item.jbUserName}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系电话:</text>
								<text class="infoSpan">{{item.jbUserPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">工作内容:</text>
								<text class="infoSpan">{{item.workContent}}</text>
							</view>
							<view class="form-item">
								<text class="label">工作票编号:</text>
								<text class="infoSpan">{{item.ticketNo}}</text>
							</view>
							<view class="info-item">
								<text class="label">作业地点： </text>
								<uni-table ref="table" border emptyText="暂无更多数据" style="margin-top: 30upx;">
										<uni-tr></uni-tr>
										<uni-tr v-for="(item, index) in accessArea" :key="index">
											<uni-td align="center" width="80">{{ item }}</uni-td>
										</uni-tr>
								</uni-table>
							</view>
							<view class="form-item">
								<text class="label">作业单位:</text>
								<text class="infoSpan">{{item.proUnit}}</text>
							</view>
							<view class="form-item">
								<text class="label">工作负责人:</text>
								<text class="infoSpan">{{item.proManager}}</text>
							</view>
							<view class="form-item">
								<text class="label">联系方式:</text>
								<text class="infoSpan">{{item.proManagerPhone}}</text>
							</view>
							<view class="form-item">
								<text class="label">合同有效期:</text>
								<text class="infoSpan">{{item.contractStartTime}}</text>~<text class="infoSpan">{{item.contractEndTime}}</text>
							</view>
							<view class="form-item">
								<text class="label">车牌号:</text>
								<text class="infoSpan">{{item.carNum}}</text>
							</view>
							<view>
								<view v-for="(people,peopleIndex) in peopleList0" :key="peopleIndex" >
									<view style="margin: 20rpx 10rpx;font-size: 30rpx;font-weight: bold;border-left:4px solid #0DB0A7;">人员信息{{peopleIndex+1}}</view>
									<view class="form-item">
										<text class="label">人员姓名:</text>
										<text class="infoSpan">{{people.personnel}}</text>
									</view>
									<view class="form-item">
										<text class="label">身份证号:</text>
										<text class="infoSpan">{{people.idNumber}}</text>
									</view>
									<view class="info-item" v-if="people.idPhoto">
										<text class="label">登记照片： </text>
										<br/>
										<image class="info-item" v-for="(item, index) in people.idPhoto.split(',')" :key="index" :src="item" :width="100" style="margin-right: 5px;"></image>
									</view>
									
								</view>
							</view>
					</view>
				</view> 
				
				<view class="info-item">
					<text class="label">申请人： </text>
					<text class="infoSpan">{{userInfo.userName}}</text>
				</view>
				<view class="info-item">
					<text class="label">申请时间： </text>	
					<text class="infoSpan">{{itemd.applyTime}}</text>
				</view>
				<!-- <view class="info-item" v-if="item.TYPE==2">
					<text class="label">申请事由： </text>	
					<text class="infoSpan">{{item.MATTER}}</text>
				</view> -->
			</view> 
		</view>
		<view >
			<view class="details">
				<YSteps :lineNum='lineNum' color='#fff' backgroundColor='#4db4ea' :infoList='process'></YSteps>
			</view>
		</view>
		<view v-if="itemd.examineBatch!=1">
			<view class="details card-status" v-if="itemd.examineState==0">
				<text class="card-text" style="color: #FFD707;">制作中</text>
			</view>
			<view class="details card-status" v-if="item.examineState==2" style="display: flex;align-items: center;">
				<view class="card-text" style="color: #00DA6A;">待领取</view>
				<view class="card-btn" @click="haveCard">领取</view>
			</view>
			<view class="details card-status" v-if="item.examineState==3">
				<text class="card-text" style="color: #00DA6A;">已领取</text>
			</view>
		</view>
		
		
		<view  class="occupied" style="height: 180upx;"></view>
		
		
		</view>
	</view>
</template>

<script>
	import {
		getCard,updateProperty,updateCardStatusById,getDetailInfo
	} from '@/common/api.js';
	import {
		callbackRequest,
		getStorage,
		alertTip,
		formatDate,
		sureAlterTip,
		vbPicture,
		formatImgUrl
	} from '@/common/util.js';
	import YSteps from '@/components/Y-Steps/Y-Steps.vue';
	import UniPopup from "@/components/uni-popup/uni-popup.vue";
	export default {
		components: {
			UniPopup,
			YSteps
		},
		data() {
			return {
				vbPicture:vbPicture,
				formatImgUrl:formatImgUrl,
				userInfo:getStorage('userInfo'),
				userId:getStorage('userInfo').userId,
				formatDate:formatDate,
				item: {DEMAND:'',FEEDBACK:'',userInfoVos:[]},
				itemd:{},
				id:0,
				feedback:'',
				submitFlag:true,
				process: [],
				lineNum:0,
				photo: '',
				photos: [],
				idPhoto: '',
				idPhotos: [],
				documentPhoto: '',
				documentPhotos: [],
				accessArea:[],
				peopleList0:[]
			}
		},
		onLoad(option) {
			this.id = option.id||0;
			this.itemd = JSON.parse(option.item);
			console.log("itemd:",this.itemd)
			this.getCard();
			
		},
		methods: {
			getCard(){
				let params =  {
						method: getDetailInfo,
						data: {
							userId: this.userInfo.id,
							phone: this.userInfo.telnumber,
							dataId:this.itemd.dataId,
							cardType:this.itemd.cardType
						}
					};
				callbackRequest(params).then(res => {
					res= res.data;
					console.log("详情",res)
					if (res.returnCode == 1) {
						let _this = this;
						_this.item = res.returnData;
						this.peopleList0=_this.item.userInfoVos;
						if(_this.item.photo){
							_this.photos = _this.item.photo.split(',');
						}
						if(_this.item.idPhoto&&_this.item.idPhoto!='null'){
							_this.idPhotos = _this.item.idPhoto.split(',');
						}
						if(_this.item.documentation){
							_this.documentPhotos = _this.item.documentation.split(',');
						}
						console.log("this.item.cardType",this.itemd)
						if(this.itemd.cardType=='职工卡'||this.itemd.cardType=='第三方人员'){
							if(_this.item.accessArea){
								_this.accessArea = JSON.parse(_this.item.accessArea)
							}else{
								_this.accessArea = []
							}
							
						}else{
							if(_this.item.accessArea){
								_this.accessArea = _this.item.accessArea.split(',')
							}else{
								_this.accessArea = []
							}
						}
						if(_this.examineBatch == this.itemd.examineBatch){
							_this.examineButton = false;
						}
						// let details = res.returnData.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.userInfo.userName+' 发起申请',
								time: formatDate( _this.itemd.applyTime,'dateTime')
							}
							_this.process.push(pObj0);
						}
						// if(details.length>0){
						// 	for(let i=0;i<details.length;i++){
						// 		let pObj = {
						// 			date: details[i].BATCH_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);
					}
				});
			},
			haveCard(){
				
				let params =  {
						method: updateCardStatusById,
						data: {
							userId:this.userId,
							id:this.id,
							cardStatus:3
						}
					};
				callbackRequest(params).then(res => {
					res = res.data;
					if (res.returnCode == 1) {
						alertTip(res.returnMsg);
						this.getCard();
						// this.item = res.returnData[0];
					} else {
						alertTip(res.returnMsg);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/css/common.scss';

	.details{
		// height: 550upx;
		background: white;
		margin: 20upx;
		border-radius: 15upx;
		padding-bottom:15rpx;
		position: relative;
		font-size: 26upx;
		.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;
			}
		}
		.form-box {
			background: #fff;
			.form-item {
				overflow: hidden;
				border-bottom: 1px solid #eee;
				padding: 30upx 20upx;
				.label {
					float: left;
					width: 180upx;
					font-size: 28upx;
					color: #333;
					font-weight: bold;
					line-height: 50upx;
				}
				.ipt-box {
					margin-left: 160upx;
					input {
						width: 90%;
						height: 50upx;
						line-height: 50upx;
						font-size: 26upx;
						color: #666;
					}
				}
				.select {
					.arrow {
						float: right;
						width: 16upx;
						height: 29upx;
						margin-top: 10upx;
					}
					.picker {
						height: 50upx;
						line-height: 50upx;
						font-size: 26upx;
						color: #666;
						margin-left: 10upx;
					}
				}
			}
		}
		.detail_msg {
			margin-left: 20upx;
			border-radius: 10upx;
			.info-item{
				border-bottom:1px solid #f8f8f8;
				padding:20upx 10upx;
				line-height: 50upx;
				.label{
					float: left;
					width: 240upx;
					font-size: 28upx;
					color: #333;
					font-weight: bold;
					line-height: 50upx;
				}
			}
			.status {
				.infoSpan{
					color: #00c277;
				}
				.infoSpan2{
					color: red;
				}
			}
			.img-box {
				// background: #fff;
				image{
					width: 200upx;
					height: 200upx;
					margin:20upx 20upx 0 0;
				}
			}
		}
	}

	.card-status{
		height: 100upx;line-height: 100upx;padding: 0 40upx;
		
		.card-text{
			font-size: 30upx;font-weight: bold;
		}
		.card-btn{
			margin-left: 60upx;height: 50upx;width: 120upx;text-align: center;line-height: 50upx;background: #00DA6A;color: #fff;border-radius: 10upx;
		}
	}
		
	
	
</style>
