<template>
	<view class="projectList">
		<view class="" style="position: fixed; top: 0; left: 0; width: 100%; z-index: 10;background-color: #f4f5fd;">
			<headers class="fixedheader" :themeType="true" :showBack="true">
				<view class="headerName">
					材料出场管理
				</view>
			</headers>
			<input class="uni-input" name="searchName" v-model="search" placeholder="请搜索" @input="handleInput" />
		</view>
		<view v-if="dataList.length > 0" style="padding-top: 90px;" >
			<view class="ukashList" v-for="item in dataList" :key="item.id" @click="jobMaterials(item.id)">
				<view class="ukashList-what">
					<span style="font-size: 14px;font-weight: 700;">{{item.name}}</span>
					<span class="ukashList-look">查看明细</span>
				</view>
				<view class="ukashList-time">企业: {{item.enterpriseName}}</view>
				<view class="ukashList-time">车牌号: {{item.carNumber}}</view>
				<view class="ukashList-time">出场有效时间: {{item.entryBeginTime}}至{{item.entryEndTime}}</view>
			</view>
		</view>
		<view class="no-data" v-else>
			<image class="img" src="/static/noData.png"></image>
			<text class="txt">暂无数据</text>
		</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 {
				search: '',
				pageNo: 1,
				pageSize: 10,
				isLoadMore: false,
				dataList: [],
				isFinished: false
			}
		},
		onLoad() {
			this.queryList()
		},
		onReachBottom() {
			console.log(99999);
			// this.pageNo += 1
			// this.queryList()
			if (!this.isLoadMore) {
				this.pageNo += 1;
				this.queryList();
			}
		},
		onPullDownRefresh() {
			console.log(222);
			this.pageNo = 1
			this.dataList = []
			this.queryList()
			this.isFinished = false
		},
		methods: {
			queryList() {
				let data = {
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					type: 2
				}
				let _this = this
				this.sendRequest({
					url: 'xmgl/xzMaterial/page',
					method: 'post',
					data: data,
					success: res => {
						console.log(res);
						// this.dataList = this.dataList.concat(res.result.records)
						
						this.dataList = [...this.dataList, ...res.result.records]
						// console.log(this.dataList , res.result.total);
						// this.dataList = res.result.records
						if (res.result.records.length < this.pageSize) {
							//判断接口返回数据量小于请求数据量，则表示此为最后一页
							this.isLoadMore = true
						} else {
							this.isLoadMore = false
							// that.loadStatus='more'
						}
						uni.stopPullDownRefresh()
						// console.log(res.result)
					}
				})
			},
			jobMaterials(id) {
				uni.navigateTo({
					url: './materials?itemS=' + id
				})
			},
			handleInput(e) {
				this.dataList = []
				let data = {
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					type: 2
				}
				if(e.detail.value){
					data.name = e.detail.value;
				}
				let _this = this
				this.sendRequest({
					url: 'xmgl/xzMaterial/page',
					method: 'post',
					data: data,
					success: res => {
						console.log(res);
						// this.dataList = this.dataList.concat(res.result.records)
						
						this.dataList = res.result.records
						// console.log(this.dataList , res.result.total);
						// this.dataList = res.result.records
						if (res.result.records.length < this.pageSize) {
							//判断接口返回数据量小于请求数据量，则表示此为最后一页
							this.isLoadMore = true
						} else {
							this.isLoadMore = false
							// that.loadStatus='more'
						}
						uni.stopPullDownRefresh()
						// console.log(res.result)
					}
				})
			}
		}
	}
</script>

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

		.uni-input {
			border-radius: 10px;
			margin: 10px 10px;
			background-color: #e6e7ef;
			height: 35px;
			line-height: 30px;
			padding: 0 20px;
			font-size: 14px;
		}

		.ukashList {
			min-height: 90px;
			background-color: #fff;
			margin: 10px 10px;
			border-radius: 15px;
				padding: 20rpx 0rpx;
			.ukashList-what {
				display: flex;
				justify-content: space-between;
				margin: 0 20px;

				.ukashList-look {
					background-color: #5081f7;
					border-radius: 10px;
					padding: 0 4px;
					font-size: 12px;
					text-align: center;
					color: #fff;
				}
			}

			.ukashList-time {
				margin-top: 10px;
				margin-left: 20px;
				font-size: 12px;
				color: #b9bbc9;
			}
		}

		.no-data {
			text-align: center;
			margin-top: 50%;

			.img {
				display: block;
				height: 200rpx;
				width: 200rpx;
				margin: 0 auto;
				margin-top: 60rpx;
				margin-bottom: 60rpx;
			}

			.txt {
				color: #C0C4CC;
			}
		}
	}
</style>