<template>
	<view>
		<view class="box">
			<view class="top">
				<text class="title">出入记录</text>
			</view>
		</view>
		<!-- <u-sticky offset-top="0">
			<u-tabs :list="tabs" @change="change" :current="current" :is-scroll="false"></u-tabs>
		</u-sticky> -->
		<view class="card-box">
			<view class="card" v-for="(recordItem,index) in recordItemList" :key="index">
				<!-- <view class="t">
					<image class="icon" src="../../static/home-icon-01.png"></image>
					<text class="title">{{recordItem.customerName}}</text>
				</view> -->
				<view class="c">
					<view class="item car-num-item">
						<text class="car-num">{{recordItem.carNo}}</text>
					</view>
					<view class="item">
						<text class="p1">联系人:</text>
						<text class="p2">{{recordItem.driverName}}</text>
					</view>
					<view class="item">
						<text class="p1">联系电话:</text>
						<text class="p2">{{recordItem.driverPhone}}</text>
					</view>
					<view class="item" >
						<text class="p1">入场时间:</text>
						<text class="p2">{{recordItem.realInTime}}</text>
					</view>
					<view class="item" >
						<text class="p1">出场时间:</text>
						<text class="p2">{{recordItem.realOutTime}}</text>
					</view>
					<view class="item">
						<text class="p1">状态:</text>
						<text class="p2">
							<text v-if="recordItem.realInTime==null && recordItem.realOutTime==null">未进场</text>
							<text v-if="recordItem.realInTime!=null && recordItem.realOutTime==null">已进场</text>
							<text v-if="recordItem.realInTime!=null && recordItem.realOutTime!=null">已出场</text>
						</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 没有数据时显示noData -->
		<noData v-if="recordItemList.length==0"></noData>
		<u-loadmore style="margin: 30rpx;" :status="status"/>
		<!-- <uni-popup ref="shpopup" type="dialog">
		    <uni-popup-dialog type="success" title="确定审核吗？" :duration="2000" @confirm="shconfirm"></uni-popup-dialog>
		</uni-popup> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current:0,
				pageNo: 1,
				pageSize: 4,
				dataCount: 0,
				status: 'loadmore',
				page: 0,
				tabs: [
					{
						name: '全部',
					},
					{
						name: '未入场',
					},
					{
						name: '已入场',
					},
					{
						name: '已出场',
					}
				],
				recordItemList:[
					{
						carNo:'',
						driverName: '',
						driverPhone:'',
						realInTime:'',
						realOutTime:'',
					},
				],
				//recordList: [],
			}
		},
		methods: {
			getRecordList() {
				this.$api.getInOutRecord({
					current: this.current,
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					dataCount: this.dataCount,
				}).then(resp => {
					this.status = 'loadmore';
					let recordList = resp.data;
					this.dataCount = resp.dataCount;
					this.pageNo = resp.pageNo;
					this.recordItemList = recordList;
					if(this.dataCount < this.pageSize * this.pageNo) this.status = 'nomore';
				})
			},
			//点击上方切换栏，根据点击项重新加载数据
			change(obj) {
				let index=obj.index;
				this.current = index;
				if(index==0){
					//加载全部
					this.getRecordList();
				}
				if(index==1){
					//加载未入场
					this.getRecordList();
				}
				if(index==2){
					//只加载已入场
					this.getRecordList();
				}
				if(index==3){
					//只加载已出场
					this.getRecordList();
				}
			},
			//------------------------------------------
			//上拉加载更多，分页模拟数据
			onReachBottom() {
				this.status = 'loading';
				if(this.dataCount > this.pageSize * this.pageNo){
					this.pageSize = parseInt(this.pageSize) + 3;
					this.getRecordList();
				}else{
					this.status = 'nomore';
				}
			} 
		},
		onShow() {
			this.getRecordList();
		
		},
	}
</script>

<style lang="scss">
	.card-box{
		display: flex;
		width: 100%;
		flex-direction: column;
		.card{
			background-color: #fff;
			border-radius: 20rpx;
			margin: 20rpx 20rpx 0 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			.t{
				width: 100%;
				display: flex;
				align-items: center;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #f5f5f5;
				.icon{
					width: 40rpx;
					height: 40rpx;
				}
				.title{
					font-size: 30rpx;
					font-weight: bold;
					margin-left: 20rpx;
				}
			}
			.c{
				padding:15rpx 0 0 0;
				display: flex;
				flex-wrap: wrap;
				//border-bottom: 1rpx solid #f5f5f5;
				.item{
					width: 50%;
					padding: 20rpx 0;
					display: flex;
					.car-num{
						background-color: #edf6ff;
						color: #0080ff;
						font-size: 44rpx;
						padding: 15rpx 0;
						text-align: center;
						width: 100%;
						border-radius: 10rpx;
						font-weight: bold;
						letter-spacing: 20rpx;
					}
					.p1{
						font-size: 28rpx;
						color: #999;
						flex: 5;
					}
					.p2{
						font-size: 28rpx;
						color: #191919;
						font-weight: bold;
						margin-left: 20rpx;
						flex: 7;
					}
				}
				.car-num-item{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
			.b{
				display: flex;
				width: 100%;
				align-items: center;
				justify-content: space-between;
				.btn{
					height: 70rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					//width: calc(50% - 15rpx);
					width: 100%;
					margin: 30rpx 0 0 0;
					border-radius: 10rpx;
					border-width: 1rpx;
					box-sizing: border-box;
				}
				.b1{
					background-color: #0080ff;
					color: #fff;
				}
				.b2{
					background-color: #f7f7f7;
					color: #191919;
				}
				.b3{
					background-color: #fff;
					color: #0080ff;
					border: 1rpx solid #0080ff;
				}
			}
		}
	}
	.t-btn{
		width: 400rpx;
		margin: 0 auto 80rpx auto;
		height: 88rpx;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 10rpx;
		color: #191919;
		font-size: 28rpx;
		background-color: #fff;
		border: 1px solid #eee;
	}
	@import '@/common/common.scss'
</style>
