<template>
	<view>

		<view class='wrap' v-for="(item, index) in tableData" :key="index">
			<view class="wenzi audit1" v-if="item.approveStatus == '待人事审核' || item.approveStatus == '待主管审核' ">审核中</view>
			<view class="wenzi audit2" v-if="item.status == '已通过'">已通过</view>
			<view class="wenzi audit3" v-if="item.status == '未通过'">未通过</view>
			<view class="c-row">
				<view class="title">请假类型 : {{item.leaveType}}</view>
			</view>
			<view class="c-row">
				<view class="title">请假事由 : {{item.reasonForLeave}}</view>
			</view>
			<view class="c-row">
				<view class="title">开始时间 : {{item.startDate}}</view>
			</view>
			<view class="c-row">
				<view class="title">结束时间 : {{item.endDate}}</view>
			</view>
		</view>
		<view v-show="isLoadMore">
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
		<view class="bottom-btn">
			<view>
				<view style='width:100%;' class='flex flex-space-between'>
					<view @click='clocksubmit' style='width:50%;text-align:center;'>
						<image v-if='value==0' class="u-page__item__slot-icon"
							src="../../static/img/oa_office/leave/qingjia-check.png"></image>
						<image v-else class="u-page__item__slot-icon"
							src="../../static/img/oa_office/leave/qingjia.png"></image>
						<view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
					</view>
					<view @click='clockRecord' style='width:50%;text-align:center;'>
						<image v-if='value==1' class="u-page__item__slot-icon"
							src="../../static/img/oa_office/leave/jilu-check.png"></image>
						<image v-else class="u-page__item__slot-icon" src="../../static/img/oa_office/leave/jilu.png">
						</image>
						<view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
					</view>
				</view>
			</view>

			<!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->

		</view>
	</view>
	</view>
</template>

<script>
	import dRili from '@/components/d-rili/d-rili.vue';
	export default {
		components: {
			dRili
		},
		data() {
			return {
				pageSize: 10,
				currentPage: 1,
				tableData: [],
				value: 1,
				isLoadMore: false, //是否加载中
				loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
			}
		},
		onShow() {
			this.getList()
		},
		//下拉刷新
		onPullDownRefresh() {
			this.currentPage = 1
			this.isLoadMore = false
			this.loadStatus = 'loading'
			this.getList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() { //上拉触底函数
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.isLoadMore = true
				this.currentPage += 1
				this.getList()
			}
		},
		methods: {
			getList() {
				this.$api.doRequest('get', '/leaveInfo/selectLeaveInfo', {
					pageSize: this.pageSize,
					currentPage: this.currentPage,
					pcFlag: 0,
					compId: uni.getStorageSync('pcUserInfo').compId,
					commonId: uni.getStorageSync('pcUserInfo').userId,
				}).then(res => {
					// if (res.data.code == 200) {
					// 	this.tableData = res.data.data.records

					// }
					if (res.data.code == 200) {
						if (res.data.data.records.length > 0) {
							this.isLoadMore = false
							this.loadStatus = 'loading'
						} else {
							this.isLoadMore = true
							this.loadStatus = 'nomore'
						}
						if (this.currentPage == 1) {
							this.tableData = res.data.data.records
						} else {
							this.tableData = this.tableData.concat(res.data.data.records)
						}

					}
				})
			},
			clockRecord() {
				uni.navigateTo({
					url: '/pages/leave/the_leave_record'
				})
			},
			clocksubmit() {
				uni.navigateTo({
					url: '/pages/leave/the_leave'
				})
			},
		}
	}
</script>

<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.wrap {
		padding-top: 15px;
		padding-bottom: 20px;
		font-size: 14px;
		background: #fff;
		margin: 10px;
		border-radius: 10px;

		input {
			font-size: 14px;
		}

		>.title {
			padding: 10px 16px;
		}

		.wenzi {
			text-align: right;
			border-radius: 10rpx;
			margin-right: 30rpx;
			height: 10rpx;
		}

		.audit1 {
			color: red;
		}

		.audit2 {
			color: #afafe6;
		}

		.audit3 {
			color: red;
		}

		.c-row {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-align: center;
			-webkit-align-items: center;
			align-items: center;
			padding: 5rpx 30rpx;
			position: relative;
		}
	}



	.submit {
		width: 40%;
		background: #22C572;
		border-radius: 10rpx;
	}

	.bottom-btn {
		padding: 30rpx;
		background: #FFFFFF;
		width: 100%;
		position: fixed;
		bottom: 0rpx;
		z-index: 9999;
	}

	.buns_item {
		display: flex;
		padding: 80rpx 0 50rpx 0;
		justify-content: space-around;
	}

	.but_css {
		background: #22C572;
		width: 40%;
		padding: 20rpx;
		color: #fff;
		text-align: center;
		border-radius: 20rpx;
	}

	/deep/.u-radio-group {
		flex-direction: row-reverse;
	}

	.no-boder {
		border: 0;
	}

	.textarea {
		background: #F9F9FA;
		border: 1px solid #EEEEEE;
	}

	.u-page__item__slot-icon {
		width: 20px;
		height: 20px;
	}
</style>
