<template>
	<view class="listbox">
		<view class="fixedt">
			<!-- tab -->
			<view class="tablists flexc">
				<block v-for="(ite,idx) in tabList" >
					<view  v-if="!ite.limit||ite.limit&&checkPermi([ite.limit])" @click="getTabFn(ite.val)" :class="{act:tabval==ite.val}" :key="idx">{{ite.tit}}</view>
				</block>
			</view>
			<!-- 选择器 -->
			<view class="flexc checkbox">
				<picker mode="date"   @change='bindDateChangea'>
					<view class="chekt">
						<view>{{sbsj|| "申报时间"}}</view>
						<image :src="upimg"></image>
					</view>
				</picker>
				<picker range-key='label' :value="shidx" :range="shlist"  @change='bindDateChangeb'>
					<view class="chekt">
						<view>{{shzt || "审核状态"}}</view>
						<image :src="upimg"></image>
					</view>
				</picker>
				<picker range-key='label' :value="shidx" :range="shlist"  @change='bindDateChangeb'>
					<view class="chekt">
						<view>{{shzt || "申贷银行"}}</view>
						<image :src="upimg"></image>
					</view>
				</picker>
				<picker range-key='label' :value="shidx" :range="shlist"  @change='bindDateChangeb'>
					<view class="chekt">
						<view>{{shzt || "担保类型"}}</view>
						<image :src="upimg"></image>
					</view>
				</picker>
				<view class="reset" @click="getResetFn">
					<image :src="resetimg"></image>
				</view>
			</view>
		</view>
		<!-- 列表 -->
		<view class="plr18">
			<bus-list :datalist="list" :wtdt="wtdt" :type="type" @getDetail="getDetail"></bus-list>
		</view>
		
	</view>
</template>

<script>
	import config from '@/config'
	const baseUrl = config.baseUrl
	import busList from "@/work/components/business/list.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	export default{
		components:{busList},
		data(){
			return{
				upimg:require('@/work/static/images/sup.png'),
				resetimg:require('@/work/static/images/reset.png'),
				list:[{tit:'123'}],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				// limit:''
				type:'work',
				tabval:'0',
				tabList:[
					{tit:'全部',val:'0',},{tit:'申报审核',val:'1',},{tit:'担保初审',val:'2',},
					{tit:'尽职调查',val:'3',},{tit:'评审会',val:'4',},{tit:'签署合同',val:'5',},
				],
				sbsj:'',
				shidx:0,
				shzt:'',
				shztid:'',
				shlist:[{label:"未审",value:'0'},{label:"已审",value:'1'},{label:"已拒",value:'2'}]
			}
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			// if (this.reachflag) {
			// 	this.pageNum++
			// 	this.getDataFn()
			// }
		},
		methods:{
			checkPermi, checkRole,
			getDetail(){
				this.$tab.navigateTo("/work/pages/business/details")
			},
			getTabFn(val){
				this.tabval=val
			},
			bindDateChangea(e){
				var val=e.detail.value;
				this.sbsj=val;
				this.getrefreshData()
			},
			bindDateChangeb(e){
				var val=e.detail.value;
				this.shzt=this.shlist[val].label;
				this.shztid=this.shlist[val].value;
				this.getrefreshData()
			},
			getResetFn(){
				// 重置
				this.getrefreshData()
			},
			getrefreshData(){
				// this.pageNum=1;
				// this.list=[];
				// this.reachflag=true;
				// this.getDataFn()
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				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 lang="scss" scoped>
.fixedt{position: fixed;left: 0;right: 0;top: 0;z-index: 2;}
.fixedt /deep/ uni-picker{flex: 1;}
.tablists{background: $com-cd3;overflow: auto;flex-wrap: nowrap;padding:4rpx 16rpx 16rpx;
	view{font-weight: bold;font-size: 26rpx;color: #FFFFFF;position: relative;flex: 1 0 auto;padding: 0rpx 20rpx;margin-right: 6rpx;box-sizing: border-box;text-align: center;
		height: 80rpx;display: flex;align-items: center;
		&:last-child{margin-right: 0;}
		&.act{font-size: 30rpx;
			&::after{content: '';width: 30rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -15rpx;bottom: 0rpx;position: absolute;}
		}
	}
}
.checkbox{padding: 4rpx 0 0 20rpx ;background-color: #efefef;
	.chekt{display: flex;align-items: center;margin-right: 12rpx;height:88rpx;
		view{text-align: center;
			font-weight: bold;font-size: 26rpx;color: #374B61;width: 136rpx;word-break: break-all;text-overflow: ellipsis;overflow: hidden;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;white-space: normal;}
		image{width: 16rpx;height: 12rpx;flex: 0 0 auto;margin-left: 4rpx;}
	}
}
.reset{width:56rpx; height: 88rpx;display: flex;align-items: center;justify-content: center;
	image{width: 26rpx;height: 30rpx;}
}
.listbox{padding-top: 192rpx;padding-bottom: 24rpx;}
</style>