<template>
	<view> 
		<uni-list>
			<uni-list-item v-for="(item, index) in listData" :key="index" @click="goDetail(item.requisitionCode)" clickable>
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">申请单编号：</view>
						<view class="column-right section-title">{{item.requisitionNumber}}</view>
					</view>
					<view class="row">
						<view class="column-left">申请单名称：</view>
						<view class="column-right">{{item.requisitionName}}</view>
					</view>
					<view class="row">
						<view class="column-left">类型：</view>
						<view class="column-right">{{item.changeType}}</view>
					</view>
					<view class="row">
						<view class="column-left">申请人：</view>
						<view class="column-right">{{item.personName}}</view>
					</view>
					<view class="row" >
						<view class="column-left">经办部门：</view>
						<view class="column-right">{{item.unitName}}</view>
					</view>
					<view class="row" >
						<view class="column-left">申请日期：</view>
						<view class="column-right">{{item.requisitionDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">当前状态：</view>
						<view class="column-right">{{item.stateName}}</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		<view style="bottom: 15px;right:10px;position: fixed;z-index: 50;">
			<router-link :to="'/pages/template/requisitionadd/requisitionadd?type='+type" style="text-decoration: none;" title="签证申请添加">
				<uni-icons type="plus-filled" size="80" color="#5678FE"></uni-icons>
			</router-link>
		</view>
		<page-foot :isShow="true" :showIndex="1"></page-foot>
		<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: '',
				type:0,
				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() {
			if(this.$util.getQuery("type")=="1")
			{
				this.type=1;
				uni.setNavigationBarTitle({
					title:'变更申请单'
				});
			}
			else{
				this.type=0;
				uni.setNavigationBarTitle({
					title:'签证申请单'
				});
			}
			this.getList();
		},
		methods: {

			getList() {
				let that = this;
				let projectCode=this.$util.getState(this,'projectCode');
				let type=this.$util.getQuery("type")-0;
				GetRequisitionList(projectCode,type).then((res) => {
					console.info(res);
					if(res=="-1"){
						uni.showToast({
							title:'项目编号或类型为空',
							duration:4000,
							icon:'none'
						});
						return;
					}
					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);
			    let type=this.$util.getQuery("type");
				uni.navigateTo({
					// requisitiondetail
					url: '../requisitiondetail/requisitiondetail?id=' + id
				});
			},
			
		}
	};
</script>

<style scoped lang="scss">
	.uni-list-item{
		border-bottom: $BgColorBlue;
	} 
	
</style>
