<template>
	<view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;margin-top: 5px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">交验单号：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.deliverNo}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">生产令号：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.bomNo}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">物料号：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.materialCode}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">物料名称：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.materialName}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">规格型号/图号：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.materialSpec}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">BN/SN码：</text>
			<text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{deliverDtlMd.bnSnCode}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">质检合格数量：</text>
			<text style="align-self: center;font-size: 40rpx;font-weight: bold;">{{deliverDtlMd.checkQty}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">已入库数量：</text>
			<text style="align-self: center;font-size: 40rpx;font-weight: bold;color: blue;">{{deliverDtlMd.instoreQty}}</text>
		</view>
		<view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px; margin-top: 5px;">
			<text style="align-self: center;font-size: 35rpx;color: darkslategray;">本次入库数量：</text>
			<input class="uni-input" type="number" style="margin-right: 5px;font-size: 40rpx;font-weight: bold;" v-model="instoreNum"/>
		</view>
		<button type="primary" style="margin-top: 15px;" @click="submitResult">入库结果提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deliverDtlMd: {},
				instoreNum: ''
			}
		},
		onUnload() {
			
		},
		onLoad() {
			uni.$once('sendCheckedDeliverDtlData', (data) => {
				this.deliverDtlMd = data
				this.instoreNum = data.checkQty
			})
		},
		methods: {
			async submitResult() {
				if(Number(this.checkQty) <= 0) {
					uni.showToast({
						title: '未输入本次入库数量！',
						icon: 'none',
						mask: true,
						duration: 1000
					})
					return;
				}
				if((Number(this.instoreNum) + this.deliverDtlMd.instoreQty) > this.deliverDtlMd.checkQty) {
					uni.showToast({
						title: '本次入库数量录入错误，数量不能大于未入库数量！',
						icon: 'none',
						mask: true,
						duration: 1000
					})
					return;
				}
				let tmpMd = this.deliverDtlMd;
				tmpMd.instoreQty = this.instoreNum;
				let parm = {
					url : '/business/InInstoreRecord/AddCheckedSapDeliverInstoreDtlResult',
					data: tmpMd,
					method: 'POST',
					isHaveToken : true
				}
				let retData = await getApp().RequestData(parm)
				if(retData.isSuccess) {
					if(retData.data.code == 200) {
						uni.navigateBack({
							url: '/pages/Inspect/inspectDtl',
							success: () => {
								uni.$emit('addInstoreData',tmpMd);
							}
						});
					}
					else {
						uni.showToast({
							title: '提交数据失败！' + retData.data.msg,
							icon: 'none',
							mask: true,
							duration: 1000
						})
					}
				}
				else {
					uni.showToast({
						title: '接口异常！' + retData.retMsg,
						icon: 'none',
						mask: true,
						duration: 1000
					})
				}
			},
			isEmptyStr(s) {
				if (s == undefined || s === '') {
					return true
				}
				return false
			},
			foucusChange0(event) {
				let str = event.detail.value
				if(str.length !== 0) {
					this.foucusIndex = 1
				}
			},
			foucusChange1(event) {
				let str = event.detail.value
				if(str.length !== 0) {
					this.foucusIndex = 2
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/uni-nvue.css';
</style>