<template>
	<view class="allpage">
		<!-- <view class="listtop pfixed">
			<tab-searchone @getSearch='getSearch' :name="name"></tab-searchone>
		</view> -->
		<view class="zhanline"></view>
		<view class="alllist">
			<!-- <time-year @bindDateChange="bindDateChange" ></time-year> -->
			<!-- l列表 -->
			<project-list type='tslist' :datalist="list" :wtdt='wtdt' @getXmjzFn="getXmjzFn"></project-list>
			
		</view>
		<!-- 弹窗 -->
		<pop-up :type="poptype" @getClose='getClose'  @getXmSubmitFn='getXmSubmitFn'></pop-up>
	</view>
</template>

<script>
	import projectList from "@/components/projectlist/list.vue"
	import tabSearchone from "@/components/toptab/searchone.vue"
	import timeYear from "@/components/timedata/timeyear.vue"
	import {gettslist,getjzqkFn} from "@/api/work/clue.js"
	import popUp from "@/components/popup/popup.vue"
	export default{
		data(){
			return{
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				itemslist:[],
				wtdt:'',
				tabidx:0,
				date:'',
				list:[],
				year:'',
				beginTime:'',
				endTime:'',
				name:'',
				census:'',
				deptId:this.$store.state.user.deptId,
				poptype:0,
				datainfo:{
					xmId:'',
					xmbh:'',
					xmmc:'',
				}
			}
		},
		components:{
			projectList,tabSearchone,timeYear,popUp
		},
		onUnload(){
			uni.$off('refreshdatalist')
		},
		onLoad(e) {
			this.getDataFn();
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			getClose(){
				this.poptype=0;
			},
			getXmjzFn(data){
				this.datainfo.xmId=data.id;
				this.datainfo.xmbh=data.xmbh;
				this.datainfo.xmmc=data.xmmc;
				this.poptype=4;
			},
			getXmSubmitFn(data){
				var that=this;
				var params=JSON.parse(JSON.stringify(data))
				params.xmId=this.datainfo.xmId;
				params.xmmc=this.datainfo.xmmc; 
				params.xmbh=this.datainfo.xmbh;
				getjzqkFn(params).then(res=>{
					if(res.code==200){
						that.$toast('添加项目进展成功')
						setTimeout(function(){
							that.poptype=0;
							that.pageNum=1;
							that.reachflag=true;
							that.list=[];
							that.getDataFn()
						},1500)									
					}else{
						this.$toast(res.msg)
					}
				})
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				gettslist(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)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.allpage{min-height: 100vh;background: #ffffff;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 ;}
  // 操作按钮
  .cluebtn{
  	display: flex;align-items: center;justify-content: center;font-weight: bold;font-size: 32rpx;color: #ffff;height: 100rpx;position: fixed;left: 0;right: 0;bottom: 0;z-index: 3;
  	&.btn1{background-color: #1FB9F7;flex: 1;}
  	&.btn2{background-color:#FF6400;flex: 1;}
  }
</style>