<template>
  <view class="content">
	  <!-- 搜索 -->
	  <tab-search :leftwith="checkPermi(['system:check:app'])?'80':'0'" :rightwith="checkPermi(['system:notice:list'])?'90':'0'" @clickLeft='clickLeft' @clickRight='clickRight' :noticenum="noticenum" @getSearch='getSearch'></tab-search>

	 <!-- banner -->
	 <block v-if="bannerlist.length">
		  <banner :bannerlist="bannerlist"></banner>
	 </block>
	

	<!-- <view class="home_tz" @click="getMessage" v-if="noticenum">
		 <image :src="tzimg"></image>
		 <view class="c34 f15 f500 over flex1">当前收到{{noticenum}}条消息，点击查看详情…</view>
		 <view class="f15 c6 ml4 flex0">02-21</view>
	 </view> -->
	 <view class="home_tz" @click="getDuFn" v-if="checkPermi(['projectV2:dbd:list'])">
	 	 <image :src="tzimg"></image>
	 	 <view class="c34 f15 f500 over flex1">当前收到{{dunoticenum}}条督办事项，点击查看详情…</view>
	 	 <view class="f15 c6 ml4 flex0">{{currentdate}}</view>
	  </view>
	 <!-- 模块 -->
	 <view>
		 <view class="flexc allpage_zd">
		 	<!-- <view class="allpage_zdl">共计<text>{{total||0}}</text>个</view> -->
		 	<time-year @bindDateChange="bindDateChange" fields='year' textAlign='right' timetxt='选择年份'></time-year>
			<view class="allpage_zdl">按年份统计，默认本年度</view>
		 </view>
		<view class="homelist">
			<view class="list" @click="handleToAll(1)" v-if="checkPermi(['projectV2:sbbzb:list'])">
				<image :src="homeaimg"></image>
				<view class="tit">项目线索</view>
				<view class="txt co1">{{census.st}}</view>
				
			</view>
			<view class="list" @click="handleToAll(2)" v-if="checkPermi(['projectV2:sbbzb:list'])">
				<image :src="homebimg"></image>
				<view class="tit">项目签约</view>
				<view class="txt co2">{{census.qy}}</view>
			</view>
			<view class="list" @click="handleToAll(3)" v-if="checkPermi(['projectV2:sbbzb:list'])">
				<image :src="homecimg"></image>
				<view class="tit">项目开工</view>
				<view class="txt co3">{{census.kg}}</view>
			</view>
			<view class="list" @click="handleToAll(4)" v-if="checkPermi(['projectV2:sbbzb:list'])">
				<image :src="homedimg"></image>
				<view class="tit">项目投产</view>
				<view class="txt co4">{{census.tc}}</view>
			</view>
			<view class="list" @click="handleTosk" v-if="checkPermi(['projectV2:skxm:list'])">
				<image :src="homeeimg"></image>
				<view class="tit">省库项目</view>
				<view class="txt co2">{{census.sk}}</view>
			</view>
			<view class="list" @click="handleTowt" v-if="checkPermi(['projectV2:shyj:list'])">
				<image :src="homefimg"></image>
				<view class="tit">问题项目</view>
				<view class="txt co3">{{census.wt}}</view>
				<!-- <view class="list_not">2</view> -->
			</view>
			<view class="list" @click="handleTold" v-if="checkPermi(['projectV2:sbbzb:ldps:list'])">
				<image :src="homegimg"></image>
				<view class="tit">领导批示</view>
				<view class="txt co4">{{census.ps}}</view>
				<!-- <view class="list_not">99+</view> -->
			</view>
			<!--  -->
			<view class="list" @click="handleToAll(0)" v-if="checkPermi(['projectV2:sbbzb:list'])">
				<image :src="homehimg"></image>
				<view class="tit">全部项目</view>
				<view class="txt co1">{{census.all}}</view>
			</view>
		</view> 
	 </view>
	 <!-- 统计表 -->
	<view class="cont_box " @click="getContFn" v-if="checkPermi(['system:qktj:show'])">
		 <image :src="centimg" class="climg"></image>
		 <view class="flex1 f16 c64 fw">潜山市招商情况月统计</view>
		 <image :src="rimg" class="crimg"></image>
	 </view>
	<!-- 重大项目 -->
	<view>
		<view class="home_more" v-if="checkPermi(['projectV2:sbbzb:list'])">
			<view class="flexc pdlr14 pdtb8" @click="handleTozd">
				<view class="tit">重大项目</view>
				<view class='flexc home_morer'>查看更多
					<image :src="mrimg"></image>
				</view>
			</view>
			<project-list :datalist="list" @getDetail='goDetail'></project-list>
			<view class="shax" v-if="list.length" @click="handleTozd">查看更多</view>
		</view>
		<!-- 列表 -->
	</view>
	<!-- <voice v-if='voiceflag' @closePopup='closePopup' @voiceResult='voiceResult'></voice> -->
	<!-- <block v-if="showfooter == 1"> -->
		<!-- <footers v-if="isfootflag"   :footerindex="footerindex" :isHomeIndex="true"></footers> -->
		<footers v-if="isfootflag" :footlist="footlist" :footerindex="footerindex" :color_checked="color_checked" :color_nochecked="color_nochecked" :isHomeIndex="true"></footers>
	<!-- </block> -->
	<!-- 弹窗 -->
	<!-- 弹窗 -->
	<view class="bgbox" v-if="tsflag"></view>
	<!-- 弹窗 -->
	<view class="fixedbox" v-if="tsflag">
		<!-- <image :src="closeimg" class="choseimg" @click="getClose"></image> -->
		<view class="top">温馨提示</view>
		<view class="boxs">
			<view class="c34 f16 fw">您有15天未填写签约信息的记录信息，请填写</view>
		</view>
		<view class="fixedbtn" @click="getKnow">去查看</view>
	</view>
  </view>
