<template>
	<view class="allpage">
		<view class="listtop pfixed">
			<tab-searchone @getSearch='getSearch' :name="name"></tab-searchone>
			<tab-list :tablist='tablist' :tabidx="tabidx" @getCheck="goCheck" :height='90'></tab-list>
			<time-year @bindDateChange="bindDateChange" ></time-year>
		</view>
		<view class="zhanline"></view>
		<view class="alllist">
			<!-- l列表 -->
			<zdproject-list :datalist="list" :wtdt='wtdt' @getDetail='goDetail' @getjdDetail="getjdDetail"></zdproject-list>
		</view>
		<!-- <view style="height: 100rpx;"></view>
		<view class="zdcount_btn" @click="getAddReport">新增申报</view> -->
	</view>
</template>

<script>
	import zdprojectList from "@/components/projectlist/zdlist.vue"
	import tabList from "@/components/toptab/tab.vue"
	import tabSearchone from "@/components/toptab/searchone.vue"
	import timeYear from "@/components/timedata/timeyear.vue"
	import {getxmsbListFn} from '@/api/zdwork/clue.js'
	export default{
		data(){
			return{
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				itemslist:[],
				wtdt:'',
				tabidx:0,
				date:'',
				list:[],
				// ,limt:'projectV2:sbbzb:list'
				tablist:[{tit:'全部',val:0},{tit:'未达到',val:1,limt:'fgw:xmsb:list'},{tit:'未填写',val:2},{tit:'其他',val:3}],
				year:'',
				beginTime:'',
				endTime:'',
				name:'',
				census:'',
				deptId:this.$store.state.user.deptId,
				wtType:''
			}
		},
		components:{
			zdprojectList,tabList,tabSearchone,timeYear
		},
		onUnload(){
			uni.$off('refreshdatalistzd')
		},
		onLoad(e) {
			this.getDataFn();
			uni.$on('refreshdatalistzd',(e) => {
				// this.$emit('refreshdatacensuszd')
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn();
			})
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			getAddReport(){
				this.$tab.navigateTo('/pages/zdpages/work/addreport')
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
					xmmc:this.name,
					isWt:'Y',
				}
				params['params[beginTime]']=this.beginTime;
				params['params[endTime]']=this.endTime;
				if(this.tabidx==0){//全部
				
				}else if(this.tabidx==1){//未达到 
					params.wtType='1'
					
				}else if(this.tabidx==2){//未填写 
					params.wtType='2'
				}else if(this.tabidx==3){//其他
					params.wtType='3'
				}
				getxmsbListFn(params).then(res=>{
					if(res.code==200){
						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();
			},
			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/zdpages/work/zdcluedetails?id='+e.id)
			},
			getjdDetail(e){
				this.$tab.navigateTo('/pages/zdpages/work/zdcluedetails?id='+e.id+'&tabidx='+e.tabidx)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.allpage{min-height: 100vh;background: #ffffff;padding-top:280rpx;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;} 
	 }
	 }
 }

.zdcount_btn{position: fixed;left: 0;right: 0;bottom: 0;z-index: 4;width: 100%;height: 100rpx;font-size: 32rpx;color: #ffffff;font-weight: 500;
background: #FE5706;display: flex;align-items: center;justify-content: center;
// image{width: 34rpx;height: 34rpx;margin-right: 16rpx;}

}
</style>