<template>
	<view>
		<u-navbar
		 :title="title" 
		 title-color="#fff" 
		 :is-back="true"
		 :custom-back="customBack" 
		 :border-bottom="false" 
		 back-icon-color="#CCE8FF" 
		 :background="{background: 'linear-gradient(99deg, #7A4398 0%, #5A5DB9 100%)' }">
			 <view class="navbar-right" slot="right" @click="handleReport">
				<text>登记</text>
			</view>
		 </u-navbar>
		<mescroll-uni ref="mescrollRef01" @init="mescrollInit" :top="config.platform=='h5'?100:180" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
			<view class="report-list">
				<view class="report-list-item" :class="{'arrearage':item.vehicleNoStatus}" v-for="item in dataList" :key="item.id"
				@click="goDetails(item.id)">
					<view class="u-flex u-row-between u-m-b-20">
						<text>路段/停车场{{item.roadName}}</text>
						<text class="u-tips-color">{{$u.timeFormat(item.createTime, 'mm月dd日hh:MM')}}</text>
					</view>
					<view class="u-flex u-row-between u-m-b-20">
						<text class="u-line-1">处理员：{{item.processBy}}</text>
						<u-icon name="arrow-right" color="#ddd" size="28"></u-icon>
					</view>
					<view class="u-flex u-row-between">
						<text class="u-line-1">处理过程：{{item.processDes}}</text>
					</view>
				</view>
			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default{
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		components:{
			
		},
		data(){
			return{
				title:"应急处置登记",
				downOption:{
					auto:false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption:{
					page: {
						size: 10 // 每页数据的数量
					},
					auto:true,
					// use:false,
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: '~ 暂无数据 ~', // 提示
						// btnText: '去看看'
					}
				},
				dataList:[],
			}
		},
		onLoad(page){
			console.log('page',page);
		},
		onShow(){
		},
		methods:{
			customBack(){
				this.$u.route({
				  url: 'pages/index/index',
				  type:'switchTab'
				})
			},
			openPage(path,id) {
			  this.$u.route({
			    url: path,
				params:{
					id:id
				}
			  })
			},
			goDetails(id){
				this.$u.route({
				  url: 'pages/report/emergencyReport/details',
					params:{
						id:id
					}
				})
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				// console.log('page',page);
				let params ={
					pageNum:page.num,
					pageSize:page.size
				};
				this.$u.api.emergencyReportList(params).then(curPageData=>{
					// console.log('word',word);
					 console.log('curPageData',curPageData);
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					this.mescroll.endSuccess(curPageData.data.total);
					this.mescroll.endBySize(curPageData.data.rows.length, curPageData.data.total);
					//设置列表数据
					if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList=this.dataList.concat(curPageData.data.rows); //追加新数据
					console.log('this.dataList',this.dataList);
				}).catch(()=>{
					console.log('catch');
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			//点击空布局按钮的回调
			emptyClick(){
				uni.showToast({
					title:'点击了按钮,具体逻辑自行实现'
				})
			},
			refresh(){
				this.mescroll.resetUpScroll( );
			},
			handleReport(){
				// console.log('handleReport');
				this.$u.route({
				  url: 'pages/report/emergencyReport/report',
				  // type:'redirect',
				})
			}
		}
	}
</script>
<style>
	page{background-color: #F3F3F3;}
</style>
<style lang="scss" scoped>
@import  '../report.scss'
</style>
