<template>
	<view class="container">
		<view class="content">
			<view class="item">
				<span class="itemLabel">货位名称：</span>
				<span class="itemValue">{{ result.inLocationName }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">商品编号：</span>
				<span class="itemValue">{{ result.goodNo }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">商品名称：</span>
				<span class="itemValue">{{ result.goodName }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">规格：</span>
				<span class="itemValue">{{ result.specifications }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">厂家：</span>
				<span class="itemValue">{{ result.factory }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">产地：</span>
				<span class="itemValue">{{ result.areaCode }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">件装量：</span>
				<span class="itemValue">{{ result.packageQty }} 单位：{{ transUnit(result.unit) }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">拣货数量：</span>
				<span class="itemValue">{{ result.pickCaseQty }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">批号：</span>
				<span class="itemValue">{{ result.batchNo }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">显示效期：</span>
				<span class="itemValue">{{ result.productionDate }} —— {{ result.expiredDate }}</span>
			</view>
			<view class="item">
				<span class="itemLabel">实际数量：</span>
				<span class="itemValue">
					<u-input v-model="value" type="text" :border="true" />
				</span>
			</view>
			<view class="item">
				<span class="itemLabel">冲红数量：</span>
				<span class="itemValue">{{result.pickCaseQty - value}}</span>
			</view>
		</view>
		<view class="footer">
			<u-button type="primary" @click="confirm()">确认冲红</u-button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				result: {},
				value: 0,
				dicOptions: []
			}
		},
		onLoad(e) {
			this.result = JSON.parse(e.list)
			this.getDic()
		},
		methods: {
			getDic() {
				this.$u.api.getByDicType().then(res => {
					this.dicOptions = res.data;
				});
			},
			transUnit(unit) {
				for (let dic in this.dicOptions) {
					if (this.dicOptions[dic].dictValue === unit) {
						return this.dicOptions[dic].dictLabel;
					}
				}
			},
			checkOutPick() {
				this.$u.api.pickingManage.checkOutPick({
					taskType: 0
				}).then(res => {
					if(res.code===200) {
						//  进入索取页面
						if(res.data.pickType===200) {
							// 零货
							this.$u.route({
								url: 'pages/smallStore/index',
								type: 'navigateTo',
								params: {
									list: JSON.stringify(res.data.taskStaticList)
								}
							})
						}
						//进入拣货页面
						if(res.data.pickType===800) {
							// 零货
							this.$u.route({
								url: 'pages/smallStore/picking',
								type: 'navigateTo',
								params: {
									list: JSON.stringify(res.data.businOutPickDTaskVo),
									container: JSON.stringify(res.data.containrList)
								}
							})
						}
						// 进入绑定周转箱页面
						if(res.data.pickType===801) {
							// 零货
							this.$u.route({
								url: 'pages/smallStore/bind',
								type: 'navigateTo',
								params: {
									list: JSON.stringify(res.data.taskAndContainerList)
								}
							})
						}
					}
					
				});
			},
			
			confirm() {
				if(this.value) {
					this.$u.api.pickingManage.orderDetailRed({
						id: this.result.id,
						qty: this.value
					}).then((res)=>{
						if(res.code===200) {
							this.$u.toast('冲红成功')
							this.checkOutPick()
						} else {
							this.$u.toast(res.msg)
						}
					})
				} else {
					this.$u.toast('请输入数量')
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 90%;
		height: calc(100vh - 120rpx);
		margin: 20rpx auto;
		border:0.5px solid #333333
	}
	
	.input {
		width: 90%;
		margin: 20rpx auto;
	}
	.content {
		width: 90%;
		margin: 20rpx auto;
	}
	.item {
		display: flex;
		align-items: center;
		font-size: 28rpx;
		line-height: 50rpx;
		.itemLabel {
			color: #555555;
			width: 160rpx;
			text-align: right;
		}
		.itemValue {
			color: #333333;
		}
	}
	.desktop {
		border-top: 0.5px solid #333333;
		border-left: 0.5px solid #333333;
		display: flex;
		flex-wrap: wrap;
		width: 70%;
		margin: 0 auto;
	}
	.desktopItem {
		width: 50%;
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		height: 140rpx;
		border-bottom: 0.5px solid #333333;
		border-right: 0.5px solid #333333;
	}
	.desktopLabel {
		text-align: center;
	}
	.desktopValue {
		text-align: center;
		color: #0000FF;;
	}
	.footer {
		width: 90%;
		margin: 0 auto;
		margin-top: 40rpx;
		display: flex;
		justify-content: space-between;
	}
</style>