<template>
	<u-mask class="productModal" :show="isShow" :mask-click-able="false">
		<view class="product-con">
			<view class="product-main">
				 <view class="p-title">
					 <text>[{{infoData.shelfPlaceCode}}]</text> {{infoData.productCode}}
				 </view>
				 <view class="p-info flex align_center">
					 <text>产品名称</text> {{infoData.productEntity.productName}}
				 </view>
				 <view class="p-info flex align_center">
				 	<text>单位</text> {{infoData.productEntity.unit}}
				 </view>
				 <view class="p-info flex align_center">
				 	<text>可用库存</text> {{infoData.qty}}
				 </view>
				 <view class="p-info flex align_center">
				 	<text>冻结库存</text>
					<view class="flex align_center">
						{{infoData.freezeQty}}
						<view>
							<text>冻结明细</text>
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
				 </view>
				 <view class="p-info flex align_center">
				 	<text>结算价格</text>
					<view>
						<text>{{infoData.price}}</text> 元
					</view>
				 </view>
				 <view class="p-info flex align_center">
				 	<text>实际可用库存</text>
					<view>
						<u-number-box v-model="infoData.checkQty" :index="infoData.id" :min="0" :max="infoData.maxQty||999999"></u-number-box>
					</view>
				 </view>
			</view>
			<view class="product-footer">
				<view class="button-cancel" @click="isShow=false">取消</view>
				<view class="button-confirm" @click="handleConfirm">确定</view>
			</view>
		</view>
	</u-mask>
</template>

<script>
	import { stockCheckDetailSave } from '@/api/stockCheck'
	export default {
		props: {
			openModal: { //  弹框显示状态
				type: Boolean,
				default: false
			},
			infoData: {
				tyoe: Object,
				default: ()=>{
					return null
				}
			},
		},
		data() {
			return {
				isShow: this.openModal, //  是否打开弹框
			}
		},
		methods: {
			// 确认
			handleConfirm(){
				this.$emit('addProduct',{
					shelfSn: this.infoData.shelfSn,
					shelfPlaceSn: this.infoData.shelfPlaceSn,
					shelfPlaceCode: this.infoData.shelfPlaceCode,
					productCode: this.infoData.productCode,
					stockQty: this.infoData.stockQty,
					freezeQty: this.infoData.freezeQty,
					checkQty: this.infoData.checkQty,
				})
			},
		},
		watch: {
			//  父页面传过来的弹框状态
			openModal (newValue, oldValue) {
				this.isShow = newValue
			},
			//  重定义的弹框状态
			isShow (newValue, oldValue) {
				if (!newValue) {
					this.$emit('close')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.productModal{
		width: 100%;
		height: 100%;
		.text-c{
			text-align: center;
		}
		.product-con{
			width: 78%;
			margin: 30vh auto 0;
			background-color: #fff;
			border-radius: 24upx;
			.product-main{
				padding: 60upx 20upx 50upx;
				max-height: 50vh;
				overflow: auto;
				.p-title{
					padding: 20upx 30upx;
					background-color: #999;
					border-radius: 60upx;
				}
				.p-info{
					padding: 20upx 30upx;
					> text{
						width: 100upx;
						color: #999;
					}
					> view{
						flex-grow:1;
					}
				}
			}
			.product-footer{
				font-size: 30upx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				text-align: center;
				border-top: 1upx solid #E5E5E5;
				.button-cancel{
					color: #999;
					border-right: 1upx solid #E5E5E5;
					flex-grow: 1;
					padding: 20upx 0;
				}
				.button-confirm{
					color: #2A86F4;
					flex-grow: 1;
					padding: 20upx 0;
				}
			}
		}
	}
</style>
