<template>
<div>

	<common @asynCallBack="asynCallBack"></common>
	<top-header :pageTitle="pageTitle"></top-header>

	<div class="mui-content vongi-hdsq">
			<div id="slider" class="mui-slider mui-fullscreen ">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a @click="reloadList(0)" :class="'mui-control-item '+(listForm.status==0?'mui-active':'')">
							<span class="fyy-badge">待处理<span class="mui-badge" v-if="firstRecordsTotal" v-text="firstRecordsTotal"></span></span>
						</a>
						<a @click="reloadList(1)" :class="'mui-control-item '+(listForm.status==1?'mui-active':'')">
							已处理
						</a>
					</div>
				</div>
				<NullList :remark="'暂无车位申请出入记录'" v-if="!recordList.length"></NullList>

				<div class="mui-slider-group">


					<div  class="mui-slider-item mui-control-content">


						<div class="mui-scroll-wrapper">
							<div class="mui-scroll">
								<ul class="mui-table-view" >
									<li class="mui-table-view-cell" v-for="(item,index) in recordList">
										<router-link :to="{name:'MasterPropertyCarInfo',query:{id:item.id}}"  >

											<div class="mui-media-body flew-sp">
												<div class="mui-col-xs-9">
													申请车位：{{item.parkingName}}<br>
													租用时间：{{item.rentTime}}
												</div>
												<div class="mui-col-xs-3"><button type="button" class="mui-btn  mui-btn-outlined" :class="statusClass[item.status]">{{item.statusN}}</button></div>
											</div>
											<p class="flew-items flew-sp">
												申请人:{{item.applicationName}}
												<span class='mui-ellipsis'>{{item.applicationTime}} </span>
											</p>
										</router-link>
									</li>
								</ul>
							</div>
						</div>
					</div>

				</div>
			</div>
		</div>
	<loading :visible="isLoading"></loading>

</div>
</template>


<script>
	import * as API from '@/apis/Master/Property/car'
	import Common from '$project/components/Common.vue'
	import NullList from '$project/components/NullList.vue'

	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import isReachBottom from '$project/utils/isReachBottom'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterAttendanceVerifyList',
		components: {
			Common,
			Loading,
			TopHeader,NullList
		},
		data() {
			return {
				pageTitle: '车位申请记录',

				isLoading: false,

				listForm: {
					pageIndex: 1,
					pageSize: 20,
					totalPage: 1,
					status: 0,
				},
				recordList: [],
				selectIdList: [],
				allSelect: [],
				subForm: {
					ids: '',
					content: '',
					status: ''
				},
				//审批内容弹窗显示
				openFromVisible: false,
				firstRecordsTotal: 0,
				statusClass:['mui-btn-primary ','mui-btn-success  ','','mui-btn-greye  ']
			}
		},
		created() {

		},
		methods: {
			//获取列表
			getList() {
				this.isLoading = true;
				API.ParkingApplicationList(this.listForm).then(response => {
					if (response) {
						if (this.listForm.pageIndex == 1) {
							this.recordList = response.list;
							this.listForm.pageIndex = response.pageNumber;
							this.listForm.totalPage = response.totalPage;
						} else {
							this.recordList = [
								...this.recordList,
								...response.list
							];
						}
					}

					if (this.listForm.status == 0) {
						this.firstRecordsTotal = response.num;
					}

					this.listForm.pageIndex++;
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//下拉事件
			handleScrool() {
				if (isReachBottom()) {
					console.log('到达底部')
					if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
						this.getList();
					} else {
						return;
					}
				}
			},
			//切换
			reloadList(status) {
				this.listForm.status = status;
				this.listForm.pageIndex = 1;
				this.getList();
			},

			asynCallBack() {

			},
		},
		mounted() {
			this.getList();
			//监控下拉加载事件
			var _this = this;
			window.addEventListener('scroll', _this.handleScrool);
		},
		destroyed() {
			//销毁监听事件
			var _this = this;
			window.removeEventListener('scroll', _this.handleScrool);
		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>

