<template>
	<u-mask class="productModal" :show="isShow" :mask-click-able="false">
		<view class="product-con" v-if="infoData">
			<view class="product-head">
				<view class="shelfName flex align_center"><text></text>{{infoData.shelfName}}</view>
				<view>
					此货架存在以下未取货的订单，导致库存被冻结，为方便盘点，请先联系修理厂处理
				</view>
			</view>
			<view>
				<scroll-view class="product-main" scroll-y>
					<view>
						<view class="p-item" v-for="item in list" :key="item.id">
							 <view class="flex align_center">
								 <view class="l-no"><text>{{item.shelfPlaceCode}}</text>{{item.productCode}}</view>
								 <view class="r-nums">冻结库存：<text>{{item.totalQty}}</text> 个</view>
							 </view>
							 <view class="p-name">{{item.productName}}</view>
						</view>
					</view>
				</scroll-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 { queryWaitListByShelfSn } from '@/api/stockCheck'
	export default {
		props: {
			openModal: { //  弹框显示状态
				type: Boolean,
				default: false
			},
			infoData: {
				tyoe: Object,
				default: ()=>{
					return null
				}
			},
		},
		data() {
			return {
				isShow: this.openModal, //  是否打开弹框
				list: []
			}
		},
		methods: {
			// 确认
			handleConfirm(){
				 this.$emit("ok")
				 this.isShow = false
			},
			// 获取列表数据
			getList(){
				queryWaitListByShelfSn({shelfSn: this.infoData.shelfSn}).then(res => {
					if(res.status == 200){
						this.list = res.data||[]
					}
				})
			}
		},
		watch: {
			//  父页面传过来的弹框状态
			openModal (newValue, oldValue) {
				this.isShow = newValue
			},
			//  重定义的弹框状态
			isShow (newValue, oldValue) {
				if (!newValue) {
					this.$emit('close')
				}else{
					this.getList()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.productModal{
		width: 100%;
		height: 100%;
		.product-head{
			font-size: 26rpx;
			padding: 20upx 30upx 15upx;
			border-bottom: 2rpx solid #eee;
			color: #666;
			.shelfName{
				width: 100%;
				flex-grow: 1;
				font-weight: bold;
				font-size: 26rpx;
				color: #333;
				text{
					display: block;
					height: 30rpx;
					width: 6rpx;
					background: #0485F6;
					margin-right: 10rpx;
					border-radius: 10rpx;
				}
			}
		}
		.product-con{
			width: 600rpx;
			margin: 16vh auto 0;
			background-color: #fff;
			border-radius: 24upx;
			position: relative;
			.product-main{
				padding: 0 30upx 20upx 30upx;
				font-size: 24upx;
				height: 40vh;
				width: 540rpx;
				.p-item{
					border-bottom: 2rpx solid #eee;
					padding: 15upx 0;
					&:last-child{
						border: 0;
					}
					> view{
						justify-content: space-between;
						&:first-child{
							margin-bottom: 10upx;
							.l-no{
								text{
									background-color: #eee;
									padding: 0 10upx;
									border-radius: 10upx;
									margin-right: 15upx;
								}
							}
							.r-nums{
								color: #999;
								text{
									color:red;
								}
								font-size: 22upx;
							}
						}
					}
					.p-name{
						font-size: 24upx;
						text-overflow: ellipsis;
						overflow: hidden;
						white-space: nowrap;
					}
				} 
			}
			.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>
