<template>
	<view class="box">
		<view class="boxtop">
			<view class="boxtopa">
				<input placeholder="请输入人员姓名查询"  v-model="userName"/>
				<view @click="getSearch">查询</view>
			</view>
			<view class="boxtopb">
				<!-- 日期选择器 -->
				<view class="approva_header">
					<picker mode="date" :value="selectDate" fields="month" @change="bindDateChange">
						<view class="flexc">
							<image :src="timg"></image>
							<text class="uni-calendar__header-text">{{selectDate||'选择日期'}}</text>
							<image :src="uimg"></image>
						</view>
					</picker>
				</view>
			</view>
		</view>	
		<card-list :datainfo="prolist" type='count'   @getdetail='goDetail'></card-list>
			<!-- <view class="exele" style="padding-top: 0;display: none;">
					<table @change="change">
						<tr class="tr_one">
							<th style="width: 100upx; text-align: center;">姓名</th>
							<th style="width: 125upx; text-align: center;">部门</th>
							<th style="width: 100upx; text-align: center;">外勤</th>
							<th style="width:100upx; text-align: center;">迟到</th>
							<th style="width: 100upx; text-align: center;">早退</th>
							<th style="width: 100upx; text-align: center;">缺卡</th>
							<th style="width: 125upx; text-align: center;">打卡详情</th>
						</tr>
						<scroll-view scroll-y class="scroll-view" upper-threshold="40" lower-threshold="40"
							@scrolltolower="bot_btn">
							<tr v-for="(item,index) in prolist" :key="index"
								:class=" [index%2  ==0 ? 'two_tr two_trtwo':'two_tr']" @click="chakn(item)">
								<td style="width: 100upx; text-align: center;">
									{{ item.userName == null ? '暂无信息' :  item.userName}}</td>
								<td style="width: 125upx; text-align: center;">
									{{ item.deptName == null ? '暂无信息' :  item.deptName}}</td>
									<td style="width: 100upx; text-align: center;">
										{{item.外勤 == null? '暂无信息' : item.外勤 }}</td>
								<td style="width: 100upx; text-align: center;">
									{{item.迟到 == null? '暂无信息' : item.迟到 }}</td>
										<td style="width: 100upx; text-align: center;">
											{{item.早退 == null? '暂无信息' : item.早退 }}</td>
											<td style="width: 100upx; text-align: center;">
											{{item.缺卡 == null? '暂无信息' : item.缺卡 }}</td>
								<td style="width: 125upx; color: #1678FF;text-align: center;text-decoration: underline;" @click.stop="goDetail(item)">查看详情</td>
							</tr>
							<div class="shax" v-if="prolist.length>0">
								{{wtdt}}
							</div>
							<div class="zanwu " v-else><span>暂无数据</span></div>
						</scroll-view>

					</table>
	

			</view> -->

	</view>
</template>

