<template>
	<view class="pb50" :style="'padding-top:'+nvaHeight+'px;'">
		<view class="navbox">
			<uni-nav-bar  color="#ffffff" rightWidth="150rpx" title="履职信息" @clickLeft="getBack" @clickRight="getChFn"  :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
				<block slot="left">
					<view class="topl">
						<image :src="backimg" ></image>
					</view>
				</block>
				<block slot="right">
					<view class="topr">
						<image :src="ccicoimg"></image>
						<view>履职加分</view>
					</view>
				</block>
			</uni-nav-bar>
			<view class="plr12 mt18">
				<view class="search flex0 mb24">
					<image :src="searchimg"></image>
					<input placeholder="输入委员姓名进行查询" />
				</view>
			</view>
			<view style="height: 56rpx;"></view>
			<view class="lbtab flexc">
				<image :src="lbicoimg" class="limg"></image>
				<view class="lbtabs flexc">
					<view class="lbtabp" v-for="(ite,idx) in litablist" :key="idx">
						<picker  range-key='label' :value="talbidx" :range="taztList"  @change='bindDateChangea'>
							<view :class="datainfo.dqjz?'':'f16 co80'">{{datainfo.talb || ite.tit}}</view>
						</picker>
						<image :src="upimg" class="upimg"></image>
					</view>
				</view>
			</view>
		</view>
		<!-- 列表 -->
		<view class="mbox">
			<report-list type="1" :datalist="list" :wtdt="wtdt" :tajdlist='tajdlist'  @getDetail="getDetail" @getTuiFn="getTuiFn"></report-list>
		</view>
		<view class="fwbtns">履职档案</view>
		
		<!-- 弹窗 -->
		<pop-up :type='ptype' @getClose="getClose"></pop-up>
	</view>
</template>

<script>
	import {getCaseListFn} from "@/api/mine/case.js"
	import popUp from "@/work/components/popup/popup.vue"
	import reportList from "@/work/components/report/list.vue"
	import {getDictionaryFn} from "@/api/mine/register.js"
	export default{
		components:{reportList,popUp},
		data(){
			return{
				searchimg: require("@/work/static/images/search.png"),
				ccicoimg:require("@/work/static/images/ccico.png"),
				lbicoimg:require("@/work/static/images/lbico.png"),
				backimg:require("@/work/static/images/back.png"),
				upimg:require("@/work/static/images/up.png"),
				backgroundColor:"#1D64E2",
				litablist:[{tit:'选择界别',val:0},{tit:'选择党派',val:1},{tit:'综合排名',val:2}],
				nvaHeight:44,
				taztList:[{label:'是',value:'0'},{label:'否',value:'1'}],
				talbidx:'',
				datainfo:{
					talb:'',
				},
				ptype:'',//弹窗类型
				list:[{tit:"123"}],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				tajdlist:[]
				
			}
		},
		onUnload(){
			uni.$off('refreshlist')
		},
		onLoad(e) {
			// this.getDataFn()
			// this.init()
			// uni.$on('refreshlist', (e) => {
			// 	this.getDataFn()
			// })
		},
		mounted() {
			this.getHeightFn()
		},
		methods:{
			// 提案状态
			init(){
				getDictionaryFn('proposal_progress').then(res=>{
					if(res.code==200&&res.data.length){
						this.tajdlist = res.data.map(v => {
							return {
								label: v.dictLabel,
								value: Number(v.dictValue)
							}
						})
					}
				})
			},
			getHeightFn(){
				var s=uni.getSystemInfoSync().statusBarHeight;
				let query = uni.createSelectorQuery().in(this);
					//需要给黄色区域设置一个id标识，在这里是demo
				query.select('.navbox').boundingClientRect(data => {
					this.nvaHeight =s? data.height:Number(data.height)-20//赋值，待会要用
				}).exec();
			},
			getClose(){
				this.ptype=""
			},
			getBack(){
				uni.navigateBack({
					delta:1
				})
			},
			bindDateChangea(e){
				console.log(e,2)
			},
			getChFn(){
				this.$tab.navigateTo('/work/pages/report/addscore')
			},
			getTuiFn(ite){
				this.ptype=ite.type
			},
			getDetail(data){
				this.$tab.navigateTo('/work/pages/report/details?id='+data)	
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
					// visitType:3
				}
				getCaseListFn(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 scoped lang="scss">
.navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;background-color: $com-cd3;
	.topl{width: 60rpx;height: 60rpx;display: flex;align-items: center;justify-content: center;
		image{width: 40rpx;height: 30rpx;}
	}
	.topr{display: flex;align-items: center;
		image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
		view{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
	}
	.tablists{
		overflow: auto;flex-wrap: nowrap;
		view{font-weight: bold;font-size: 26rpx;color: #FFFFFF;position: relative;flex: 0 0 auto;padding: 22rpx 24rpx;margin-right: 6rpx;box-sizing: border-box;
			&:last-child{margin-right: 0;}
			&.act{font-size: 30rpx;
				&::after{content: '';width: 62rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -31rpx;bottom: 0rpx;position: absolute;}
			}
		}
	}
	.lbtab{height: 114rpx;background: #FFFFFF;border-radius: 30rpx;padding-left: 24rpx;position: absolute;left:24rpx;right: 24rpx;bottom: -58rpx;
		.limg{width: 40rpx;height: 34rpx;margin-right: 10rpx;flex:0 0 auto;}
		.lbtabs{overflow: auto;flex-wrap: nowrap;flex: 1;
			.lbtabp{display: flex;align-items: center;flex:1;margin-right: 24rpx;}
			.upimg{width: 18rpx;height: 10rpx;}
			
		}
	}
}
.mbox{padding:58rpx 24rpx 28rpx;}
.lbtabs /deep/ picker{padding: 0 18rpx;}
</style>