<template>
	<view>
		<StickyNavBar>
			<NavBar title="委外发料"></NavBar>
			<view class="btn">
				<uni-easyinput
					prefixIcon="search"
					:disabled="isDisabled"
					v-model="wxparams"
					:focus="isFocus"
					placeholder="请扫描单号"
					@input="handleInputPlnr"
				></uni-easyinput>
			</view>
		</StickyNavBar>
		<view class="cardBox">
			<text class="cardBoxTip">
				步骤一    扫描单号
			</text>
			<u-image class='cardBoxImg' :src="bgSrc" width="560rpx" height="400rpx"></u-image>
			<view class="cardBoxTip2">
				摄像头对准
			</view>
			<view class="cardBoxTip3">
				委外发料单号二维码
			</view>
			<view class="cardBoxTip2">
				<text class="tipLeft">
					点击扫描或
				</text>
				<text class="tipRight">
					点选单号
				</text>
			</view>
		</view>
	</view>
</template>

<script>
import StickyNavBar from '@/components/StickyNavBar/index.vue';
import ContentLoadingMore from '@/components/ContentLoadingMore/index.vue';
import BottomBtn from '@/components/BottomBtn/index.vue';
export default {
	components: {
		StickyNavBar,
		ContentLoadingMore,
		BottomBtn
	},
	data() {
		return {
			bgSrc: require('@/static/images/qrcode.png'),
			number: 0,
			totalNum: 0,
			show: true,
			nlpla: '',
			wxparams: '',
			btnArr: [
				{
					style: '',
					type: 'primary',
					text: '扫描单号',
					way: 'scanning'
				},
				{
					style: '',
					type: 'warning',
					text: '点击单号',
					way: 'goClick'
				}
			],
			goodsList: [],
			isFocus: false,
			isDisabled: false
		};
	},
	created() {
		// this.getPlnr('10000820240325000001|10000320100');
	},
	methods: {
		deleGonds(idx) {
			this.goodsList.splice(idx, 1);
			this.totalNum = 0;
			this.goodsList.forEach((ele) => {
				this.totalNum += ele.ERFMG;
			});
		},
		getBtnHandle(row) {
			this[row.way]();
		},
		goClick() {
			uni.navigateTo({
				url: `/pages/produceReturn/produceReturnList`
			});
		},
		scanning() {
			
		},
		handleInputPlnr(e) {
			this.isFocus = false;
			e && this.getPlnr(e);
		},
		handleInputNlpla(e) {
			if (e) {
				this.nlpla = e;
				this.goodsList.forEach((ele) => {
					this.totalNum += ele.ERFMG;
					ele.NLPLA = ele.NLPLA || this.nlpla;
				});
			}
		},
		getPlnr(VBELN) {
			this.$u.api.sapApi
				.sapSchDn({
					VBELN
				}, 300)
				.then((res) => {
					console.log(res);
					if (res && res.BKDT.length) {
						this.goodsList = res.BKDT
						uni.navigateTo({
							url: `/pages/outsourcedMaterial/outsourcedMaterialList?order=${JSON.stringify(this.goodsList)}`
						});
					} else {
						// res.forEach(element => {
						// });
						this.$u.toast(res.MSG[0].MESSAGE);
					}
					this.loading = false;
				});
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background: #f8f8f8;
}
.btn {
	padding: 20rpx;
	background: #fff;
	.topSearch {
		margin-bottom: 20rpx;
	}
}
.cardBox {
	min-height: calc(100vh - 400rpx);
	padding: 0rpx 20rpx;
	margin-top: 20rpx;
}
/deep/ .u-sticky {
	top: 0 !important;
	background: #fff;
}
.cardBoxTip{
	color: #000;
	font-size: 28rpx;
}
.cardBoxTip2{
	color: #000;
	font-size: 28rpx;
	text-align: center;
}
.cardBoxTip3{
	color: #3f9dcc;
	font-size: 28rpx;
	text-align: center;
}
.tipRight{
	color: #ff9900;
}
.cardBoxImg{
	margin: 20rpx 0;
}
</style>