<script>
	import {getClockCountall} from "@/api/work/check.js"
	import selectPicker from '@/components/selectPicker.vue'
	import cardList from "@/work/components/clock/cardlist.vue"
	// import {selectDictLabel} from '@/utils/common.js'
	export default {
		data() {
			return {
				timg:require("@/static/images/time.png"),
				uimg:require("@/static/images/up.png"),
				buimg: require("@/static/images/chosebm.png"),
				addimg: require("@/static/images/addry.png"),
				upimg: require("@/static/images/up.png"),
				closeimg:require("@/static/images/close.png"),
				rimg:require("@/static/images/right.png"),
				prolist:  [],
				wtdt: '',
				userName:'',
				listite:{
					"roleName":'',
					"roleId":''
				},
				rolelist:[],
				role:'',
				deptId:this.$store.state.user.deptId,
				roindex:-1,
				roleId:'',
				rangekey:"label",
				pageNum: 1,
				pageSize: 10,
				reachflag:true,
				deptName:'',
				kaYear:'',
				kaMonth:'',
				selectDate: '',
			}
		},
		components:{
			selectPicker,cardList
		},
		onLoad() {
			this.selectDate = this.formatDateTime();
			this.getsubordinateList()
		},
		onReachBottom() {
				if (this.reachflag) {
					this.pageNum++
					this.getsubordinateList()
				}
		},
		methods:{
			formatDateTime() {
			var 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 time = y + "-" + m ;
			  this.kaYear=y;
			  this.kaMonth=m;
			  return `${y}-${m}`;
			
			},
			bindDateChange(e) {
				this.selectDate = e.detail.value
				var val=e.detail.value.split('-')
				this.pageNum=1;
				this.prolist=[];
				this.kaYear=val[0];
				this.kaMonth=val[1]
				this.reachflag=true;
				this.getsubordinateList()
			},
			
			getSearch(){
				this.pageNum=1;
				this.prolist=[];
				this.reachflag=true;
				this.getsubordinateList()
			},
			goDetail(e){
				var obj={
					userId:e.userId,
					recordDate:this.selectDate+'-01'
				}
				// var obj={
				// 	userId:3,
				// 	recordDate:'2024-10-20'
				// }
				this.$tab.navigateTo('/work/pages/record/detail?data='+encodeURIComponent(JSON.stringify(obj)))
				
			},
			getsubordinateList(){
				var that = this;
				var params={
					// "ancestors":this.$store.state.user.ancestors,
					// "kaYear":this.kaYear,
					// "kaMonth":this.kaMonth,
					// name:this.userName,
					pageSize: this.pageSize,
					pageNum: this.pageNum,
					// deptId:this.$store.state.user.deptId
					recordDate:this.selectDate
				}
				if(this.userName){
					params.name=this.userName
				}
				getClockCountall(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.prolist = res.rows;
						} else {
							this.prolist = this.prolist.concat(res.rows)
							}
					} else {
						this.$toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box{height: 100vh;display: flex;flex-direction: column;padding-top: 188rpx;box-sizing: border-box;background-color: #f2f2f2;}
	
	.boxtop{
		flex: 0 0 auto;position: fixed;left:0;right: 0;top: 0;z-index: 5;background-color: #FFFFFF;
		// padding: 0 34rpx;
		.boxtopa{
			padding: 14rpx 34rpx;display: flex;align-items: center;box-shadow: 0px 6rpx 12rpx 0px rgba(210,210,210,0.35);
			input{height: 64rpx;background: #E6E6E6;border-radius: 28rpx;flex: 1;background: #E6E6E6;padding: 0 30rpx;line-height: 64rpx;
border-radius: 28rpx;font-size: 28rpx;}
			view{width: 120rpx;height: 64rpx;background: #1678FF;border-radius: 28rpx;font-size: 28rpx;color: #FFFFFF;margin-left: 8rpx;flex: 0 0 auto;text-align: center;line-height: 64rpx;}
		}
		.boxtopb{
			display: flex;align-items: center;justify-content: space-between;padding: 12rpx 0;
			.boxflex{display: flex;align-items: center;
				.boxtopba{width: 26rpx;height: 24rpx;margin-right: 16rpx;}
				.boxtopbb{font-size: 28rpx;color:#1678FF;margin-right: 16rpx;}
				.boxtopbc{width: 14rpx;height: 14rpx;}
				.boxtopbd{width: 28rpx;height: 28rpx;margin-right: 16rpx;}
				.boxtopbe{font-size: 28rpx;color:#6CBC0A;}
			}
		}
	}
	.tab {
		.tabs {
			.one_tab {
				color: #1678FF !important;
	
			}
	
			.one_tabqie {
				border-bottom: 8rpx solid #1678FF;
	
			}
		}
	}
	.exele {
		flex: 1;display: flex;flex-direction: column;overflow: hidden;

			table{border-spacing: 0rpx;height: 100%;display: flex;flex-direction: column;}
			.tr_one {
				display: flex;
				flex: 0 0 auto;
				// padding: 0 20rpx;
				box-sizing: border-box;
				justify-content: space-between;
				th {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #000000;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					line-height: 78rpx;
					height: 78rpx;
					box-sizing: border-box;
				}
			}
	
			.two_tr {
				display: flex;
				// padding: 0 20rpx;
				box-sizing: border-box;
				justify-content: space-between;
	
				td {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #343434;
					
					min-height: 82rpx;
					padding: 20rpx 0;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					justify-content: center;
	
				}
	
				// .tdse {
				// 	color: #E60012 !important;
				// }
				// .apply_span_xl{
				// 	color: #32B16C !important;
				// }
				// .apply_span_xltwo{
				// 	color: #ffa200 !important;
				// }
				// .apply_span_xlfive{
				// 	color: #4c4b4b !important;
				// }
				// .apply_span_xlthreo{
				// 	color: #f00404 !important;
				// }
				// .apply_span_xlforu{
				// 	color: #aaaaaa !important;
				// }
				// .coiu {
				// 	color: #EC1717;
				// }
			}
	
			.two_trtwo {
				background-color: #F2F2F2;
			}
			.scroll-view{flex: 1;overflow-y: auto;}
	
	}
	.zanwu {text-align: center;
		padding-top: 20upx;

		span {
			font-size: 30upx;
		}}
	// 搜索条件width: 562rpx;
	.bgbox{position: fixed;left: 0;right: 0;top: 0;bottom: 0;z-index: 19;
	background: rgba(0,0,0,0.5);}
		.sfixed{min-height: 760rpx;background: #FFFFFF;border-radius: 14rpx;padding: 40rpx 34rpx;box-sizing: border-box;position: fixed;left: 60rpx;right: 60rpx;top: 50%;transform: translateY(-50%);
		z-index: 29;max-height: calc(100vh - 280rpx);overflow-y: auto;
			.sfixed_tit{font-size: 28rpx;font-weight: bold;color: #343434;line-height: 44rpx;text-align: center;}
			.sfixed_clo{width: 20rpx;height: 20rpx;position: absolute;left: 34rpx;top: 44rpx;}
			.sfixed_box{
				padding-top: 20rpx;
				margin-bottom: 80rpx;
				.sfixed_inp{width: 100%;height: 76rpx;background:#F2F2F2;padding: 0 34rpx;box-sizing: border-box;font-size: 34rpx;color: #333333;margin-top: 30rpx;}
			}
			.sfixed_btn{width: 100%;height: 76rpx;border: 0px solid #00B034;border-radius: 6rpx;font-size: 28rpx;
	color: #FFFFFF;text-align: center;line-height: 76rpx;
			&.btn1{background: #1678FF;color: #FFFFFF;}
			&.btn2{border: 2rpx solid #F02828;color: #F02828;margin-top: 28rpx;}
	
	
	}
			
		}
		.address{
				display: flex;align-items: center;
				padding: 24rpx 0;
				.addtita{flex: 0 0 auto;font-size: 28rpx;font-weight: bold;
		color: #343434;}
				.addressa{
					display: flex;align-items: center;
					flex: 1;
					display: flex;align-items: center;justify-content: flex-end;
					overflow: hidden;
					.addsa{font-size: 28rpx;color: #333333;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
					flex: 1;text-align: right;
					}
					.addsimg{width: 10rpx;height: 18rpx;margin-left: 10rpx;flex: 0 0 auto;}
					// .adds{
					// 	display: flex;align-items: center;justify-content: flex-start;padding:10rpx 20rpx;min-width: 220rpx;box-sizing: border-box;}
				}
				
				.addclear{color: #EA2929;font-size: 28rpx;flex: 0 0 auto;height: 60rpx;line-height: 60rpx;width: 128rpx;text-align:center}
			}
		.approva_header {
			height: 80rpx;
		
			picker {
				padding: 0 34rpx;
				display: flex;
				align-items: center;
				height: 40px;
		
				image:nth-child(1) {
					width: 26rpx;
					height: 26rpx;
				}
		
				image:nth-child(3) {
					width: 14rpx;
					height: 14rpx;
		
				}
		
				text {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #1678FF;
					margin: 0 14rpx;
				}
			}
		}
</style>
