<template>
	<view>
		<view class="banner"><image src="../../static/my2.png" mode="widthFix"></image></view>
		<view class="ccn" style="margin-top: -150px;">
			<view class="cn">
				<view class="rows">
					<view class="row" @click="go('/pages/index/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">委托单列表</view>
						</view>
					</view>
					<view class="row" @click="go('/pages/model/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备借还记录</view>
						</view>
					</view>
					<!--
					<view class="row" @click="go('/pages/test/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备借还记录</view>
						</view>
					</view>
					<view class="row" @click="go('/pages/test/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备借还记录</view>
						</view>
					</view>
					<view class="row" @click="go('/pages/model/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备台账</view>
						</view>
					</view>
					<view class="row" @click="go('/pages/test/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备借还记录</view>
						</view>
					</view>
					<view class="row" @click="go('/pages/test/index')">
						<view class="out">
							<view class="ioc" style="background-color: #2196F3;"><text class="icon">&#xe6f3;</text></view>
							<view class="tit omit">设备借还记录</view>
						</view>
					</view>-->
					<view class="clear"></view>
				</view>
			</view>
		</view>
		<view class="ccn">
			<view class="cn">
				<view class="lable">
					<text>审批中心</text>
					<text class="more" @click="go('/pages/home/list')">更多></text>
				</view>
				<view class="list">
					<view class="tab"><u-tabs :list="tab" :current="current" @click="click"></u-tabs></view>
					<view class="spitem" v-for="(item, index) in list" :key="index" @click="detail(item.formId, item.docId)">
						<view class="title">
							<text class="icon">&#xe602;</text>
							<text class="tit">[{{ item.flowName }}]</text>
							<view class="dev">{{ item.subject.summaryText }}</view>
						</view>
						<view class="desc">
							<view class="name">{{ item.initiator }}</view>
							<view class="bm omit">{{ item.initiatorDept }}</view>
							<view class="date">{{ item.actionTime }}</view>
						</view>
						<view class="clear"></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			user: {},
			current: 0,
			tab: [{ name: '待审批', badge: { value: 5 } }, { name: '已审批' }],
			list: [{}, {}, {}, {}, {}]
		};
	},
	onShow() {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: this.http.urls.myPending,
				success: res => {
					this.list = res.data.data.datas;
					this.list.forEach(item => {
						item.subject=JSON.parse(item.subject);
						item.subject.summaryText=item.subject.summaryText.replace(/\r|\n/ig,"");
					});
				}
			});
		},
		//跳转
		go(url) {
			uni.navigateTo({ url: url });
		},
		click(e) {},
		//跳转到详情
		detail(formId, id) {
			uni.navigateTo({
				url: '/pages/index/detail?id=' + id + '&ste=1&formId=' + formId
			});
		},
		//退出登录
		exit() {
			uni.showModal({
				title: '提示',
				content: '确定退出登录?',
				success: res => {
					if (res.confirm) {
						uni.removeStorageSync('user');
						this.user = {};
					}
				}
			});
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.getData();
			uni.stopPullDownRefresh();
		}, 1000);
	}
};
</script>

<style lang="scss">
page {
	background-color: #f1f0f1;
}
.banner {
	image {
		width: 100%;
	}
}
.ccn {
	padding: 13px;
	overflow: hidden;
	position: relative;
	margin-top: -15px;
	.cn {
		background-color: white;
		border-radius: 8px;
		padding: 10px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		.rows {
			margin-top: 3%;
			.row {
				float: left;
				width: 33.33%;
				text-align: center;
				.out {
					padding: 5px;
					.ioc {
						width: 40px;
						height: 40px;
						background-color: red;
						border-radius: 40%;
						text-align: center;
						margin: 0 auto;
						line-height: 40px;
						.icon {
							font-size: 19px;
							color: white;
						}
					}
					.tit {
						font-size: 14px;
						margin-top: 5px;
						color: #848484;
					}
				}
			}
		}
		.lable {
			font-size: 17px;
			color: $font-c;
			font-weight: bold;
			.more {
				float: right;
				font-size: 14px;
				font-weight: normal;
				color: #848484;
			}
		}
		.list {
			.tab {
				background-color: aliceblue;
				border-radius: 3px;
				margin-top: 7px;
			}
		}
	}
}
</style>
