<template>
	<view>
		<roll-load :total="queryConditions.total" 
			:size="queryConditions.limit" 
			@lower="lower" @upper="upper" key="checkRecord-roll-load"
			:topBt='top' ref="roll-load" styles="height:100vh;">
			<template v-slot:cont>
				<block></block>
				<uni-list>
					<!-- {{item.checkRecordId}} -->
					<uni-list-item class="list-item" v-for="(item,index) in dataList" :key="index"
						:title="item.measureContent" :note="item.checkTime" @click="inspection(item)" clickable>
						<!-- 自定义 body -->
						<view slot="body" class="uni-padding-wrap uni-common-mt">
							<text class="slot-box slot-text">{{item.riskPointTitle}}</text>
							<view>
								检查人：{{item.accountName}}
							</view>
							<view>
								检查时间：{{item.checkTime}}
							</view>
							<view>
								描述：{{item.checkDesc}}
							</view>
						</view>
						<view slot="footer" class="unilist_footer_tag">
							<template>
								<uni-tag v-if="item.checkResult===1" text="通过" type="success" size="small" inverted />
								<uni-tag v-if="item.checkResult===2" text="不通过" type="warning" size="small" inverted />
								<uni-tag v-if="item.checkResult===3" text="有隐患" type="error" size="small" inverted />
								<uni-tag v-if="item.checkResult===0" text="未检查" type="default" size="small" inverted />
							</template>
						</view>
					</uni-list-item>
				</uni-list>
			</template>
		</roll-load>	
	</view>
</template>
<script>
	import RollLoad from '@/components/RollLoad/index.vue';
	import { getCheckRecordByPage } from '../../api/checkRecord.js'
	import { deepClone } from '@/libs'
	export default {
		components: {
			RollLoad
		},
		data() {
			return {
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				top: {
					show: true,
					style: "top:95%"
				},
				pageNumber: 1,
				items: [],
				dataList: [],
				queryConditions: {
					page: 1,
					limit: 10,
					total: 0,
					keywords: ''
				}
			}
		},
		onShow() {
			this.getCheckRecord();
		},
		methods: {
			upper: function(e) {
				console.log('upper')
				console.log(e)
			},
			lower: function(e) {
				console.log('lower')
				console.log(e)
				if (e.status) {
					this.queryConditions.page = e.pageNumber
					this.getCheckRecord(this.queryConditions);
				}
			},
			scroll: function(e) {
				this.old.scrollTop = e.detail.scrollTop
			},
			goTop: function(e) {
				this.scrollTop = this.old.scrollTop
				this.$nextTick(() => {
					this.scrollTop = 0
				});
				uni.showToast({
					icon: "none",
					title: "已经到顶了！"
				})
			},
			getCheckRecord() {
				getCheckRecordByPage(this.queryConditions).then((res) => {
					let items =[...this.dataList];
					let dataList=items.concat(res.data);
					this.dataList=dataList;
					this.$set(this.queryConditions, 'total', res.total)	
				})
			},
			inspection(item){
				uni.setStorageSync('inspectionInfo',item);
				uni.navigateTo({
					url:'/views/checkRecord/inspectionDetail/inspectionDetail'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.slot-image {
		height: 35upx;
	}
	.list-item{
		position: relative;
		.unilist_footer_tag {
			position: absolute;
			right: 20upx;
			top: 50%;
			transform: translateY(-50%);
		}	
	}
</style>
