<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='员工管理'></cus-header>
		<div class="boxs" v-if="list.length">
			<div class="box" v-for="(item,index) in list" :key="index" @tap="toDetail(item)">
				<div class="top">
					<div class="left">
						<text>{{item.name||''}}</text>
						<image :src="imgBase+'home/staff_man.png'" v-if="item.gender==1"></image>
						<image :src="imgBase+'home/staff_women.png'" v-else-if="item.gender==2"></image>
					</div>
					<div class="right">{{item.entryDate||''}}入职</div>
				</div>
				<div class="bottom">
					<div class="left">手机号：{{item.mobile||''}}</div>
					<div class="right">工号：{{item.jobNumber||''}}</div>
				</div>
			</div>
		</div>
		<template v-else>
			<page-empty :height="'calc(100vh - '+mt+'px)'"></page-empty>
		</template>
	</view>
</template>

<script>
	import pageEmpty from '@/components/pageEmpty/index.vue'
	export default {
		components:{
			pageEmpty
		},
		data(){
			return {
				isOver:false,
				params:{
					page:1,
					limit:10
				},
				list:[]
			}
		},
		onReachBottom() {
			if(this.isOver) return
			this.getList();
		},
		onLoad() {
			this.getList();
		},
		methods:{
			getList(){
				this.$api.get('/staff/info/page',this.params).then(res=>{
					if(res.data.code===0){
						if(this.list.length<res.data.data.total){
							this.params.page++;
							this.list = [...this.list,...res.data.data.list];
						}else this.isOver = true
					}else this.$showModal(res.data.msg)
				});
			},
			toDetail(item){
				uni.navigateTo({
					url:'/pagesHome/employee/detail?id='+item.id
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		padding: 0 24rpx 20rpx;
		background: #F4F8FB;
		box-sizing: border-box;
		.boxs{
			width: 100%;
			.box{
				width: 100%;
				background: #FFFFFF;
				border-radius: 16rpx;
				padding: 36rpx 24rpx;
				box-sizing: border-box;
				margin-top: 20rpx;
				&>div{
					display: flex;
					align-items: center;
					justify-content: space-between;
				}
				.top{
					.left{
						display: flex;
						align-items: center;
						text{
							font-family: PingFang-SC, PingFang-SC;
							font-weight: bold;
							font-size: 32rpx;
							color: #1D2129;
							line-height: 36rpx;
						}
						image{
							width: 26rpx;
							height: 26rpx;
							margin-left: 23rpx;
						}
					}
					.right{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #4E5969;
						line-height: 36rpx;
						text-align: right;
					}
				}
				.bottom{
					margin-top: 20rpx;
					&>div{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #4E5969;
						line-height: 36rpx;
						&.right{
							text-align: right;
						}
					}
				}
			}
		}
	}
</style>