<template>
	<view>
		<view class="tabs">
			<u-tabs :list="tab_list" :is-scroll="false" :current="current" bg-color="#f6f6f6" active-color="#11D189" @change="tabsChange"></u-tabs>
		</view>
		<swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}" 
			:current="current" @change="swiperChange">
			<swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
				<scroll-view class="lf-w-100 lf-h-100 lf-p-l-32 lf-p-r-32 lf-border-box" :scroll-y="true">
					<view class="card" v-for="(item, index) in tabItem.list" :key="item.id" @click="$url('/pages/canteen/delivery/detail?id='+ item.id)">
						<view class="lf-row-between item">
							<view class="lf-color-gray">申请人</view>
							<view class="lf-color-black">{{ item.o_name }}</view>
						</view>
						<view class="lf-row-between item">
							<view class="lf-color-gray">申请时间</view>
							<!-- todo 申请时间和种类 -->
							<view class="lf-color-black">{{ item.o_sn }}</view>
						</view>
						<view class="lf-row-between item">
							<view class="lf-color-gray">商品种类</view>
							<view class="lf-color-black">8类</view>
						</view>
						<view class="lf-row-between item">
							<view class="lf-color-gray">订单状态</view>
							<view class="quoted-price">{{ item.state }}</view>
						</view>
					</view>
					<view class="loading-more">
						<text v-if="tabItem.list.length" :class="{'loading-more-text': tabItem.loading_class}">{{ tabItem.loading_text }}</text>
						<lf-nocontent v-else class="lf-m-t-50"></lf-nocontent>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				current: 0,
				tab_list: [{
					name: '全部',
					loading_class: true,
					loading_text: '正在加载中...',
					page: 1,
					isPage: true,
					list: []
				},{
					name: '申请中',
					loading_class: true,
					loading_text: '正在加载中...',
					page: 1,
					isPage: true,
					list: []
				},{
					name: '已出库',
					loading_class: true,
					loading_text: '正在加载中...',
					page: 1,
					isPage: true,
					list: []
				}],
				page_size: 10,
				windowHeight: 0
			}
		},
		onLoad(){
			this.windowHeight = uni.getSystemInfoSync().windowHeight;
			this.getData();
		},
		methods: {
			getData(){
				this.$http(this.API.API_CANTEEN_WAREHOUSEOUTLIST).then(res => {
					console.log("getData", res);
					this.tab_list[this.current].list = res.data.list || [];
				});
			},
			tabsChange(current){
				this.current = current;
			},
			swiperChange(event){
				this.current = event.detail.current;
			}
		}
	}
</script>

<style>
	page{
		background-color: #f6f6f6;
	}
</style>
<style lang="scss" scoped="scoped">
	.card{
		width: 100%;
		height: max-content;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;
		.item{
			padding: 20rpx 0;
			box-sizing: border-box;
			width: 100%;
			border-bottom: 1rpx solid #E5E5E5;
			font-size: 28rpx;
			&:last-child{
				border-bottom: none;
			}
		}
		// 已报价，等待审核
		.quoted-price{
			color: #777777;
		}
		// 等待报价
		.wait{
			color: #1833F2;
		}
		// 已通过审核
		.passed{
			color: #0BCE5F;
		}
		// 报价被拒绝
		.refuse{
			color: #FF0000;
		}
	}
</style>
