<template>
	<view class="">
		<uni-popup ref="popup">
			<view class="uni-flex uni-column" style="background-color: white;width: 100%; height:60%;">
				<view class="uni-flex uni-row jus">
					<view class="">
						编辑
					</view>
					<view class="">
						X
					</view>
				</view>

				<view class="">
					箱码 {{dataContent.recommendPackingCode}}
				</view>
				<view class="">
					批次 {{dataContent.recommendLot}}
				</view>
				<receipt-count-edit :packInfo="dataContent" @calcQty='calcQty'></receipt-count-edit>
				<view class="uni-flex uni-row">
					<view class="">
						库位 {{dataContent.handledLocationCode}}
					</view>
					<input placeholder="请输入库位" v-model="locationCode" />
					<button @click="scanLocation()">扫描库位</button>
				</view>
				<view class="uni-flex uni-row">
					<button @click="cancel()">取消</button>
					<button @click="confirm()">确定</button>
				</view>
			</view>
		</uni-popup>
		<win-scan-location ref="scanLocation" @getLocation='getLocationInfo'></win-scan-location>
	</view>
</template>

<script>
	import receiptCountEdit from '../modelCom/receiptCountEdit.vue'
	import winScanLocation from '../../wincom/scanCom/winScanLocation.vue'
	export default {
		components: {
			receiptCountEdit,
			winScanLocation
		},
		data() {
			return {
				count: 0,
				data: {},
				locationCode: ''
			}
		},
		watch: {
			dataContent: {
				handler(newval, oldval) {
					this.data = newval;
					this.count = this.data.handledQty
				},
				immediate: true
			}
		},


		props: {
			title: {
				type: String,
				default: ""
			},
			dataContent: {
				type: Object,
				default: {}
			},
		},
		methods: {
			openScanPopup() {
				this.$refs.popup.open('bottom')
			},
			closeScanPopup() {
				this.$refs.popup.close()
			},
			confirm() {
				this.change();
				this.closeScanPopup();
			},
			cancel() {
				this.closeScanPopup();
			},
			calcQty(count) {
				this.count = count;
			},
			change() {
				this.data.handledQty = this.count;
				this.data.handledLocationCode = this.locationCode;
				this.$emit("change", this.data)
			},
			scanLocation() {
				this.$refs.scanLocation.openScanPopup();
			},
			getLocationInfo(res) {
				if (res != null) {
					this.locationCode = res.code
				} else {
					uni.showToast({
						title: "库位没查到"
					})
				}
			},

		}


	}
</script>

<style>
</style>
