<template>
	<view class="projectList">
		<headers class="fixedheader" :themeType="true" :showBack="true">
			<view class="headerName">
				查看明细
			</view>
		</headers>
		<view class="details">
			<view class="details-item">
				<span>访客姓名</span>
				<span>{{result.visitName}}</span>
			</view>
			<view class="details-item">
				<span>访客身份证号</span>
				<span>{{result.idCard}}</span>
			</view>
			<view class="details-item">
				<span>访问事由</span>
				<span>{{result.reason}}</span>
			</view>
			<view class="details-item">
				<span>访问区域</span>
				<span>{{result.local}}</span>
			</view>
			<view class="details-item">
				<span>车牌号</span>
				<span>{{result.carNumber}}</span>
			</view>
			<view class="details-item">
				<span>预约人姓名</span>
				<span>{{result.appointmentName}}</span>
			</view>
			<view class="details-item">
				<span>预约结果</span>
				<span>{{ result.isSuccess === 0 ? '预约成功' : '预约失败'}}</span>
			</view>
			<view class="details-item">
				<span>预约有效开始时间</span>
				<span>{{result.beginTime}}</span>
			</view>
			<view class="details-item">
				<span>预约有效结束时间</span>
				<span>{{result.endTime}}</span>
			</view>
			<view class="details-item">
				<span>来访人单位</span>
				<span>{{result.visitUnit}}</span>
			</view>
			<view class="details-item">
				<span>接送人姓名</span>
				<span>{{result.takeName}}</span>
			</view>
			<view class="details-item">
				<span>接送人手机号</span>
				<span>{{result.takePhone}}</span>
			</view>
			<view class="details-item">
				<span>接送人单位</span>
				<span>{{result.takeUnit}}</span>
			</view>
			<view class="details-item">
				<span>接送人职务</span>
				<span>{{result.takeJob}}</span>
			</view>
			<view class="details-state" style="height: 100px;">
				<span>当前状态</span>
				<span>{{ result.isEnable === 0 ? '预约有效' : '预约已失效'}}</span>
			</view>
		</view>
		<view class="delete" @click="deleteEvent" v-if="btnAuth">删除</view>
		<levitatedsphere :x="100" :y="80"></levitatedsphere>
	</view>
</template>

<script>
	import levitatedsphere from "@/components/levitatedsphere/levitatedsphere.vue"
	import headers from '../../../components/headers/headers.vue'

	export default {
		data() {
			return {
				id: '',
				result: {},
				btnAuth: true
			}
		},
		onShow() {
			this.getDetails()
		},
		onLoad(vai) {
			this.btnAuth = this.checkBtnPermission({key: 'fkyyjl_delete', menuPath: '/project/labor/visitRecord'})
			this.id = vai.itemS
		},
		onReachBottom() {

		},
		onPullDownRefresh() {

		},
		methods: {
			getDetails() {
				let data = {
					id: this.id
				}
				let _this = this
				this.sendRequest({
					url: 'xmgl/xzVisitorManageRecord/queryById',
					method: 'post',
					data: data,
					success: res => {
						console.log(res);
						this.result = res.result
					}
				})
			},
			deleteEvent(){
				let data = {
					id: this.id
				}
				let _this = this
				this.sendRequest({
					url: 'xmgl/xzVisitorManageRecord/delete',
					method: 'post',
					data: data,
					success: res => {
						console.log(res);
						// this.result = res.result
						if(res.code=== 200){
							uni.showToast({
								title: '删除成功',
								duration: 2000,
								icon: 'none',
								mask: true,
							})
							setTimeout(() => {
								uni.navigateBack({
									url:'visitorsManage?el=1'
								})
							}, 1000)
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.projectList {
		min-height: 100%;
		background: #f4f5fd;
		position: relative;

		.details {
			margin: 10px;
			background-color: #fff;
			height: auto;
			border-radius: 4px;

			.details-item {
				height: 50px;
				border-bottom: 1px solid #e4e6ef;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 15px;
				span:nth-child(2){
					width: 65%;
					text-align: right;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}
		}

		.details-state {
			display: flex;
			justify-content: space-between;
			padding: 0 15px;
			margin-top: 15px;
		}

		.delete {
			position: absolute;
			bottom: 0px;
			left: 0;
			height: 50px;
			background-color: #eb3b43;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			color: #fff;
			font-size: 16px;
		}
	}
</style>