<template>
	<view class="" style="background-color: #fff;">
		<record-com-detail-card :dataContent="dataContent" @removeItem="removeItem(index,dataContent)"
			:isShowItemQty='false'>
		</record-com-detail-card>

		<view class="" v-for="(detail,index) in dataContent.subList">
			<view v-if="detail.Records!=undefined" style='margin-left: 20px;' v-for="(record,index) in detail.Records">
				<uni-swipe-action ref="">
					<uni-swipe-action-item @click="swipeClick($event,detail,record,index)"
						:right-options="record.scaned?scanOptions:detailOptions">
						<view class="uni-flex uni-row scan_view margin-top: 5px;">
							<view
								style=" width: 20px;display: flex;justify-content: center;align-items: center; color: #32C1E8;">
								{{index+1}}.
							</view>
							<view style="width: 300px;">
								<!-- <recommend :dataContent="record" :packageContent="record.package" :isShowStatus="false"
									:isShowLocation="false"></recommend> -->
								<balance :dataContent="record" :packageContent="record.package" :isShowStatus="false"
									:isShowFromLocation="false" :isShowToLocation="false"></balance>
							</view>
						</view>
					</uni-swipe-action-item>
				</uni-swipe-action>
			</view>
		</view>
		<recommend-qty-edit ref="recommendQtyEdit" :dataContent="editItem" :handleQty='editItem.qty' @confirm="confirm">
		</recommend-qty-edit>
		<package-detail-popup ref='packageDetailPopup'></package-detail-popup>
		<comMessage ref="comMessage"></comMessage>
	</view>
</template>

<script>
	import itemQty from '@/mycomponents/item/itemQty.vue'
	import recommend from '@/mycomponents/recommend/recommend.vue'
	import purchaseLabel from '@/mycomponents/balance/purchaseLabel.vue'
	import record from '@/mycomponents/record/record.vue'
	import balance from '@/mycomponents/balance/balance.vue'
	import recommendQtyEdit from '@/mycomponents/qty/recommendQtyEdit.vue'
	import packageBalance from '@/mycomponents/package/packageBalance.vue'
	import packageHandle from '@/mycomponents/package/packageHandle.vue'
	import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
	import packageDetailPopup from '@/mycomponents/package/packageDetailPopup.vue'

	import {
		getDetailOption,
		getDetailEditRemoveOption,
		getClearOption
	} from '@/common/array.js';
	export default {
		components: {
			itemQty,
			recommend,
			purchaseLabel,
			balance,
			recommendQtyEdit,
			record,
			packageBalance,
			packageHandle,
			recordComDetailCard,
			packageDetailPopup
		},
		props: {
			dataContent: {
				type: Object,
				default: {}
			},
			settingParam: {
				type: Object,
				default: {}
			},
			fromInventoryStatus: {
				type: String,
				default: ""
			},
			toInventoryStatus: {
				type: String,
				default: ""
			},
			isShowStatus: {
				type: Boolean,
				default: false
			}
		},
		watch: {
			// dataContent: {
			// 	handler(newName, oldName) {
			// 		if (this.dataContent.originalList.length > 0) {
			// 			if (this.$refs.collapse1 != undefined) {
			// 				this.$nextTick(res => {
			// 					this.$refs.collapse1.resize()
			// 				})
			// 			}
			// 		}
			// 	},
			// 	immediate: true,
			// 	deep: true
			// }
		},

		data() {
			return {
				option: [],
				title: "推荐详情",
				showItem: {},
				editItem: {},
				detailOptions: [],
				scanOptions: [],
				removeOptions: [],
				dataList: []
			}
		},

		mounted() {
			this.detailOptions = getDetailOption();
			this.scanOptions = getDetailEditRemoveOption();
			this.removeOptions = getClearOption();
		},

		methods: {
			removeItem(e, dataContent) {
				if (e.content.text == "清空") {
					this.$refs.comMessage.showQuestionMessage("确定清空物料及箱码信息?",
						res => {
							if (res) {
								this.$emit('removeItem')
								// this.$emit('removeItem', this.dataContent)
							}
						});
				}
			},
			swipeClick(e, detail, record, index) {
				if (e.content.text == "详情") {
					this.detail(detail.package)
				} else if (e.content.text == "编辑") {
					this.edit(record)
				} else if (e.content.text == "移除") {
					this.remove(detail, index)
				}
			},

			edit(item) {
				this.editItem = item;
				this.$refs.recommendQtyEdit.openRecordEditPopup(this.editItem.LabelQty);
			},

			detail(item) {
				this.showItem = item;
				this.$refs.packageDetailPopup.openPopup(item)
			},
			remove(detail, index) {
				this.$refs.comMessage.showQuestionMessage("确定移除扫描信息?",
					res => {
						if (res) {
							detail.Records.splice(index, 1)
							this.$emit('removePack')
						}
					});
			},
			confirm(qty) {
				this.editItem.qty = qty;
				this.$emit('updateData')
			}
		}
	}
</script>

<style>
</style>
