<template>
	<view class="content">
		<!-- 自定义导航 -->
		<view class="navbar-box">
			<u-navbar title="物资出库" :safeAreaInsetTop="true" @leftClick="leftClick">
			</u-navbar>
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view v-for="item in dataList" :key="item.id">
				<u-card :title="'申请单号:'+item.id" padding="20">
					<view class="" slot="body">
						<view class="u-body-item u-p-t-0">
							<view class="u-m-b-10">申请机构：杨慧街道社区</view>
							<view class="u-m-b-10">申请物资：医用湿巾</view>
							<view class="u-m-b-10 u-tips-color">审批人：东东</view>
							<view class="text-color-red">申请数量：500箱</view>
						</view>
					</view>
					<view class="u-flex u-row-between" slot="foot">
						<view class="time">2022/12/06</view>
						<u-button type="success" size="medium" @click="goPutOut(item)" style="margin: 0;">去出库</u-button>
					</view>
				</u-card>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			
		},
		data() {
			return {
				// 下拉刷新的配置(可选, 绝大部分情况无需配置)
				downOption: {
				},
				// 上拉加载的配置(可选, 绝大部分情况无需配置)
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				// 列表数据
				dataList: [{id:1},{id:2}]
			}
		},
		onLoad() {

		},
		methods: {
			/*上拉加载的回调*/
			upCallback(page) {
				let params ={
					pageNum:page.num,
					pageSize:page.size
				} 
				this.$u.api.areaSearch(params).then(curPageData=>{
					console.log('curPageData',curPageData)
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					// this.mescroll.endSuccess(curPageData.data.total);
					this.mescroll.endBySize(curPageData.data.length, curPageData.data.length);
					//设置列表数据
					if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList=this.dataList.concat(curPageData.data); //追加新数据
				}).catch((err)=>{
					uni.showToast({
						title:'链接失败'
					});
					console.log('err',err)
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
				
			},
			/*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
			reloadList(){
				this.mescroll.resetUpScroll();
			},
			leftClick() {
			   let canNavBack = getCurrentPages();
			     if(canNavBack && canNavBack.length>1) {  
			       uni.navigateBack({  
			         delta: 1  
			       });  
			     } else {  
			       history.back();  
			     }
			},
			goPutOut(item){
				this.$u.route({
					url: 'pages/putout/putoutItem/putoutItem',
					params: {
						id: item.id
					}
				})
				console.log('goPutOut',item)
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
