<template>
	<view :style="'padding-top:'+nvaHeight+'px;'">
		<view class="navbox">
			<uni-nav-bar color="#ffffff" left-icon="left" title="打卡记录" :background-color="backgroundColor"
				:border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
			</uni-nav-bar>
			<view class="plr16" :style="'background:'+backgroundColor">
				<view class="search flexc mb4">
					<image :src="serimg"></image>
					<input placeholder="请输入人员姓名进行搜索" confirm-type="search" placeholder-style="color:#B9DCF7" v-model="title" @confirm="getConfirm"/>
				</view>
				<!-- 搜索 -->
				<view class="lbtab flexc">
					<image :src="licoimg" class="limg"  @click='getResetFn'></image>
					<view class="lbtabs flexc">
						<!-- <picker class="pickbox" range-key='dictLabel' 	:range="adrlist" @change="bindTimeChangea">
							<view class="pickboxa">
								<view class="tit overtwo" >{{deptName||'考勤类型'}}</view>
								<image :src="wupimg" class="hupimg"></image>
							</view>
						</picker> -->
						<picker mode="date" class="pickbox"  
							 @change="bindTimeChangea">
							<view class="pickboxa">
								<view class="tit" >{{time||'选择时间'}}</view>
								<image :src="wupimg" class="hupimg"></image>
							</view>
						</picker>
					</view>
				</view>
			</view>
			
		</view>
		<image :src="navbg" class="navbg"></image>
		<view class="zxmain">
			<!-- 列表 -->
			<y-list type='clock' :datalist="list" :wtdt="wtdt" @getDetail='getDetail' :adrlist="adrlist" @getDelFn="getDelFn" @gettypeFn="gettypeFn"></y-list>
		</view>
	</view>
</template>

<script>
	import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
	import yList from "@/work/components/yuyue/list.vue"
	import {getRecordPeoList} from "@/api/work/check.js"
	import {getDictionaryFn} from "@/api/mine/register.js"
	export default {
		components: {yList},
		data() {
			return {
				wupimg:require("@/work/static/record/wup.png"),
				serimg:require("@/work/static/record/search.png"),
				licoimg:require("@/work/static/record/lico.png"),
				navbg:require("@/static/images/navbg.png"),
				backgroundColor: "transparent",
				datainfo:{},
				nvaHeight: 44,
				marTop: 0, //距离顶部的距离
				stubarHeight: 0, //
				title:'',
				list:[],
				pageSize: 10,
				pageNum: 1,
				reachflag: false,
				wtdt:'',
				userId:this.$store.state.user.userId,
				deptName:'',
				time:'',
				adrlist:[],
			}
		},
		onPageScroll(e) {
			var scrollTop = Number(e.scrollTop);
			if (scrollTop > 0) {
				this.backgroundColor = '#0491FD'
			} else {
				this.backgroundColor = 'transparent'
			}
		},
		onLoad: function() {
			this.init()
			this.getDataFn()
			uni.getSystemInfo({
				success: (e) => {
					this.stubarHeight = Number(e.statusBarHeight);
					this.nvaHeight = Number(e.statusBarHeight) + 44;
				}
			})
		},

		onShow() {},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods: {
			checkPermi,
			checkRole,
			getConfirm(){
				this.pageNum=1;
				this.list=[];
				this.reachflag=true;
				this.getDataFn()
			},
			getResetFn(){
				this.time='';
				this.title='';
				this.getConfirm()
			},
			getBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			gettypeFn(){
				
			},
			getDelFn(){
				
			},
			getDetail(ite){
				var obj={
					userId:ite.userId,
					recordDate:ite.clockMap.date
				}
				this.$tab.navigateTo('/work/pages/record/detail?data='+encodeURIComponent(JSON.stringify(obj)))
			},
			bindTimeChangea(e){
				var val=e.detail.value;
				this.time=val
				this.getConfirm()
			},
			init() {
				// 门卫
				// getDictionaryFn('is_read').then(res=>{
				// 	if(res.code==200){
				// 		this.ydztlist = res.data.map(v => {
				// 			return {
				// 				label: v.dictLabel,
				// 				value: v.dictValue
				// 			}
				// 		})
				// 	}
				// })
			},
			getDataFn() {
				var params = {
					pageSize: this.pageSize,
					pageNum: this.pageNum,
				}
				// if(!checkRole(['administrators'])){
				// 	params.userId=this.userId
				// }
				if(!checkPermi(['system:clock:glylist'])){
					params.userId=this.userId
				}
				if(this.time){
					params.recordDate=this.time
				}
				if(this.title){
					params.userName=this.title
				}
				getRecordPeoList(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>
/* 	page {
		background: #ffffff;
	} */
</style>
<style lang="scss" scoped>
.navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;	}
.navbg{width: 100%;height: 692rpx;}
.zxmain{position: relative;padding: 180rpx 32rpx 40rpx;box-sizing: border-box;}
.search{padding: 0 52rpx;box-sizing: border-box;
	width: 100%;height: 76rpx;background: rgba(40, 139, 214, 0.5);border-radius: 38rpx;
	image{width: 24rpx;height: 24rpx;margin-right: 22rpx;flex: 0 0 auto;}
	input{flex: 1;font-weight: 500;font-size: 22rpx;color: #FFFFFF;}
}
.lbtab{padding: 0 56rpx;
	.limg{width: 24rpx;height: 24rpx;margin-right: 16rpx;flex:0 0 auto;}
	.lbtabs{overflow: auto;flex-wrap: nowrap;flex:1;
		.pickbox{text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;min-height:88rpx;margin: 0 20rpx;
			.pickboxa{justify-content: center;	
				min-height: 88rpx;display: flex;align-items: center;	
			}
			.tit{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
			.hupimg{width: 16rpx;height: 10rpx;margin-left: 26rpx;flex: 0 0 auto;}
		}
		
	}
}
</style>