</template>

<script>
	import timeYear from "@/components/timedata/timeyear.vue"
	import tabSearch from "@/components/toptab/search.vue"
	import banner from "@/components/toptab/banner.vue"
	import projectList from "@/components/projectlist/list.vue"
	import {getBannerlist,getNoticenumber,getCommonCensus,getdbdnumber} from "@/api/work/index.js"
	import { getsbbzblist,gettslist} from '@/api/work/clue.js'
	import footers from '@/components/footer/footer.vue'

	// import voice from "@/pages/seep.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  export default {
	  data(){
		  return{
			  tzimg:require('@/static/images/index/tzicon.png'),
			  homeaimg:require('@/static/images/index/homea.png'),
			  homebimg:require('@/static/images/index/homeb.png'),
			  homecimg:require('@/static/images/index/homec.png'),
			  homedimg:require('@/static/images/index/homed.png'),
			  homeeimg:require('@/static/images/index/homee.png'),
			  homefimg:require('@/static/images/index/homef.png'),
			  homegimg:require('@/static/images/index/homeg.png'),
			  homehimg:require('@/static/images/index/homeh.png'),
			  mrimg:require("@/static/images/index/mrore.png") ,
			  closeimg:require('@/static/images/close.png'),
			  rimg:require('@/static/images/mine/rimg.png'),
			  centimg:require("@/static/images/index/centicon.png"),
			  list:[],
			  bannerlist:[],
			  noticenum:0,
			  census:{},//统计
			 footlist:[
			 	{module:'home',title:'首页',icon_checked:require('@/static/images/tabbar/home_.png'),icon_nochecked:require('@/static/images/tabbar/home.png')},
				{module:'center',title:'引荐项目',icon_checked:require('@/static/images/tabbar/cen_.png'),icon_nochecked:require('@/static/images/tabbar/cen.png')},
			 	{module:'mine',title:'我的',icon_checked:require('@/static/images/tabbar/mine_.png'),icon_nochecked:require('@/static/images/tabbar/mine.png')},
			 	],
			  footerindex:'home',
			  showfooter: 0,
			  isfootflag:true,
			  color_checked :'343434',
			  color_nochecked :'666666',
			  dunoticenum:0,
			  voiceflag:false,
			  deptId:'',
			  tsflag:false,
			  currentdate:'',
		  }
	  },
	  components:{tabSearch,banner,projectList,footers,timeYear},
	  onUnload(){
	  	uni.$off('refreshdatalist')
	  },
	  onLoad() {
		  this.deptId=this.$store.state.user.deptId;
		  // 判断有无切换权限
		  
		  this.currentdate = this.getNowFormatDate();
		this.init()
		uni.$on('refreshdatalist',(e) => {
			this.list=[];
			if(checkPermi(['projectV2:sbbzb:list'])){
				this.getsbbzblist()
			}
			if(e&&e=='ldps'){
				
			}else if(e&&e=='duban'){
				this.getdbdnumber();
			}else{
				this.getCommonCensus();
				this.getdbdnumber();
			}
		})
	  },
	  onShow() {
	  	this.gettslist()
	  },
	  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;
			this.time=y;
		  	const timeday = m + "-" + d;
		  	return timeday;
		  },
		  bindDateChange(e){
		  	this.time=e;
		  	// var timestr=e.split('-');
		  	// this.year=timestr[0];
		  	// this.month=timestr[1];
		  	// this.reachflag=true;
		  	// this.pageNum=1;
		  	// this.list=[];
		  	this.getCommonCensus();
			if(checkPermi(['projectV2:sbbzb:list'])){
				this.list=[];
				this.getsbbzblist()
			}
		  },
		  gettslist(){
		  	gettslist().then(res=>{
		  		if(res.code==200){
		  			if(res.rows&&res.rows.length){
						this.tsflag=true;
		  			}else{
						this.tsflag=false;
					}								
		  		}else{
		  			this.$toast(res.msg)
		  		}
		  	})
		  },
		  getKnow(){
			  this.$tab.navigateTo('/pages/work/tslist')
		  },
		  init(){
			  
			this.getNoticenumber()
		  	this.getBanList()
			this.getCommonCensus()
			if(checkPermi(['projectV2:sbbzb:list'])){
				this.getsbbzblist()
			}
			
			this.getdbdnumber()
		  },
		  //左侧点击
		  clickLeft(){
			  if(checkPermi(['system:check:app'])){
			  	this.$tab.reLaunch('/pages/indexs')
			  }
			  // this.voiceflag=true;
			  // this.$refs.voice.show()
		  	 
		  },
		  //右侧点击
		  clickRight(e){
			 if(checkPermi(['system:notice:list'])){
			 	this.$tab.navigateTo('/pages/work/message')
			 } 
		  	
		  },
		  getMessage(){
		  	if(checkPermi(['system:notice:list'])){
		  		this.$tab.navigateTo('/pages/work/message')
		  	} 
		  },
		  getContFn(){
			 this.$tab.navigateTo('/pages/work/count/count') 
		  },
		  closePopup(){
			  
		  },
		  voiceResult(){
			   this.voiceflag=false;
			  this.$refs.voice.hide();
			  this.$refs.voice.afterHide()
			  let params={
				  ...this.searchTabObj,
				  voice:true,
				  data:data
			  }
		  },
		  getdbdnumber(){
			  var params={
				  deptId:this.deptId,
				  isHf: 'N',
			  }
			  getdbdnumber(params).then(res=>{
			  	if(res.code==200){
					this.dunoticenum=res.data
			  	}else{
			  		this.$toast(res.msg)
			  	}
			  })
		  },
		  getNoticenumber(){
			  var params={
			  	deptId:this.deptId
			  }
			  getNoticenumber(params).then(res=>{
			  	if(res.code==200){
			  		this.noticenum=Number(res.data)
			  	}else{
			  		this.$toast(res.msg)
			  	}
			  })
		  },
		  getBanList(){
			  var params={
			  	deptId:this.deptId
			  }
		  	getBannerlist(params).then(res=>{
				if(res.code==200){
					this.bannerlist=res.rows
				}else{
					this.$toast(res.msg)
				}
		  	})
		  },
		  getCommonCensus(){
			  var objs={
				  params:{
					  year:this.time
				  }
			  }
			  getCommonCensus(objs).then(res=>{
			  	if(res.code==200){
			  		this.census=res.data
			  	}else{
			  		this.$toast(res.msg)
			  	}
			  })
		  },
		  //重大项目
		  getsbbzblist(){
			  var params={
			  	pageSize:5,
			  	pageNum: 1,
				sfwlhxxxm:'Y',
				deptId:this.deptId,
			  }
			  params['params[beginTime]']=this.time+'0101';
			  params['params[endTime]']=this.time+'1231';
			 getsbbzblist(params).then(res=>{
			 	if(res.code==200){
			 		this.list = res.rows;
			 	}else{
			 		this.$toast(res.msg)
			 	}
			 }) 
		  },
		 
		  
		  // 督办
		  getDuFn(){
		  	this.$tab.navigateTo('/pages/work/idea')
		  },
		  getSearch(data){
			   this.$tab.navigateTo('/pages/work/allitems?idx=0&xmmc='+data)
		  },
		  handleToAll(idx){
			this.$tab.navigateTo('/pages/work/allitems?idx='+idx+'&time='+this.time)
		  },
		  handleTosk(){
			  this.$tab.navigateTo('/pages/work/skitem?time='+this.time)
		  },
		  handleTowt(){
		  	this.$tab.navigateTo('/pages/work/wtitem?time='+this.time)
		  },
		  handleTold(){
		  	 this.$tab.navigateTo('/pages/work/lditem?time='+this.time)
		  },
		  handleTozd(){
		  	 this.$tab.navigateTo('/pages/work/zditem?time='+this.time)
		  },
		  goDetail(e){
			  this.$tab.navigateTo('/pages/work/cluedetails?id='+e.id)
		  }
	  },
  }
