<template>
	<view class="content">
		<view class="select-top">
			<view class="">
				本月统计
			</view>
			<view class="top-right">
				<view class="select-time">
					<picker mode="date" @change="bindDateChange" fields="month">
						<view class="uni-input">{{showdate}}</view>
					</picker>
					<image src="../../static/img/downjian.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<!-- <view class="dk-info">
			<view class="dk-day big">
				<view class="dk-left">
					20
				</view>
				<view class="dk-center">
					/
				</view>
				<view class="dk-right err">
					20
				</view>
			</view>
			<view class="dk-tit">
				<view class="dk-left">
					正常天数
				</view>
				<view class="dk-center">
					/
				</view>
				<view class="dk-right">
					异常天数
				</view>
			</view>
			<view class="dk-detail">
				<view class="detail-item green">
					<view class="">
						20
					</view>
					<view class="item-tit">
						已打卡(次)
					</view>
				</view>
				<view class="detail-item">
					<view class="">
						20
					</view>
					<view class="item-tit">
						未打卡(次)
					</view>
				</view>
				<view class="detail-item">
					<view class="err">
						20
					</view>
					<view class="item-tit">
						迟到(次)
					</view>
				</view>
			</view>
		</view> -->
		<scroll-view scroll-y="true" class="yg-list" :style="{'height': height}">
			<view class="yg-wrap" v-for="item in list">
				<view class="yg-name">
					{{item.staffName}}
				</view>
				<view class="dk-status" @click="goPage('/pagesS/yg/dkdetail?id=' + item.id)"
					:class="{'err': item.abnormal != 0}">
					{{item.abnormal == 0? '正常': '异常'}}
					<image src="../../static/img/downright.png" mode=""></image>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showdate: '',
				height: '',
				list: []
			}
		},
		onLoad() {

		},
		onShow() {
			this.getTime()
		},
		onReachBottom() {

		},
		onReady() {
			var obj = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.yg-list').boundingClientRect();
					query.exec(function(res) {
						obj.height = resu.windowHeight - res[0].top + 'px';
					});
				},
				fail: res => {}
			});
		},
		methods: {
			getKqList() {
				this.$u.api.getKqList({
					month: this.showdate //选择月份
				}).then(({
					data
				}) => {
					console.log(data, 'getKqList')
					this.list = data
				}).catch(err => {
					console.log(err);
				})
			},
			// 选择年月
			bindDateChange(e) {
				let time = e.detail.value.split('-')
				this.showdate = time[0] + '-' + time[1]
				this.getKqList()
			},
			// 获取当前年月
			getTime() {
				let date = new Date()
				try {
					let M = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))
					console.log(M)
					this.showdate = date.getFullYear() + '-' + M
					this.getKqList()
				} catch (e) {
					//TODO handle the exception
					console.log(e);
				}

			},
		}
	}
</script>

<style lang="scss">
	.select-top {
		width: 100%;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border: 1px solid #F5F5F5;
		font-size: 32rpx;
		font-weight: bold;
		color: #000000;
		padding: 0 30rpx;
		background-color: #fff;

		.top-right {
			font-size: 28rpx;
			font-weight: bold;
			color: #000000;
			display: flex;
			align-items: center;
			justify-content: flex-end;

			image {
				width: 19rpx;
				height: 11rpx;
			}
		}
	}

	.err {
		color: #E05742;
	}

	.dk-info {
		height: 326rpx;
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #fff;
		margin-bottom: 20rpx;

		.big {
			font-size: 46rpx !important;
			font-weight: 800;
			color: #000000;
			margin-bottom: 10rpx;
		}



		.dk-day,
		.dk-tit {
			display: flex;
			flex-direction: row;
			justify-content: center;
			width: 100%;
			font-size: 26rpx;

			.dk-left {
				width: 48%;
				text-align: right;
			}

			.dk-center {
				width: 4%;
				flex-shrink: 0;
				text-align: center;
				color: #D7D7D7;

			}

			.dk-right {
				width: 48%;
			}
		}

		.dk-detail {
			display: flex;
			justify-content: center;
			width: 100%;
			margin-top: 50rpx;

			.detail-item {
				width: 30%;
				text-align: center;
				font-size: 28rpx;
				font-weight: bold;
				color: #000000;

				.item-tit {
					margin-top: 15rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #666666;
				}
			}

		}
	}

	.yg-list {
		background-color: #fff;
		width: 100%;

		.yg-wrap {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 40rpx 0 30rpx;
			height: 100rpx;
			border-bottom: 1px solid #F2F2F2;
			font-size: 28rpx;
			font-weight: bold;
			color: #000000;

			.yg-name {}

			.dk-status {
				display: flex;
				align-items: center;

				image {
					width: 11rpx;
					height: 19rpx;
					margin-left: 10rpx;
				}
			}
		}
	}

	.select-time {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #000;
		display: flex;
		align-items: center;
		font-weight: bold;

		image {
			width: 17rpx;
			margin-left: 10rpx;
		}
	}
</style>
