<template>
	<u-cell-group>
	    <u-cell
	        center
			isLink
			v-for="item in list"
			:key="item.id"
			:title="item.allocationLinkageOutNo"
			@click="toStockOut(item)"
	    >
		<view slot="label">
			<view class="u-kh">{{item.putTenantName}}</view>
			<view class="u-time">调拨类型：{{item.allocationTypeDictValue}}</view>
			<view class="u-time">创建时间：{{item.createDate}}</view>
		</view>
		<view slot="value">
			<text v-if="item.state=='WAIT_OUT_WAREHOUSE'" class="u-text" :style="{color:'#00aaff'}">出库检货</text>
			<text v-else class="u-text" :style="{color: '#999'}">{{item.stateDictValue}}</text>
		</view>
		</u-cell>
		<view v-if="list.length==0&&status != 'loading'">
			<u-empty :iconSize="60" text="暂无连锁调出单" :marginTop="100" mode="history"></u-empty>
		</view>
		<view style="padding: 30rpx 0;">
			<u-loadmore :status="status" />
		</view>
	</u-cell-group>
</template>

<script>
	import { allocLinkageOutList } from '@/config/api.js'
	export default{
		data(){
			return {
				list: [],
				pageSize: 10,
				pageNo: 1,
				total: 0,
				status: 'loadmore'
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			if(this.$store.state.vuex_isRefash){
				this.pageNo = 1
				this.getList()
				this.$store.state.vuex_isRefash = false
			}
		},
		methods:{
			getList(){
				this.status = 'loading'
				allocLinkageOutList({pageSize:this.pageSize,pageNo:this.pageNo, state: 'WAIT_OUT_WAREHOUSE'}).then(res => {
					if(res.status == 200){
						const list = res.data.list
						this.total = res.data.count
						if(this.pageNo == 1){
							this.list = list
						}else{
							this.list = this.list.concat(list)
						}
						
						if(this.list.length < this.total){
							this.status = 'loadmore'
						}else{
							this.status = 'nomore'
						}
					}
				})
			},
			// 出库
			toStockOut(item){
				// 待出库
				if(item.state=='WAIT_OUT_WAREHOUSE'){
					uni.navigateTo({
						url: "/pages/stockOut/chainTransferOut/index?id="+item.id+"&allocationLinkageOutSn="+item.allocationLinkageOutSn
					}) 
				}else{
					// 查看详情
					uni.navigateTo({
						url:"/pages/stockOut/chainTransferOut/viewDetail?allocationLinkageOutSn="+item.allocationLinkageOutSn+"&id="+item.id
					})
				}
			},
			onReachBottom(){
				const pageNums = Math.ceil(this.total / this.pageSize)
				if(this.pageNo <= pageNums){
					this.pageNo = this.pageNo + 1
					this.getList()
				}else{
					this.status = 'nomore'
				}
			}
		}
	}
</script>

<style lang="scss">
	.u-time{
		color: $uni-text-color-grey;
		font-size: 30upx;
	}
	.u-kh{
		font-size: 34upx;
	}
</style>