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


		<view class="list_box">

			<u-list @scrolltolower="scrolltolower" key="dataList">



				<view class="card_box cx-sc" v-for="(item, index) in dataList" :key="index">

					<view class="content_table">
						<view class="item">
							<view class="lable rx-cc" style="color:#157A2C ;">领料单号</view>
							<view class="content" style="color:#157A2C;">
								{{ item.code }}
							</view>
						</view>
					</view>

					<view v-for="(it,idx) in item.orderInfoList" :key='idx'>
						<view class="word_order ">工单编号:{{it.code}}</view>

						<view v-if='it.arr.length == 0' style='margin-top: 10px;'>
							<u-empty iconSize='80' textSize='32' text='未领料'>
							</u-empty>
						</view>

						<instanceBom :list='it.arr'></instanceBom>


					</view>


				</view>


				<u-list-item v-if="dataList.length === 0" style='margin-top: 20vh;'>
					<u-empty iconSize='150' textSize='32' text='暂无数据'>
					</u-empty>
				</u-list-item>

			</u-list>
		</view>


		<view class="bottom-wrapper">
			<!-- <view class="btn_box" @click="save">一键报工</view> -->
		</view>


	</view>
</template>

<script>
	import {
		tableHeader
	} from '../../common.js'
	import {
		workorderPage
	} from '@/api/pda/workOrder.js'

	import {
		pickDetails
	} from '@/api/pda/picking.js'

	import instanceBom from './components/instanceBom.vue'
	export default {
		components: {
			instanceBom
		},
		data() {
			return {

				ids: [],
				dataList: [],

			}
		},


		onLoad(option) {
			this.ids = [option.id]
			this.getList()
		},



		methods: {
			async getList() {



				const res = await pickDetails(this.ids)
				let list = res
				list.forEach(m => {
					if (m.orderInfoList.length > 0) {
						m.orderInfoList.forEach(o => {
							let _arr = []
							_arr = [...o.bomDetailDTOS, ...o.instanceList]
							_arr = _arr.sort((a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId)
							o['arr'] = _arr

						})



					}
				})
				this.dataList = list





			},




			scrolltolower() {

			},




			tableH(type) {
				return tableHeader(type)
			},

			save() {},


		}
	}
</script>

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

	}



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

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


	.bottom-wrapper {
		.btn_box {
			width: 750rpx;
			height: 88rpx;
			line-height: 88rpx;
			background: $theme-color;
			text-align: center;
			font-size: 36rpx;
			font-style: normal;
			font-weight: 400;
			color: #fff;
		}
	}



	.card_box {
		margin-top: 10rpx;




		.word_order {
			height: 64rpx;
			width: 706rpx;
			background: $theme-color;
			font-size: 28rpx;
			color: #fff;
			line-height: 64rpx;
			padding-left: 40rpx;
			box-sizing: border-box;
		}

		.content_table {
			margin-top: 10rpx;
			width: 702rpx;
			border: 2rpx solid $border-color;

			.item {
				display: flex;
				border-bottom: 2rpx solid $border-color;


				.lable {
					width: 132rpx;
					text-align: center;
					background-color: #F7F9FA;
					font-size: 26rpx;
					border-right: 2rpx solid $border-color;
					flex-shrink: 0;
				}

				.ww80 {
					width: 80rpx;
				}

				.content {
					width: 518rpx;
					min-height: 64rpx;
					font-size: 28rpx;
					line-height: 28rpx;
					font-style: normal;
					font-weight: 400;
					padding: 18rpx 8rpx;
					box-sizing: border-box;
					word-wrap: break-word;
					flex-grow: 1 !important;

				}

				.content_num {
					display: flex;
					align-items: center;
					padding: 0 4rpx;

					/deep/ .uni-input-input {
						width: 480rpx;
						border: 2rpx solid #F0F8F2;
						background: #F0F8F2;
						color: $theme-color;
					}

					.unit {
						padding: 0 4rpx;
						font-size: 24rpx;
						color: #404446;
					}
				}

				.pd4 {
					padding: 4rpx 8rpx;
				}



				&:last-child {
					border-bottom: none;
				}
			}

			.ww55 {
				width: 55%;
			}

			.ww45 {
				width: 45%;
			}
		}
	}
</style>