<template>
	<u-popup v-model="isShow" mode="bottom" height="800" border-radius="25">
		<view class="head u-flex u-row-between">
			<text>已选产品</text>
			<text @click="clearAllList">清空列表</text>
		</view>
		<scroll-view scroll-y class="scroll-view" v-if="list.length>0">
			<view class="partList-list-box" v-for="(con,i) in list" :key="con.id">
				<view class="product flex align_center">
					<view class="checkbox" @click="clearList(con.id,i)">
						<u-icon name="close-circle" color="#999" size="40"></u-icon>
					</view>
					<view class="checkboxRight flex align_center flex_1">
						<view class="pimgs">
							<u-image :src="con.productImageUrl?con.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
						</view>
						<view class="pinfo">
							<view class="pname">
								<text>{{con.shelfPlaceCode}}</text>
								{{con.productCode}}
							</view>
							<view class="productName u-line-1">
								{{con.productName}}
							</view>
							<view class="ptxt flex align_center">
								<view>
									最大库容
									<text class="pnums">{{con.maxQty}}</text>
								</view>
								<view>
									/货架库存
									<text class="pnums">{{con.qty}}</text>
								</view>
								<view>
									/滞销
									<text class="pnums">{{con.unsalableDays && con.unsalableDays == 0 ?'--天':con.unsalableDays}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="ptools flex align_center justify_between">
					<view class="ptools_l u-flex">
						<view v-if="con.replenishBillQty && con.replenishBillQty!=0">
							补货在途
							<text class="pnums">{{con.replenishBillQty}}</text>
						</view>
						<view v-if="con.recallBillQty && con.recallBillQty!=0">
							{{con.replenishBillQty && con.replenishBillQty!=0 ? '/':''}}调回在途
							<text class="pnums">{{con.recallBillQty}}</text>
						</view>
					</view>
					<view class="pcurnums flex align_center">
						<text>调回数量</text>
						<view class="u-ninput"><u-number-box color="#000" :input-height="60" bg-color="#fff" v-model="con.confirmQty" :min="1" :max="con.qty" @minus="minus" @plus="plus" @change="change"></u-number-box></view>
					</view>
				</view>
			</view>
		</scroll-view>
		<u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="200" text="暂无选中回调单" img-width="120" v-else></u-empty>
	</u-popup>
</template>

<script>
	export default {
		props: {
			detailShow: { //  弹框显示状态
				type: Boolean,
				default: false
			},
			chooseData:{
				type: Array,
				default:()=>[]
			}
		},
		data() {
			return {
				isShow:this.detailShow,
				list:[]
			}
		},
		methods: {
			clearList(id,i){
				this.list.splice(i,1);
				this.$emit("clearList",id)
				 if(this.list.length == 0){
					  this.$emit('close')
				 }
			},
			clearAllList(){
				this.list = [];
				 this.$emit("clearAllList")
				 this.$emit('close')
			},
			
			minus(){
				this.$emit("changeNumRecount")
			},
			plus(){
				this.$emit("changeNumRecount")
			},
			change(){
				this.$emit("changeNumRecount")
			}
		},
		watch: {
			//  父页面传过来的弹框状态
			detailShow (newValue, oldValue) {
				this.isShow = newValue
			},
			//  重定义的弹框状态
			isShow (newValue, oldValue) {
				if (!newValue) {
					this.$emit('close')
				}else{
					this.list = this.chooseData
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.head{
		width: 100%;
		box-sizing: border-box;
		padding:30rpx 20rpx;
		background: #e0e0e0;
		text{
			&:first-child{
				font-weight: bold;
			}
		}
	}
	.scroll-view{
		height: 584rpx;
	}
	.partList-list-box {
		padding: 20rpx;
		border-bottom: 2rpx solid #f5f5f5;
		&:last-child {
			border: 0;
		}
		.product {
			flex-grow: 1;
			.checkbox {
				width: 60rpx;
			}
			.checkboxRight{
				width: calc(100% - 60rpx);
			}
			.pinfo {
				width: calc(100% - 148rpx);
				flex-grow: 1;
				padding-left: 20rpx;
				.pname {
					font-size: 32rpx;
					color: #191919;
					margin-bottom: 10rpx;
					text {
						font-weight: normal;
						margin-right: 6rpx;
						padding: 0 10rpx;
						background: rgba(3, 54, 146, 0.15);
						border-radius: 100rpx;
						color: #033692;
						font-size: 28rpx;
					}
				}
				.productName{
					width: 100%;
					font-size: 32rpx;
					color: #191919;
					font-weight: bold;
					margin:10rpx 0;
				}
				.pno {
					background-color: rgba(3, 54, 146, 0.15);
					border-radius: 50rpx;
					padding: 0 20rpx;
					color: #033692;
					font-size: 24rpx;
					margin-right: 10rpx;
				}
				.ptxt {
					font-size: 24rpx;
					color: #999;
					.pnums {
						color: #222;
						padding: 0 4upx;
					}
				}
			}
		}
		.ptools {
			margin-top: 30rpx;
			margin-left: 60rpx;
			.ptools_l{
				font-size: 24rpx;
				color: #999;
				.pnums {
					color: #ff5500;
					padding: 0 4rpx;
				}
			}
			.pcurnums {
				> text {
					font-size: 24rpx;
					color: #999;
					margin-right: 20rpx;
				}
			}
			.u-ninput {
				border: 2rpx solid #eee;
				border-radius: 50rpx;
				padding: 0 6rpx;
			}
			/deep/ .u-icon-disabled {
				background: #fff !important;
			}
			/deep/ .u-number-input {
				margin: 0 0;
				border: 2rpx solid #eee;
				border-top: 0;
				border-bottom: 0;
			}
			/deep/ .u-icon-plus,
			/deep/ .u-icon-minus {
				border-radius: 50rpx;
			}
		}
	}
</style>