<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" :preLoadScreen="page * 10">

				<view class="card_box cx-sc">
					<view class="title_box rx-sc">
						<view class="round">1</view>
						<view class="code">领料单号:62464462</view>
					</view>
					<view class="word_order ">工单编号:62464462</view>

					<view class="content_table" v-for="(item, idx) in dataList">
						<view class="item">
							<view class="lable rx-cc">编码</view>
							<view class="content">
								{{item.assetCode}}
							</view>
						</view>

						<view class="item">
							<view class="lable rx-cc">名称</view>
							<view class="content">{{item.assetName}}</view>
						</view>


						<view class="item" v-for="(itm, index) in tableH(4)" :key="index">
							<view class="lable rx-cc">{{ itm.label }}</view>
							<view class="content">{{ item[itm.prop] }}</view>

						</view>


						<view class="item">
							<view class="lable rx-cc">数量</view>
							<view class="content content_num">
								<input class="uni-input" v-model="item.demandQuantity"
									@blur='item.demandQuantity > item.number ?  item.demandQuantity = item.number : item.needNum'
									type="digit"></input>
								<view class="unit">/{{item.unit}}</view>

							</view>
						</view>



						<view class="item">
							<view class="lable rx-cc">领料仓库</view>
							<view class="content ">

							</view>
						</view>

					</view>
				</view>


				<u-list-item v-if="dataList.length === 0">
					<u-empty iconSize='150' style='margin-top: 20vh;' 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'
	let [isEnd] = [false]
	export default {
		components: {

		},
		data() {
			return {
				page: 1,
				size: 5,
				ids: [],
				dataList: [],

			}
		},


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



		methods: {
			async getList() {
		

				isEnd = false
				const res = await pickDetails(this.ids)
				console.log(res)

				if (params.page === 1) {
					this.dataList = []
				}

				this.dataList.push(...res.list)
				isEnd = this.dataList.length >= res.count

			},




			scrolltolower() {
				if (isEnd) return
				this.page++
				this.getList()
			},




			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;



		.title_box {
			width: 702rpx;

			.round {
				width: 32rpx;
				height: 32rpx;
				line-height: 32rpx;
				border-radius: 50%;
				background: $theme-color;
				color: #fff;
				text-align: center;
				font-size: 20rpx;
			}

			.code {
				margin-left: 16rpx;
				font-family: PingFang SC;
				font-size: 28rpx;
				font-style: normal;
				font-weight: 400;
				color: $theme-color;
			}
		}


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

		.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>