<template>
	<view class="query-wrap">
		<view class="title-cont">
			<view class="search-view">
				<uni-easyinput prefixIcon="search" :value="value" placeholder="请输入出库订单号"
					@input="input">
				</uni-easyinput>
			</view>
			<v-tabs v-model="index" :tabs="tabList" @change="changeTab" :scroll="false"></v-tabs>
		</view>
		<z-paging ref="paging" @query="queryList" v-model="dataList" :use-page-scroll="true">
			<view class="inner-item" v-for="(item,index) in dataList" :key="index" @click="itemDetails(item)">
				<view class="item-stats">
					<span v-if="item.stas == 'A'">已确认待拣货</span>
					<span v-if="item.stas == 'B'">已出库待配送</span>
					<span v-if="item.stas == 'C'">配送中</span>
					<span v-if="item.stas == 'D'">已配送</span>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							出库订单号:
						</view>
						<view class="shuo-unit">
							{{item.stooutId}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							来源订单号:
						</view>
						<view class="shuo-unit">
							{{item.soucId}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							出库品种数:
						</view>
						<view class="shuo-cont">
							{{item.stoCnt}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							出库总数量:
						</view>
						<view class="shuo-cont">
							{{item.devCnt}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							出库类型:
						</view>
						<view class="shuo-cont">
							{{item.stoType}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							目标位置
						</view>
						<view class="shuo-cont">
							{{item.deptName}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							出库人:
						</view>
						<view class="shuo-cont">
							{{item.crteUsrName}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							出库时间:
						</view>
						<view class="shuo-cont">
							{{forMatTime(item.crteTime)}}
						</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	import {
		debounce
	} from 'lodash';
	import moment from "moment";
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin.js';
	export default {
		mixins: [ZPMixin],
		data() {
			return {
				index: 0,
				value: "",
				dataList: [],
				inputVal: "",
				codeVal: "",
				confirmVal: "",
				changeVal: "",
				classes: [],
				listData: [],
				tabList: ['待配送', '已配送'],
				valueList: 0,
				beforeClose: true,
				datetimesingle: [],
			}
		},
		computed: {
			 ...mapState(['houseSelectData'])
		},
		onShow() {
			uni.$once('update', function(data) {
				// uni.redirectTo({
				// 	url: '/pages/grounding/grounding' //写你的路径
				// });
			})
		},
		mounted() {

		},
		methods: {
			...mapActions(['getDeliveryData']),
			...mapMutations(['setAcceptDetaData']),
			async queryList(pageNo, pageSize) {
				await this.getDeliveryData({
					pam: {
						current: pageNo,
						size: pageSize,
						stooutId: this.value,
						type: this.index == '0' ? 'waitDev' : 'delvSuc',
						pdaType: "pda",
						soucStroomId: this.houseSelectData.houseId
					},
					that: this
				});
			},
			//日期格式化
			forMatTime(time) {
				return moment(time).format("YYYY-MM-DD");
			},
			//跳转配送详情	 
			itemDetails(item) {
				uni.setStorage({
					key: 'deliveredDetail',
					data: item
				});
				uni.navigateTo({
					url: '/pages/deliveredDetail/index',
					success: function(res) {
						console.log(res, "res")
					}
				});
			},
			input: debounce(function(e) {
				this.value = e;
				this.getDeliveryData({
					pam: {
						stooutId: this.value,
						type: this.index == '0' ? 'waitDev' : 'delvSuc'
					},
					that: this
				});

			}, 500),
			changeTab(index) {
				this.index = index;
				this.$refs.paging.reload();
			},
		},
		watch: {

		}

	}
</script>

<style lang="scss" scoped>
	.query-wrap {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background-color: #F1F1F1;
		overflow-y: scroll;
		overflow-x: hidden;

		.time-view {
			height: 350rpx;
			background-color: #fff;
			padding: 50rpx 50rpx 0 50rpx;
			box-sizing: border-box;

			.btn-view {
				width: 100%;
				height: 100rpx;
				margin-top: 100rpx;
				display: flex;
				justify-content: space-around;
			}
		}

		.title-cont {
			padding-top: 10rpx;
			width: 100%;
			background-color: #fff;

			.search-view {
				width: 100%;
				height: 100rpx;
				display: flex;
				align-items: center;
				padding: 0rpx 20rpx 0rpx 20rpx;
				box-sizing: border-box;

				.filter-text {
					width: 72rpx;
					height: 50rpx;
					line-height: 50rpx;
					color: rgba(1, 169, 146, 1);
					font-size: 36rpx;
					font-family: PingFangSC-bold;
					padding-left: 20rpx;
				}
			}
		}
	}

	uni-page-body {
		width: 100%;
		height: 100%;
	}
</style>