<template>
	<view class="pad-x120">
		<!-- 头部 -->
		<status-nav :ifReturn="false" :ifHome="true" navBarTitle="工人信息"></status-nav>
		<view class="content" :style="{'padding-top':statusHeight+50+'px'}">
			<!-- 导航 -->
			<view class="pull-nav" :style="{'top':statusHeight+50+'px'}">
				<sub-nav @changeEv="changeEv"></sub-nav>
			</view>
			<!-- 全选 -->
			<view class="choose-all-bg"></view>
			<!-- 工人列表 -->
			<view class="sign-record sign-record-other bg-white">
				<view class="item font26" v-for="(item,index) in enterList" :key="index">
					<view class="info enter-info">
						<text>姓名：{{item.real_name}}</text>
						<text>技术岗位：{{item.position_name}}</text>
						<text>录入时间：{{item.created_at}}</text>
						<text v-if="item.status==-1">审核状态：<text class="color-red">已退回</text></text>
					</view>
					<!-- 待确认 -->
					<view class="examine-btns font24">
						<view class="btn color-blue" v-if="status==0" @tap="toDetail(item.id)">去确认</view>
						<view class="btn btn-other color-99" v-if="status==1" @tap="toDetail(item.id)">查看详情</view>
					</view>
				</view>
			</view>
			<!-- 加载更多 -->
			<view class="more-tips font24">{{enterList.length==total?'没有更多数据了':'下滑获取更多'}}</view>
		</view>
		<!-- 尾部 -->
		<tabbar :userType="userType" current="2"></tabbar>
	</view>
</template>
<script>
	import subNav from '@/components/sub-nav/sub-nav.vue';
	import tabbar from '@/components/tabbar/tabbar';
	export default {
		components:{
			subNav,
			tabbar
		},
		data() {
			return {
				statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
				userType:'director', //账户类型 工人：worker 负责人：director  工作台：workbench
				enterList:[], //打卡列表
				page:1,
				size:10,
				status:0,
				total:0,
				isAll:false, //是否全选
				ids:'', //选中的id
			}
		},
		onLoad(op) {
			if(op.userType){
				this.userType = op.userType;
			}
			// 获取录入列表
			this.getEnterList();
		},
		onShow() {
			
		},
		onReachBottom() {
			if(this.enterList.length<this.total){
				this.page++;
				// 获取录入列表
				this.getEnterList();
			}
		},
		onPullDownRefresh() {
			this.page = 1;
			// 获取录入列表
			this.getEnterList();	
			// 关闭下拉刷新
			uni.stopPullDownRefresh();
		},
		methods: {
			// 选择栏目
			changeEv(index){
				this.status = index;
				this.page = 1;
				// 获取录入列表
				this.getEnterList();
			},
			
			// 去确认&查看详情
			toDetail(id){
				uni.navigateTo({
					url:`/pagesB/enterDetail/enterDetail?id=${id}&userType=workbench`,
				})
			},
			
			// 获取录入列表
			getEnterList(){
				let params = {
					page:this.page,
					size:this.size,
					status:this.status
				}
				if(this.page==1) this.enterList = [];
				this.$requst.post('/api/v1/manager/check-list',params).then(res=>{
					if(res.code==0){
						console.log(res,'录入列表');
						this.total = res.data.total;
						this.enterList = this.enterList.concat(res.data.list);
					}
				})
			},
		}
	}
</script>
<style scoped>
	
</style>