<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.id}}</view>
					</view>
					<view class="row">
						<view class="column-left">标题：</view>
						<view class="column-right">{{item.title}}</view>
					</view>
					<view class="row">
						<view class="column-left">原因：</view>
						<view class="column-right">{{item.reason}}</view>
					</view>
					<view class="row">
						<view class="column-left">项目：</view>
						<view class="column-right">{{item.projectName}}</view>
					</view>					
					<view class="row" >
						<view class="column-left">申请日期：</view>
						<view class="column-right">{{item.createDateStr}}</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/InsertzzSupplierEx/InsertzzSupplierEx'" 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 uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		GetzzSupplierExList
	} 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() {
			
			this.getList();
		},
		methods: {

			getList() {
				let that = this;
				let supplierCode=this.$util.getState(this,'user').supplierCode;
				//let type=this.$util.getQuery("type")-0;
				GetzzSupplierExList(supplierCode).then((res) => {
					console.info(res);
					if(res=="-1"){
						uni.showToast({
							title:'供应商编号不能为空',
							duration:4000,
							icon:'none'
						});
						return;
					}
					if(res=="-2"){
						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>
