<template>
	<view>
		<view class="search" v-if="show">
			<u-divider text="展开搜索"></u-divider>
			<u--input v-model="param.xx" placeholder="输入条件" class="input" clearable></u--input>
			<u--input v-model="param.xx" placeholder="输入条件" class="input" clearable></u--input>
			<u--input v-model="param.xx" placeholder="输入条件" class="input" clearable></u--input>
			<u--input v-model="param.xx" placeholder="输入条件" class="input" clearable></u--input>
			<u--input v-model="param.xx" placeholder="输入条件" class="input" clearable></u--input>
			<view class="flex">
				<view class="f"><button class="btn c" @click="clear()">重置</button></view>
				<view class="f"><button class="btn" @click="search()">搜索</button></view>
			</view>
		</view>
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item.id)">
				<view class="title">
					<text class="tv">{{ item.items.__DkLB41tkDZoSeXdzjNd.value }}</text>
					<text class="icon">&#xe631;</text>
					<view class="clear"></view>
				</view>
				<view class="con">
					
					
					<view class="it">
						<view class="label">计量编号：</view>
						<view class="name">{{ item.items.__To3ldfLqdpnLNUIjGvb.value }}</view>
					</view>
					
					<view class="it">
						<view class="label">借用人部门：</view>
						<view class="name">{{ item.items.__ISOkPJeTwFomTO3JEFR.value }}</view>
					</view>
					<view class="it">
						<view class="label">借用人：</view>
						<view class="name">{{ item.items.__UAsr8UEjHBujd7oCVfb.value }}</view>
					</view>
					
					
					
					<view class="tag" v-if="item.items.__2ryB7XjxtrdtU40P48c.value==0">借用待审</view>
					<view class="tag" v-else-if="item.items.__2ryB7XjxtrdtU40P48c.value==1">借用中</view>
					<view class="tag" v-else-if="item.items.__2ryB7XjxtrdtU40P48c.value==2">已归还</view>
					<view class="tag" v-else-if="item.items.__2ryB7XjxtrdtU40P48c.value==-1">归还待审</view>
					<view class="tag" v-else-if="item.items.__2ryB7XjxtrdtU40P48c.value==3">驳回</view>
					<view class="tag" v-else-if="item.items.__2ryB7XjxtrdtU40P48c.value==81">终止</view>
					<view class="tag" v-else></view>
				</view>
			</view>
			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
		</view>
		<view class="footer">
			<view class="flex">
				<view class="f"><button class="btn br" @click="go('/pages/model/return?op=设备归还')">归还设备</button></view>
				<view class="f"><button class="btn br" @click="go('/pages/model/borrowing?op=设备借用')">借用设备</button></view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			param: { appId: '__gAPYBW4YxB3UePM3lqO', containTitle: '设备借还台账', opentarget: 'detail', viewId: '__NOtUm3wgeNBBmv8mhK3', _currpage: 1 },
			
			list: [],
			show: false,
			loadMore: true
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: this.http.urls.borrowing_list,
				data: this.param,
				method: 'POST',
				loading: 'false',
				success: res => {
				console.log('gfgh===1111' + JSON.stringify(res));
				let totalPage = res.data.data.row_count < 10 ? 1 : res.data.data.row_count / 10;
				this.loadMore = totalPage > this.param._currpage ? true : false;
				res.data.data.data.forEach(item => {
					this.list.push(item);
				});
				}
			});
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		},
		//跳转到详情
		detail(id) {
			uni.navigateTo({
				url: '/pages/model/detail?ste=1&id=' + id
			});
		},
		go(url) {
			uni.navigateTo({
				url: url
			});
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	},
	//展开搜索
	onNavigationBarButtonTap() {
		this.show = !this.show;
	}
};
</script>

<style lang="scss">
page {
	background-color: #f2f3f5;
}
.list {
	padding: 0px 15px 80px 15px;
	.item {
		margin-top: 10px;
		background-color: white;
		border-radius: 5px;
		overflow: hidden;
		padding-bottom: 5px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		.title {
			border-bottom: 1px solid #efefef;
			padding: 12px;
			color: $font-c1;
			.tv {
				float: left;
				width: 90%;
			}
		}
		.con {
			position: relative;
			.it {
				font-size: 14px;
				padding: 5px 12px 5px 12px;
				.label {
					float: left;
					color: #969696;
					width: 90px;
					text-align: right;
				}
				.name{
					color: $font-c;
				}
			}
			.tag {
				position: absolute;
				top: 10%;
				right: 0px;
				padding: 3px 10px;
				background-color: #F44336;
				color: white;
				font-size: 14px;
				border-radius: 15px 0px 0px 15px;
			}
		}
	}
}
.br {
	border-radius: 25px;
}
</style>
