<template>
	<view class="fgw">
		<view class="listtop">
			
			<view class="listtopa flexc">
				<image :src="dayimg" @click="getSeep"></image>
				<picker mode="date" :value="jdsj" fields="month"  class="flex1" @change='bindDateChangetimea'>
					<view :class="jdsj?'f16 c3':'f16 co80'">{{jdsj||"请选择日期进行搜索"}}</view>
				</picker>
				<view class="btn f16 cf flexcc" @click="getSearch">搜索</view>
			</view>
		</view>
		<view class="zhanline"></view>
		<!--  @getDown="getDown" @getDelFn='getdbDelFn' @getPutFn="getdbPutFn" @getjdShFn="getjdShFn" @getCbFn="getCbFn"  @getjzqklistFn="getjzqklistFn" -->
		<block v-if='list&&list.length'>
			<point :datainfo='list' @getHuiFn="getHuiFn" :jdflag='jdflag'></point>
		</block>
		<no-data v-else></no-data>
		
		<block >
			<view class="pfixedb">
				<view class="tstit"><text>*</text>汇报节点进度指汇报当前页面显示的本月节点进度，若汇报其他月份进度，请于搜索框搜索后再进行汇报</view>
				<view class=" flexc" v-if="checkPermi(['fgw:jzqk:add'])">
					<view style="height: 100rpx;"></view>
					<view class="cluebtn btn1"  @click="getAddbFn('xm')">汇报项目进度</view>
					<view class="cluebtn btn2"  @click="getAddbFn('jd')">汇报节点进度</view>
				</view>
			</view>
			
		</block>
	</view>
</template>

<script>
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	import noData from "@/components/nodata/nodata.vue"
	import {getlistzdapdFn} from '@/api/zdwork/addclue.js'
	import point from "@/components/zdclue/point.vue"  //节点安排
	export default{
		components:{
			noData,point
		},
		data(){
			return{
				dayimg:require('@/static/images/new/index/dayicon.png'),
				jdsj:'',
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				itemslist:[],
				year:'2023',
				month:'03',
				list:[],
				jdflag:false,
				datainfo:{}
			}
		},
		onLoad(e) {
			if(e.data){
				var newObj=JSON.parse(decodeURIComponent(e.data));
				this.datainfo.xmId=newObj.id;
				this.datainfo.xmmc=newObj.xmmc;
				this.getNowFormatDate();
				this.getDataFn()
			}
			
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			checkPermi, checkRole,
			getNowFormatDate(){
				let date = new Date();
				let y = date.getFullYear();
				let m = date.getMonth() + 1;
				m = m < 10 ? "0" + m : m;
				let d = date.getDate();
				d = d < 10 ? "0" + d : d;
				const timeday = y + "-" + m;
				// this.year=y;
				// this.month=m;
				this.jdsj=timeday;
				// return timeday;
			},
			bindDateChangetimea(e){//完成时间
				this.jdsj = e.detail.value;
				this.reachflag=true;
				this.pageNum=1;
				this.list=[];
				this.getDataFn()
			},
			getSearch(){
				this.getDataFn();
			},
			getAddbFn(tit){
				
				var newobj={
					id:this.datainfo.xmId,
					xmmc:this.datainfo.xmmc,
					pagetype:'add',
					jzfrom:'ratelist'
				}
				if(tit=='jd'){
					if(this.list&&this.list.length){
						var titval=this.list[0];
						newobj.jdId=titval.id
						newobj.year=titval.year
						newobj.month=titval.month
					}
					
				}
				this.$tab.navigateTo('/pages/zdpages/work/addrate?data='+encodeURIComponent(JSON.stringify(newobj)))
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
					jdsj:this.jdsj,
					xmId:this.datainfo.xmId,
					xmmc:this.datainfo.xmmc
				}
				getlistzdapdFn(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>
.listtop{padding: 24rpx;}
.listtopa{border: 6rpx solid #FD5001;border-radius: 32rpx;height:72rpx;box-sizing: border-box;padding:0 140rpx 0 32rpx ;position: relative;
 input{}
 image{width: 34rpx;height: 34rpx;margin-right: 24rpx;}
 .btn{background: #FA5F03;border-radius: 32rpx;width: 120rpx;position: absolute;right: -2rpx;top: -2rpx;bottom:-2rpx;}
 }	
.tstit{padding:24rpx;font-size:22rpx;color: #AAAAAA;line-height: 36rpx;
	text{color: #FF0000;}
}
// .jdlist /deep/ uni-picker{margin-top: -30rpx;margin-left: 24rpx;}
</style>