<template>
	<view class="">
		<view class="detail-content">
			<view class="choose_main">
				<view class="ljh_box">
					<view class="tit_ljh">{{ dataContent.itemCode }}</view>
					<view class="ljh_left desc_ljh">
						<view class="font_xs text_lightblue">{{ dataContent.itemName }}</view>
						<view class="font_xs text_lightblue">{{ dataContent.itemDesc1 }}</view>
					</view>
				</view>
				扫描{{dataContent.scaned}}

				<view class="list_form">
					<view class="uni-container">
						<uni-table style="overflow-x: hidden;">
							<uni-tr>
								<!-- <uni-th width="90"></uni-th>
								<uni-th width="100" align="center">推荐</uni-th>
								<uni-th width="100" align="center">实际</uni-th> -->
								<uni-th width="50"></uni-th>
								<uni-th width="120" align="center">推荐</uni-th>
								<uni-th width="120" align="center">实际</uni-th>
							</uni-tr>
							<uni-tr>
								<uni-th width="50">器具码</uni-th>
								<uni-th width="120" align="center">
									<view class="text_packingCode">
										{{ dataContent.recommendContainerCode }}
									</view>
								</uni-th>
								<uni-th width="120" align="center">
									<view v-if="dataContent.scaned" class="text_packingCode">
										{{ dataContent.containerCode }}
									</view>
								</uni-th>
							</uni-tr>
							<uni-tr>
								<uni-th width="50">数量</text></uni-th>
								<uni-th width="120" align="center">
									<text class="text_black">{{dataContent.recommendQty}}({{dataContent.uom}})</text>
								</uni-th>
								<uni-th width="120" align="center">
									<view v-if="dataContent.scaned"
										style="display: flex;flex-direction: row;justify-content:center;align-items: center;">

										<com-number-box ref="comNumberBox" v-model="dataContent.handledQty"
											:max="99999" :min="0" style='width: 100px;'
											@change="qtyChanged($event,dataContent)">
										</com-number-box>
										<text class="text_black">({{dataContent.uom}})</text>
									</view>
								</uni-th>
							</uni-tr>
						</uni-table>
					</view>
				</view>
			</view>
			<view class="choose_marked" v-if="dataContent.scaned">
				<image src="@/static/image_marked.svg"></image>
			</view>
			<view class="fr" v-if="isShowPacking">
				<button class="btn_single" hover-class="btn_single_after" @click="unPacking(dataContent)">拆箱</button>
			</view>
		</view>
		<comUnPacking ref='comUnPacking'
			@getvalue="getUnPackingCount" title="拆箱" @update="update">
		</comUnPacking>
		<com-message ref="comMessage" @afterCloseCommitMessage='closeCommitMessage()'
			@afterCloseScanMessage='closeScanMessage'></com-message>
	</view>
</template>

<script>
	import comNumberBox from '@/mycomponents/common/comNumberBox.vue';
	import comUnPacking from '@/mycomponents/coms/comUnPacking.vue'
	import comMessage from '@/mycomponents/common/comMessage.vue'
	
	export default {
		name: "",
		components: {
			comNumberBox,
			comUnPacking,
			comMessage
		},
		data() {
			return {};
		},
		// 此处定义传入的数据
		props: {
			dataContent: {
				type: Object,
				value: {}
			},
			isShowPacking: {
				type: Boolean,
				value: false
			},
		},
		methods: {
			update(newCode){
				this.showMessage("生成新的箱码【"+newCode+"】请到PC端打印标签");
			},
			unPacking(item) {
				this.$refs.comUnPacking.openPopup3(item,item.handledQty,item.recommendQty,false);
			},
			qtyChanged(value, item) {
				if (value <= 0) {
					this.showMessage('数量不能小于或等于0')
					item.handledQty = item.defaultHandleQty
					this.$refs.comNumberBox.setValue(item.handledQty);
				} else if (value > item.defaultHandleQty) {
					item.handledQty = item.defaultHandleQty
					this.showMessage('数量不能大于库存数量:' + item.handledQty)
					this.$refs.comNumberBox.setValue(item.handledQty);
				}
			},
			showMessage(message) {
				this.$refs.comMessage.showMessage(message);
			},
		}
	}
</script>

<style>
</style>
