<template>
	<view class="fullHeight">
		<levitatedsphere :x="100" :y="80"></levitatedsphere>
		<headers :showBack="true" class="">
			<view class="headerName">
				施工日志
			</view>
		</headers>
		 <!-- :style="{ 'padding-top': (statusBarHeight+52+40) * 1.5 + 'rpx' }" -->
		<view class="listBox">
			<view class="listItem" v-for="item in list" :key="item.id" @click="goAdd(item.id)">
				<view class="title">
					{{item.buildPlace}}
				</view>
				<view class="bottom">
					{{item.taskCondition}}
				</view>
				<view class="bottom">
					<text class="time">{{item.createTime}}</text>
				</view>
				<image src="/static/icon-right.png" class="icon-right"></image>
			</view>
			<view class="placeholderBox" v-show="list.length==0">
				<image src="/static/noData.png" class="noDataImg"></image>
				<view class="text">
					暂无数据
				</view>
			</view>
		</view>
		<view class="loadMoreBox" v-if="isLoadMore">
			<uni-load-more :status="loadStatus" iconType="auto"></uni-load-more>
		</view>
		<image src="/static/addImg.png" class="addImg" @click="goAdd('')"></image>
	</view>
</template>

<script>
	import headers from "@/components/headers/headers.vue"
	export default {
		components:{headers},
		data() {
			return {
				searchForm:{
					buildName: "",
					endTime: "",
					pageNo: 1,
					pageSize: 10,
					projectSn: "",
					startTime:""
				},
				projectDetail:{},
				list:[],
				statusBarHeight:0,
				loadStatus:'more',
				isLoadMore:false
			};
		},
		onShow() {
			this.list=[]
			this.searchForm.pageNo=1
			this.statusBarHeight=uni.getStorageSync('systemInfo').statusBarHeight
			this.projectDetail=JSON.parse(uni.getStorageSync('projectDetail'))
			this.searchForm.projectSn=this.projectDetail.projectSn
			this.loadData()
		},
		onReachBottom() {
			if(!this.isLoadMore){  //此处判断，上锁，防止重复请求
				this.isLoadMore=true
				this.searchForm.pageNo+=1
				this.loadData()
			}
		},
		onPullDownRefresh() {
			this.searchForm.pageNo=1
			this.list=[]
			this.loadData()
		},
		methods:{
			loadData(){
				var that = this
				this.sendRequest({
					url: 'xmgl/projectBuildLog/list',
					data: this.searchForm,
					method: "POST",
					success(res){
						that.list=that.list.concat(res.result.records)
						if(res.result.records.length<that.searchForm.pageSize){  //判断接口返回数据量小于请求数据量，则表示此为最后一页
							  that.isLoadMore=true                                             
							  that.loadStatus='nomore'
						}else{
							  that.isLoadMore=false
							  // that.loadStatus='more'
						}
						uni.stopPullDownRefresh()
						console.log('that.isLoadMore',that.isLoadMore)
					}
				})
			},
			goAdd(id){
				uni.navigateTo({
					url:'./add?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.addImg{
	position: fixed;
	bottom: 30rpx;
	right: 30rpx;
	width: 64rpx;
	height: 64rpx;
}
.listBox{
	margin: 30rpx;
}
.listItem{
	box-shadow: 0px 4px 26rpx 0px rgba(212, 220, 236, 0.53);
	position: relative;
	margin-bottom: 10rpx;
	padding: 30rpx;
	border-radius: 16rpx;
	.title{
		font-size: 30rpx;
		font-weight: bold;
		margin-bottom: 20rpx;
	}
	.bottom{
		color: rgba(55, 45, 102, 0.5);
		font-size: 24rpx;
	}
	.time{
		margin-right: 24rpx;
	}
}
.icon-right{
	position: absolute;
	width: 16rpx;
	height: 28rpx;
	right: 30rpx;
	top: calc(50% - 7px);
}
</style>
