<template>
	<view>
		<uni-list>
			<uni-list-item v-for="(item, index) in listData" :key="index" @click="goDetail(item.materialOutCode)" clickable >
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">领料编号：</view>
						<view class="column-right section-title">{{item.materialOutCode}}</view>
					</view>
					<view class="row">
						<view class="column-left">状态：</view>
						<view class="column-right">{{item.statusName}}</view>
					</view>
					<view class="row">
						<view class="column-left">领料类型：</view>
						<view class="column-right">{{item.groupName}}</view>
					</view>
					<view class="row">
						<view class="column-left">调拨人：</view>
						<view class="column-right">{{item.outPersonName}}</view>
					</view>
					<view class="row">
						<view class="column-left">领料日期：</view>
						<view class="column-right">{{item.outDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">工程合同：</view>
						<view class="column-right">{{item.contractName}}</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		<view style="bottom: 15px;right:10px;position: fixed;z-index: 50;">
			<router-link to="/pages/template/MaterialOutAdd/MaterialOutAdd" style="text-decoration: none;" title="领料单添加">
				<uni-icons type="plus-filled" size="80" color="#F26C69"></uni-icons>
			</router-link>
		</view>
		<page-foot :isShow="true" :showIndex="3"></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 {
		GetMaterialOuts
	} from "@/common/api/MaterialInOut.js";

	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				listData: [],
				last_id: '',
				reload: false,
				status: 'more',
                
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				}
			};
		},
		onLoad() {
			console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);
		},
		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 projectcode = that.$util.getState(that,'projectCode');
				let usercode = that.$util.getState(that,'userCode');
				let search = '';
				 
				GetMaterialOuts(projectcode, search).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',id);
				uni.navigateTo({					
					url: '/pages/template/GetMaterialOutDetail/GetMaterialOutDetail?id=' + id
				});
			},
           
		}
	};
</script>

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