<template>
	<view>
		<view class="uni-list">
			<block v-for="(item, index) in listData" :key="index">
				<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="goDetail(item.requisitionCode)">
					<view class="uni-media-list">
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top" style="font-size:18px;"> {{item.requisitionName}} </view> 
							<view style="font-size:13px;" class="uni-media-list-text-body">{{item.requisitionReason.substring(0,30)}}</view>
							<view class="uni-media-list-text-bottom"> 
								<text>申请人:{{item.person}}</text>
								<text>{{item.requisitionDate.substring(0,10)}}</text>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view style="bottom: 15px;right:10px;position: fixed;z-index: 50;">
			<router-link to="/pages/template/requisitionadd/requisitionadd" style="text-decoration: none;" title="签证申请添加">
				<uni-icons type="plus-filled" size="80" color="#5678FE"></uni-icons>
			</router-link>
		</view>
		<uni-load-more :status="status" :icon-size="16" :content-text="contentText" />
	</view>
</template>

<script>
	import {
		getUnit,
		getUnitUser
	} from "@/common/api/commonApi.js";
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		GetRequisitionList
	} from "@/common/api/requisitionApi.js";

	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				listData: [],
				last_id: '',
				reload: false,
				status: 'more',
				adpid: '',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				}
			};
		},
		onLoad() {
			console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);
			this.adpid = this.$adpid;

			//this.getList();
		},
		onPullDownRefresh() {
			this.reload = true;
			this.last_id = '';

			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		created: function() {
			this.getList();
		},
		methods: {

			getList() {
				let that = this;
				let where='1=1 and projectcode=\''+this.$store.state.projectCode+'\'';
				GetRequisitionList(where).then((res) => {
					console.info(res);
					res.forEach(function(item, index, array) {
						that.$set(that.listData, index, item);
					});
					console.info(that.listData);
				});
			},
			goDetail: function(id) {
				console.info('godetail');
				console.info(id);
			
				uni.navigateTo({
					// requisitiondetail
					url: '../requisitiondetail/requisitiondetail?id=' + id
				});
			},
			
		}
	};
</script>

<style scoped>
	.uni-media-list-body {
		height: auto;		
		justify-content: space-around;
	}

	.uni-media-list-text-top {
		 
		height:35px;
		line-height: 35px;
		font-size: 15rpx;
		font-weight: 500;
		letter-spacing:1px;
		overflow: hidden;
	}
    .uni-media-list-text-body{
		 
		flex-direction: row;		
		height:50px;
		font-size: 13px;
		color: #8f8f94;
		letter-spacing:1px;
	}
	.uni-media-list-text-bottom {
		display: flex;
		justify-content: space-between;
		height:35px;
		line-height: 35px;
		font-size: 13px;
		color: #8f8f94;
		letter-spacing:1px;
		padding-bottom: 0;
	}
</style>
