<template>
	<view class="content-box">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
			color="#000" @clickLeft="back"></uni-nav-bar>

		<view class="list_box">
			<u-list @scrolltolower="scrolltolower">
				<view v-for="(item,index) in List" :key="index" class="card_box">
					<workOrderBom :item='item' @handleScan='handleWordScan'></workOrderBom>


					<turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item'
						:newTurnover='item.newTurnover' @handleScan='handleScan' @refreshList='getList'></turnoverBom>



				</view>
			</u-list>

		</view>




	</view>
</template>

<script>
	import workOrderBom from '../../feeding/components/workOrderBom.vue'
	import turnoverBom from '../components/turnoverBom.vue'

	import {
		getVehicle,
	} from '@/api/pda/workOrder.js'





	export default {
		components: {
			workOrderBom,
			turnoverBom
		},
		data() {
			return {
				title: '',
				workOrderId: null,
				List: [],
				taskId: null


			}
		},
		onLoad(options) {
			this.title = options.taskName ? options.taskName + '-更换周转车' : '更换周转车'
			this.workOrderId = options.workOrderId;
			this.taskId = options.taskId
			this.taskName = options.taskName

			this.getList()

		},


		methods: {
			scrolltolower() {},



			getList() {
				getVehicle({
					workOrderId: this.workOrderId,
					taskId: this.taskId
				}).then(res => {
					this.List = []

					if (res.turnover && res.turnover.length) {
						res.newTurnover = []
						res.turnover.forEach(e => {
							e.extInfo.positionList.length && e.extInfo.positionList.forEach(o => {
								o['check'] = false
								o['isend'] = false
								o['newQuantity'] = o.quantity
							})
						})
					}

					this.List.push(res)
					
				})
			},






			handleWordScan(id, type) {
				uni.showToast({
					icon: 'none',
					title: '不支持更换工单'
				})


			},


			handleScan(id, type) {

				let _this = this
				uni.scanCode({
					success: function(res) {
						_this.scanData(res.result, type, id)
					}
				})


			},






		},

	}
</script>

<style lang="scss" scoped>
	.content-box {
		height: 100vh;
		overflow: hidden;
		display: flex;
		flex-direction: column;

	}

	.list_box {
		flex: 1;
		overflow: hidden;
		padding: 4rpx 0;

		.u-list {
			height: 100% !important;
		}

		.card_box {
			padding: 16rpx;
		}



	}


	.operate_box {
		padding: 10rpx 160rpx;

		/deep/ .u-button {
			width: 160rpx;
		}
	}
</style>