<template>
	<view>
		<!-- <requiredLocation title="需求库位" :locationCode="dataContent.toLocationCode"
			:isShowEdit="dataContent.allowModifyLocation==1"></requiredLocation> -->

		<view v-for="(item,index) in dataContent.subList">
			<uni-swipe-action ref="swipeAction" :class="item.scaned? 'scan_view':''">
				<uni-swipe-action-item
					:right-options="(item.scaned&&isEdit)?editAndRemoveOptions : item.scaned? removeOptions:options"
					@click="swipeClick($event,item,index)" style='padding:0px 0px  5px 0px;align-items: center;'>
					<item-qty :dataContent="item" :handleQty="item.handleQty" :isShowBalanceQty="false"></item-qty>
					<location :locationCode="item.fromLocationCode"></location>
					<recommendBalanceBatch style='margin-left: 20px;' :detail="item" :isShowLocation="false"
						:isShowPack="item.packingNumber"></recommendBalanceBatch>

				</uni-swipe-action-item>
			</uni-swipe-action>
		</view>
	</view>
	<qtyEdit ref="balanceQtyEdit" @confirm="confirm" :isShowStatus="true"></qtyEdit>
	<detail-info-popup ref="detailInfoPopup"></detail-info-popup>
	<comMessage ref="message"></comMessage>
</template>

<script>
	import itemQty from '@/mycomponents/item/itemQty.vue'
	import recommend from '@/mycomponents/recommend/recommend.vue'
	import recommendBalanceBatch from '@/mycomponents/balance/recommendBalanceBatch.vue'
	import handleBalance from '@/mycomponents/balance/handleBalance.vue'
	import recommendQtyEdit from '@/mycomponents/qty/recommendQtyEdit.vue'
	import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
	import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
	import qtyEdit from '@/mycomponents/qty/qtyEdit.vue'
	import location from '@/mycomponents/balance/location.vue'
	import detailInfoPopup from '@/pages/productionReceipt/coms/detailInfoPopup.vue'

import {
		getDetailOption,
		getPurchaseReceiptOption,
		getRemoveOption,
		getEditRemoveOption
	} from '@/common/array.js';

	export default {
		emits: ['updateData'],
		components: {
			itemQty,
			recommend,
			recommendBalanceBatch,
			handleBalance,
			recommendQtyEdit,
			requiredLocation,
			qtyEdit,
			location,
			detailInfoPopup
		},
		props: {
			dataContent: {
				type: Object,
				default: {}
			},
			settingParam: {
				type: Object,
				default: {}
			},
			isEdit: {
				type: Boolean,
				default: true
			},
		},
		watch: {

		},

		data() {
			return {
				option: [],
				showItem: {},
				editItem: {},
				batchItem: {},
				detailOptions: [],
				scanOptions: []
			}
		},

		mounted() {
			
			this.removeOptions = getRemoveOption();
			this.editAndRemoveOptions = getEditRemoveOption()
		},

		methods: {
			resizeCollapse() {
				this.$nextTick(r => {
					this.$refs.collapse.forEach(r => {
						r.childrens.forEach(i => {
							i.init();
						})
						r.resize();
					})
				});
			},

			swipeClick(e, item, index) {
				if (e.content.text == "编辑") {
					this.edit(item)
				} else if (e.content.text == "移除") {
					this.remove(item, index)
				}
			},

			edit(item) {
				let that = this;
				that.editItem = item;
				that.$refs.balanceQtyEdit.openEditPopup(item);
			},

			detail(item) {
				this.showItem = item;
				this.$refs.receiptHint.openScanPopup()
			},
			remove(item, index) {
				this.$refs.message.showQuestionMessage("确定移除扫描信息?",
					res => {
						if (res) {
						item.handleQty = 0;
						item.scaned = false ;
						}
					});
			},
			confirm(val) {
					console.log(44,this.editItem)
					this.editItem.handleQty =  Number(val);
					this.$emit('updateData', this.editItem)
			}
		}
	}
</script>

<style>
</style>