</script>

<style lang="scss" scoped>
.content{min-height: 100vh;background-color: #ffffff;}
.home_tz{display: flex;align-items: center;padding: 0 28rpx;height: 80rpx;background: #FFE9D5;
	image{width: 66rpx;height: 30rpx;margin-right: 24rpx;flex: 0 0 auto;}
}

.homelist{display: flex;flex-wrap: wrap;padding: 40rpx 20rpx;
	.list{width: 25%;display: flex;flex-direction: column;align-items: center;padding: 20rpx 0;position: relative;
	.list_not{    position: absolute; background: #F63030;color: #ffffff;font-size: 18rpx;left: 50%;top: 24rpx;border-radius: 50%;min-width: 40rpx;height: 40rpx;text-align: center;padding: 0 4rpx;box-sizing: border-box;line-height: 40rpx;margin-left: 30rpx;}
	image{width: 108rpx;height: 108rpx;margin-bottom: 20rpx;}
	.tit{font-size: 30rpx;font-weight: bold;
color: #444444;margin-bottom: 12rpx;}
	.txt{font-size: 30rpx;font-weight: bold;
	&.co1{color: #F84E57;}
	&.co2{color: #26C240;}
	&.co3{color: #F74E32;}
	&.co4{color: #3C9BCD;}
	}
	}
}
.home_more{padding-top: 20rpx;
	.tit{font-size: 32rpx;font-weight: bold;color: #343434;position: relative;padding-left: 22rpx;flex: 0 0 auto;
	&::before{content: '';width: 8rpx;height: 40rpx;position: absolute;left: 0;top: 50%;margin-top: -20rpx;background-color: #FC7300;}
	}
	.home_morer{flex: 1;display: flex;align-items: center;justify-content: flex-end;
		view{font-size: 30rpx;color: #AAAAAA;font-weight: 500;}
		image{width: 24rpx;height: 24rpx;margin-left: 14rpx;}
	}
}

.fixedbox{
	height: 480rpx;box-sizing: border-box;z-index: 3000;
	.boxs{padding: 90rpx 0 70rpx;}
	.fixedbtn{width:100%;height: 80rpx;background: #FF6400;
	border-radius: 10rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;font-weight: bold;color: #FFFFFF;
		&.btn1{background-color: #20ACCF;margin-bottom: 36rpx;}
	}
}
.bgbox{z-index:2000;}
.cont_box{width: 706rpx;height: 100rpx;background: #EDF5FF;border-radius: 10rpx;margin: 0 auto 80rpx;padding: 0 40rpx;box-sizing: border-box;display: flex;align-items: center;
	.climg{width: 68rpx;height: 60rpx;margin-right: 28rpx;flex: 0 0 auto;}
	.crimg{width: 16rpx;height: 26rpx;flex: 0 0 auto;}
}
 .allpage_zd{background-color:#F2F2F2;padding: 0 28rpx;justify-content: space-between;
	.allpage_zdl{font-size: 24rpx;font-weight: 500;color: #666666;
	text{font-weight: bold;color: #FE5706;margin: 0 8rpx;}
	}
}
</style>
