<!-- 到货质检 数量修正 -->
<template>
	<view class="container-wrap">
		<uni-nav-bar title="数量修正" :status-bar="true" background-color="#3F92F9" color="#FFF">
			<view slot="left">
				<u-icon name="account-fill" color="#FFF" size="35"></u-icon>
				<span style="padding: 0 5rpx;color: #FFFFFF;">{{ userInfo.name }}</span>
			</view>
			<view slot="right" @tap="$utils.back()">
				<span style="color: #FFFFFF;">返回</span>
			</view>
		</uni-nav-bar>
		<view class="container">
			<div class="top">
				<view class="info">
					<view class="title">数量修正申请</view>
					<view class="row">
						<view class="col">
							<view class="label">合同号：</view>
							<view class="value">{{ option.purchaseBillNo }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">批次号：</view>
							<view class="value">{{ option.batchNo }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">供应商：</view>
							<view class="value">{{ option.supplier }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">物料名称：</view>
							<view class="value">{{ option.materialName }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">物料规格：</view>
							<view class="value">{{ option.spec }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">到货时间：</view>
							<view class="value">{{ option.arriveTime }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">申购数量：</view>
							<view class="value">{{ option.purchaseCount }}</view>
						</view>
						<view class="col">
							<view class="label">到货数量：</view>
							<view class="value">{{ option.inStockQty }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col" style="align-items: center;">
						<span>数量修正：</span>
						<view style="width: 200rpx;background-color: #FFFFFF;margin-right: 10rpx;">
							<u-input v-model="option.adjustNum" type="number" :border="true"/>
						</view>
						%
						</view>
					</view>
				</view>
				<view class="title">质检短少记录</view>
				<view class="sub-title">共有{{ option.checkLakeItems.length }}个物料存在短少</view>
			</div>
			<view class="list">
				<view class="item" v-for="(item, index) in option.checkLakeItems" :key="index">
					<view class="row">
						<view class="col">
							<view class="label">标签值：</view>
							<view class="value">{{ item.rfidCode }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">物料数量：</view>
							<view class="value">{{ item.quantity }}</view>
						</view>
					</view>
					<view class="row border">
						<view class="col">
							<view class="label">短少比率：</view>
							<view class="value">{{ item.lakePercent }}%</view>
						</view>
					</view>
					<view class="row" style="justify-content: center;">
						<span>质检结论：</span>
						<span class="red">短少{{ item.lakeNum }}米</span>
					</view>
				</view>
			</view>
			<view class="btn">
				<u-button throttleTime="300" type="primary" style="width: 100%;" @click="cfm">提交申请</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num: 0,
				option: {}
			};
		},
		methods: {
			/* 结束质检 */
			cfm() {
				this.$http.AddStockQtyCheckAdjust({
					stockQuantityCheckId: this.option.stockQuantityCheckId,
					adjustNum: this.option.adjustNum
				}).then(res => {
					console.log(res)
					if(res.code === 0) {
						this.$msg.showToast(res.msg || '提交成功！')
						this.$storage.removeStorageSync(this.option.stockQuantityCheckId)
						/* 如果需要免检 */
						if(this.option.isNoCheck) {
							this.$utils.openNew(`/pages/store-in-manage/quality/quality-no-check?data=${this.$utils.object2Code(this.option)}`)
						} else {
							setTimeout(() => {
								this.$utils.back(2)
							}, 500)
						}
					}
				})
			},
			/* 绑定标签 */
			bind() {
				this.$utils.open('/pages/store-in-manage/quality/quality-scan')
			}
		},
		onLoad(option) {
			console.log('?????????????')
			this.option = this.$utils.code2Object(option.data)
			console.log(this.option)
		},
		onUnload() {
			// #ifdef APP-PLUS
			// #endif
		}
	}
</script>

<style lang="scss" scoped>
.container-wrap {
	overflow: hidden;
	.container {
		padding: 10rpx;
		height: calc(100vh - var(--status-bar-height) - 44px);
		overflow: auto;
		.top {
			height: 600rpx;
			.info {
				padding: 10rpx 20rpx;
				font-size: 32rpx;
			}
			.title {
				font-size: 36rpx;
				font-weight: bold;
				text-align: center;
			}
			.sub-title {
				font-size: 24rpx;
				text-align: center;
				color: #7f7f7f;
			}
		}
		.list {
			padding: 10rpx 0;
			height: calc(100% - 680rpx);
			overflow: auto;
			background-color: #FFFFFF;
			.item {
				padding: 20rpx;
				margin-bottom: 10rpx;
				background-color: #FFFFFF;
				border: 1rpx solid rgba(215, 215, 215, 1);
				border-radius: 10rpx;
				.row {
					&.border {
						border-bottom: 1px solid rgba(215, 215, 215, 1);
					}
					.orange {
						color: rgb(245, 154, 35);
					}
					.red {
						color: red;
					}
				}
			}
		}
	}
}
.modal {
	padding: 40rpx 0;
	text-align: center;
	.img {
		margin: auto;
		width: 200rpx;
	}
	.content {
		padding: 30rpx 0;
		font-size: 36rpx;
		font-weight: bold;
	}
}
</style>
