<template>
	<view class="container">
		<view class="" v-if="!isScan">
			<view class="flex padding-sm" style="background: #F5E4C2;" v-if="qptipsObj.type">
				<u-icon name="warning-fill" color="#FFA500"></u-icon>
				<view class="" style="color: #ffa500;">
					注意:发出气瓶数{{this.qptipsObj.type}}订单所需数，请确认是否继续配送！
				</view>
			</view>
			<view class="cardCss usuallyCard">
				<view class="flex justify-between" v-for="(item,index) in qpParams" :key="index">
					<view class="flex">
						<view class="">
							<u-image width="50px" height="50px" radius="10" :src="item.image"></u-image>
						</view>
						<view class="flex flex-direction justify-between margin-left-sm">
							<view class="text-bold text-lg">
								{{item.fSpmc || ""}}
							</view>
							<view class="text-sm text-grey">
								{{item.fMs || ""}}
							</view>
						</view>
					</view>
					<view class="flex align-center text-grey">
						X{{item.fSl || ""}}
					</view>
				</view>
			</view>
			<view class="cardCss usuallyCard">
				<u-collapse ref="collapse1" :border="false" :value="qpsf.mpfc.length?['1']:['']">
					<u-collapse-item title="满瓶发出" name="1">
						<view class="flex justify-between align-center" style="margin: 10px 15px 0px 15px;" v-for="(item,index) in qpsf.mpfc"
							:key="index">
							<view class="">
								{{item.code}} | {{item.qpgg}}
							</view>
							<view class="" @click="del(1,index)">
								<u-icon name="trash" size="18"></u-icon>
							</view>
						</view>
					</u-collapse-item>
				</u-collapse>
			</view>
			<view class="cardCss usuallyCard">
				<u-collapse ref="collapse2" :border="false" :value="qpsf.kphs.length?['2']:['']">
					<u-collapse-item title="空瓶回收" name="2">
						<view class="flex justify-between align-center" style="margin: 10px 15px 0px 15px;" v-for="(item,index) in qpsf.kphs"
							:key="index">
							<view class="">
								{{item.code}} | {{item.qpgg}}
							</view>
							<view class="" @click="del(2,index)">
								<u-icon name="trash" size="18"></u-icon>
							</view>
						</view>
					</u-collapse-item>
				</u-collapse>
			</view>
			<!-- <view class="cardCss usuallyCard">
				<u-collapse ref="collapse3" :border="false" :value="qpsf.mphs.length?['3']:['']">
					<u-collapse-item title="满瓶回收" name="3">
						<view class="flex justify-between align-center" style="margin: 10px 15px 0px 15px;" v-for="(item,index) in qpsf.mphs"
							:key="index">
							<view class="">
								{{item.code}} | {{item.qpgg}}
							</view>
							<view class="" @click="del(3,index)">
								<u-icon name="trash" size="18"></u-icon>
							</view>
						</view>
					</u-collapse-item>
				</u-collapse>
			</view> -->
			<view class="scanAreaCss flex justify-around">
				<view class="flex flex-direction align-center margin-tb-sm" @click="openScan(1)">
					<view class="">
						<u-image src="/static/images/home/saoma.png" width="22px" height="22px"></u-image>
					</view>
					<view class="margin-top-xs themeColor">
						满瓶发出
					</view>
				</view>
				<view class="flex flex-direction align-center margin-tb-sm" @click="openScan(2)">
					<view class="">
						<u-image src="/static/images/home/saoma.png" width="22px" height="22px"></u-image>
					</view>
					<view class="margin-top-xs themeColor">
						空瓶回收
					</view>
				</view>
				<!-- <view class="flex flex-direction align-center margin-tb-sm" @click="openScan(3)">
					<view class="">
						<u-image src="/static/images/home/saoma.png" width="22px" height="22px"></u-image>
					</view>
					<view class="margin-top-xs themeColor">
						满瓶回收
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {

		},
		data() {
			return {
				isScan: false
			}
		},
		props: {
			qpsf: {
				type: Object,
				default: () => {}
			},
			qpParams: {
				type: Array,
				default: () => []
			},
			qptipsObj: {
				type: Object,
				default: () => {}
			}
		},
		watch: {
			qpsf: {
				handler() {
					this.$nextTick(() => {
						// 重新触发mounted生命周期钩子
						console.log("监听qpsf", this.qpsf);
						this.setQplist();
						this.$forceUpdate();
					});
				},
				immediate: true,
				deep: true,
			}
		},
		computed: {

		},
		mounted() {
			this.setQplist();
			console.log("qpparams", this.qpParams);
		},
		methods: {
			setQplist() {
				setTimeout(() => {
					this.$nextTick(() => {
						// nextTick延迟回调，否则第一次不更新
						this.$refs.collapse1.init();
						this.$refs.collapse2.init();
						// this.$refs.collapse3.init();
					})
				}, 500)
			},
			openScan(e) {
				this.$emit('openScan', e)
			},
			del(e, index) {
				this.$emit('del', e, index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		position: relative;
	}

	.cardCss {
		margin: 10px 12px;
		padding: 20px 15px;
	}

	.scanAreaCss {
		width: 100%;
		position: fixed;
		bottom: 50px;
		height: 60px;
		background: #3D3935;
	}
</style>