<template>
	<view >
		<view class="top_search">
			<u-input v-model="value" type="text" class="search_input" placeholder="请扫描出库条码" @input="handleInput" :border="true" />
		</view>
		<view class="top_title" v-if="result">
			{{result.caseNumSeq===0?'整件':'拼箱'}} {{result.barcodeCode}}
		</view>
		<view class="content" v-if="result">
			<view class="item">
				<span class="item_title">货主：</span>
				<span class="item_value">{{ result.consignorName}}</span>
			</view>
			<view class="item">
				<span class="item_title">单据编号：</span>
				<span class="item_value">{{ result.orderNo}}</span>
			</view>
			<view class="item">
				<span class="item_title">客户名称：</span>
				<span class="item_value">{{ result.companyName}}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">商品编号：</span>
				<span class="item_value">{{ result.goodNo }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">商品名称：</span>
				<span class="item_value">{{ result.goodName}}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">规格：</span>
				<span class="item_value">{{ result.specifications }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">厂家：</span>
				<span class="item_value">{{ result.factory }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">件装量：</span>
				<span class="item_value">{{ result.packageQty }}</span>
				<span class="item_title marginLeft">单位：</span>
				<span class="item_value">{{ transUnit(result.unit) }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">批号：</span>
				<span class="item_value">{{ result.batchNo }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">显示日期：</span>
				<span class="item_value">{{ result.productionDate }}</span>
				<span class="item_value marginLeft">{{ result.expiredDate }}</span>
			</view>
			<view class="item" v-if="result.caseNumSeq===0">
				<span class="item_title">总箱数：</span>
				<span class="item_value">{{ result.totalPackage }}</span>
				<span class="item_title marginLeft">已复核：</span>
				<span class="item_value">{{ result.checkedTotalPackage }}</span>
			</view>
			<view class="item">
				<span class="item_title">整件件数：</span>
				<span class="item_value">{{ result.caseQty }}</span>
				<span class="item_title marginLeft">已复核</span>
				<span class="item_value">{{ result.checkedCaseQty }}</span>
			</view>
			<view class="item">
				<span class="item_title">拼箱数：</span>
				<span class="item_value">{{ result.caseNumSeq }}</span>
				<span class="item_title marginLeft">已复核</span>
				<span class="item_value">{{ result.checkedCaseNumSeq}}</span>
			</view>
			<view class="item">
				<span class="item_title">复核件数</span>
				<span class="item_value">
					<u-input v-model="value1" type="text" class="search_input" placeholder="请扫描条码" :border="true" />
				</span>
			</view>
		</view>
		<view class="footer" v-if="result">
			<u-button size="default" @click="confirm()">复核确认</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				value1: '',
				result: '',
				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;
					}
				}
			},
			confirm() {
				this.$u.api.reviewManage.confirmSearchReviewTask({
					id: this.result.id
				}).then(res=>{
					if(res.code===200) {
						this.$u.toast("复核成功！");
						this.result = ''
						this.value = ''
						this.value1 = ''
					}
				})
			},
			handleInput() {
				console.log(this.value)
				this.loadList()
			},
			loadList() {
				this.$u.api.reviewManage.reviewTaskDetail({
					barcodeCode: this.value,
				}).then(res => {
					console.log(res)
					if(res.code===200) {
						this.result = res.data
					} else {
						this.$u.toast(res.msg);
						this.result = ''
					}
				});
			},
			searchData(val) {
				this.loadList(val);
			}
		}
	}
</script>

<style lang="less" scoped>
	.top_search {
		display: block;
		width: 90%;
		margin: 0 auto;
		margin-top: 30rpx;
	}
	.top_title {
		display: block;
		text-align: center;
		color: #333333;
		font-size: 36rpx;
		margin-top: 30rpx;
	}
	.content {
		width: 90%;
		margin: 0 auto;
		margin-top: 30rpx;
	}
	.marginLeft {
		margin-left: 30rpx;
	}
	.item {
		display: flex;
		align-items: center;
		line-height: 50rpx;
		.item_title {
			width: 120rpx;
			font-size: 24rpx;
			color: #333333;
		}
		.item_value {
			font-size: 24rpx;
			color: #555555;
		}
	}
	.footer {
		width: 70%;
		margin: 0 auto;
		margin-top: 40rpx;
	}
</style>