<template>
	<view class="allpage">
		
		<view class="listtop pfixed">
			<tab-searchone @getSearch='getSearch'></tab-searchone>
			<view class="flexc allpage_zd">
				<view class="allpage_zdl">本年度共计<text>{{total||0}}</text>个</view>
				<time-year @bindDateChange="bindDateChange" textAlign='right' :timedate="time"></time-year>
			</view>
		</view>
		
		<view class="alllist">
			<!--  :start="startDate" :end="endDate" -->
			
			<!-- l列表 -->
			<project-list :datalist="list" :wtdt="wtdt" type='leader' @getDetail='goDetail'></project-list>
		</view>
	</view>
</template>

<script>
	import projectList from "@/components/projectlist/list.vue"
	import tabList from "@/components/toptab/tab.vue"
	import tabSearchone from "@/components/toptab/searchone.vue"
	import timeYear from "@/components/timedata/timeyear.vue"
	import { getldpslistFn} from '@/api/work/clue.js'
	export default{
		data(){
			return{
				upimg:require("@/static/images/index/up.png"),
				tabidx:0,
				year:'',
				list:[],
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				wtdt:'',
				beginTime:'',
				endTime:'',
				name:'',
				total:0,
				deptId:this.$store.state.user.deptId,
				time:""
			}
		},
		components:{
			projectList,tabList,tabSearchone,timeYear
		},
		onUnload(){
			uni.$off('refreshdatalist')
		},
		onLoad(e) {
			uni.$on('refreshdatalist',(e) => {
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn();
			})
			var y='';
			if(e.time){
				y=e.time
			}else{
				let date = new Date();
				y = date.getFullYear();
			}
			this.beginTime=y+'0101';
			this.endTime=y+'1231';
			this.time=y;
			this.tabidx=Number(e.idx);
			this.getDataFn()
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			bindDateChange(e){
				this.year=e;
				this.beginTime=e+'0101';
				this.endTime=e+'1231';
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn()
			},
			goCheck(data){
				this.tabidx=data;
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn()
			},
			goDetail(e){
				this.$tab.navigateTo('/pages/work/cluedetails?id='+e.id)
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
					xmxsmc:this.name,
					deptId:this.deptId
				}
				params['params[beginTime]']=this.beginTime
				params['params[endTime]']=this.endTime
				getldpslistFn(params).then(res=>{
					if(res.code==200){
						this.total=res.total;
						if (res.rows.length < this.pageSize) {
							this.reachflag = false
							this.wtdt = '到底了~';
						} else {
							var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
							if (num < res.total) {
								this.reachflag = true
								this.wtdt = '上拉加载更多'
							} else {
								this.reachflag = false
								this.wtdt = '到底了~';
							}
						}
						if (this.pageNum == 1) {
							this.list = res.rows;
						} else {
							this.list = this.list.concat(res.rows)
						}
					}else{
						this.$toast(res.msg)
					}
				})
			},
			getSearch(e){
				this.name=e;
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.allpage{min-height: 100vh;background: #ffffff;padding-top:190rpx;box-sizing: border-box;}
.listtopa{border: 6rpx solid #FD5001;border-radius: 36rpx;height:72rpx;box-sizing: border-box;padding:0 140rpx 0 32rpx ;position: relative;
 input{}
 image{width: 30rpx;height: 30rpx;margin-right: 24rpx;}
 .btn{background: #FA5F03;border-radius: 36rpx;width: 140rpx;position: absolute;right: -2rpx;top: -2rpx;bottom:-2rpx;}
 }
 .listtopb{
	 .tit{flex: 1;height: 130rpx;display: flex;flex-direction: column;justify-content: center;position: relative;
	 view{text-align: center;}
	 .tits{color: #666666;}
	 .txt{color: #aaaaaa;}
	 &.act{
		 &::after{content: '';width: 100rpx;height: 6rpx;background:#FE5706 ;position: absolute;left: 50%;margin-left: -50rpx;bottom: 0;}
		.tits{color: #343434;}
		.txt{color: #FE5706;} 
	 }
	 }
 }

 .alllist{padding-top:10rpx ;}
 
 //统计
 .allpage_zd{background-color:#F2F2F2;padding: 0 28rpx;justify-content: space-between;
	.allpage_zdl{font-size: 30rpx;font-weight: 500;
color: #666666;
	text{font-weight: bold;color: #FE5706;margin: 0 8rpx;}
}
 
 }
 
</style>