<template>
	<view class="lists">
		<view class="status_bar" :style="navHeight"></view>
		<!-- <view class="header-bg">
			<image class="header-bg-img" src="@/static/image/nav_bg@3x.png" mode="scaleToFill"></image>
		</view> -->
		<view class="main" :style="mainHeight">
			<view class="middle view planout-block-item">
				<view class="text-block">
					<text class="middle-date">要货单号</text>
					<input class="middle-date-des" type="text" v-model="boxNum" placeholder="请输入" disabled />
				</view>
				<view class="text-block text-block-last">
					<text class="middle-date">箱码编号</text>
					<input class="middle-date-des" type="text" v-model="boxBarcode" placeholder="请输入" />
				</view>
			</view>
			<view class="planout-block">
				<button class="btn" type="default" @tap="getBoxNum">
					<text class="btn-text">查询</text>
				</button>
			</view>
			<list class="view scroll-area code-box" scrollable loadmoreoffset='1' show-scrollbar='false' v-if="dataList.length">
				<cell class="" v-for="item in dataList">
					<view class="box-code">{{item.boxBarcode}}</view>
				</cell>
			</list>
			<no-data v-if="dataList.length === 0"></no-data>
		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex'
	import noData from '@/components/nodata.nvue';
	import { findGoodsSingleJoinBoxBarcode } from '@/servers/purchaseList.js'
	export default {
		data() {
			return {
				dataList: [],
				boxNum: '',
				boxBarcode: ''
			}
		},
		components: {
			noData,
		},
		computed: {
			navHeight() {
				return {
					'height': `${this.sysinfo.safeArea.top + 44}px`
				}
			},
			mainHeight() {
				return {
					'height': `${this.sysinfo.safeArea.height - 44 }px`,
				}
			},
			scrollHeight() {
				return {
					'height': `${this.sysinfo.safeArea.height - 44}px`
				}
			},
			...mapState(['sysinfo','userInfo'])
		},
		onLoad() {
		},
		onBackPress() {
			
		},
		created() {
			this.getBoxNum()
		},
		onLoad(option) {
			this.boxNum = option.num
		},
		methods: {
			async getBoxNum(){
				uni.showLoading({
					title: '加载中'
				});
				const formdata = {
					"user_bp": this.userInfo.code,
					"role": 'WLY001',
					"wantCode": [{
						"sign": "I",
						"option": "CP",
						"low": "*"+ this.boxNum +"*",
						// "low": "*FHZG20020840*",
						"high": ""
					}],
					"page": 1,
					"pagesize": 10000,
					"totalCount": 10000,
					"is_result": 1,
					"sort": [{
						"field_name": "createdDate",
						"field_sort": "X"
					}],
					"billStatus": [{
						"sign": "I",
						"option": "EQ",
						"low": "E003",
						"high": ""
					}],
					"boxBarcode": [{
						"sign": "I",
						"option": "CP",
						"low": "*"+ this.boxBarcode +"*",
						"high": ""
					}],
					"boxBarcodeNotNull": true
				}
				!this.boxBarcode && delete formdata.boxBarcode
				try{
					const res = await findGoodsSingleJoinBoxBarcode(formdata)
					uni.hideLoading();
					this.dataList = res.data.Rows
				}catch(e){
					uni.hideLoading();
				}
				
			}
		}
	}
</script>
<style lang="scss" scoped>
	.view {
		flex-direction: column;
	}

	.header-bg {
		height: 284rpx;
		opacity: 0.72;
		margin-top: -88rpx;
	}
	.header-bg-img {
		width: 750rpx;
	}

	.lists {
		position: relative;
		flex-direction: column;
		background: #f0f4f5;
		flex: 1;
	}

	.main {
		position: relative;
		flex-direction: column;
		padding: 0 16rpx;
		padding-top: 40rpx;
		// background-color: #fff;
	}

	.middle {
		background-color: #fff;
		border-radius: 16rpx;
		padding: 0rpx 64rpx 0rpx 48rpx;
	}

	.text-block {
		overflow: hidden;
		height: 96rpx;
		margin-bottom: 14rpx;
		border-bottom: 1px solid #f4f5f6;
	}

	.text-block-last {
		margin-bottom: 0;
		border-bottom: 0;
	}

	.middle-date {
		flex: 2;
		font-size: 28rpx;
		line-height: 96rpx;
		color: #333;
		margin-bottom: 8rpx;
	}

	.middle-date-des {
		flex: 3;
		font-size: 28rpx;
		line-height: 96rpx;
		height: 96rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		color: #888;
	}

	.picker-year {
		position: relative;
		border-radius: 4px;
		align-items: center;
		line-height: normal;
	}

	.uni-list-cell {
		flex: 1;
		height: 96rpx;
		line-height: 96rpx;
	}

	.uni-list-cell-db {
		flex: 1;
	}

	.picker-block {
		flex: 1;
	}

	.uni-input-text {
		height: 96rpx;
		line-height: 96rpx;
		font-size: 14px;
		color: #888;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}
	.btn {
		flex: 1;
		height: 92rpx;
		background: $wly-primary-color;
		border-radius: 46rpx;
	}

	.btn-text {
		color: #fff;
		font-size: 34rpx;
	}
	.navs-block {
		flex-direction: column;
		background-color: #fff;
		padding-top: 40rpx;
	}
	
	.navs-tab {
		display: flex;
		flex: 1;
		align-items: center;
		height: 60rpx;
		border-bottom: 1px solid #F4F5F6;
		padding-bottom: 8rpx;
	}
	
	.navs-tab-item {
		display: flex;
		justify-content: center;
		flex: 1;
		align-items: center;
		height: 50rpx;
		overflow: hidden;
	}
	
	.search-type-text {
		color: #333;
		font-size: 28rpx;
	}
	
	.icon-arrow-down {
		width: 6px;
		height: 4px;
		margin-left: 16rpx;
	}
	.planout-block {
		display: flex;
		justify-content: space-between;
		margin-top: 30rpx;
		margin-bottom: 30rpx;
		padding: 0 24rpx;
	}
	
	.btn {
		flex: 1;
		height: 92rpx;
		background: $wly-primary-color;
		border-radius: 46rpx;
	}
	
	.btn-text {
		color: #fff;
		font-size: 34rpx;
	}
	.title-no {
		font-size: 32rpx;
		font-weight: 600;
		color: #000;
		margin-bottom: 20rpx;
	}
	.tips{
		margin-top: 40rpx;
		margin-bottom: 20rpx;
	}
	.code-box{
		background: #f8f8f8;
		border-radius: 20rpx;
		display: flex;
		flex-direction: column;
		padding: 40rpx 24rpx;
		margin-bottom: 40rpx;
	}
	.box-num{
		// min-height: 400rpx;
	}
	.box-code{
		font-size: 28rpx;
		color: #000;
		line-height: 44rpx;
		font-weight: 600;
	}
	.scroll-area {
		overflow-y: scroll;
	}
</style>
