<!-- 申请免检 -->
<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="back()">
				<span style="color: #FFFFFF;">返回</span>
			</view>
		</uni-nav-bar>
		<view class="container">
			<div class="top">
				<view class="info">
					<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>
					<view class="row">
						<view class="col">
							<view class="label">到货数量：</view>
							<view class="value">{{ option.inStockQty }}</view>
						</view>
					</view>
				</view>
			</div>
			<view class="list">
				<div><span style="color: red;">*</span>申请原因</div>
				<div style="background-color: #FFFFFF;margin-top: 10rpx;">
					<u-input
						placeholder=""
						v-model="reason"
						type="textarea"
						:border="true"
						:height="180"
					  ></u-input>
				</div>
			</view>
			<view class="btn">
				<u-button throttleTime="300" type="primary" style="width: 100%;" @click="cfm">提交申请</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import error from '../../../static/images/error.png'
	export default {
		data() {
			return {
				reason: '',
				option: {}
			};
		},
		methods: {
			cfm() {
				if(!this.reason) {
					return this.$msg.showToast('请输入申请原因！')
				}
				this.$http.AddStockExemptCheck({
					stockQuantityCheckId: this.option.stockQuantityCheckId,
					reason: this.reason
				}).then(res => {
					console.log(res)
					if(res.code === 0) {
						this.$msg.showToast(res.msg || '提交成功！')
						this.$storage.removeStorageSync(this.option.stockQuantityCheckId)
						setTimeout(() => {
							this.$utils.back(3)
						}, 500)
					}
				})
			},
			back () {
				if(this.option.isNoCheck) {
					this.$utils.back(3)
				} else {
					this.$utils.back(1)
				}
			}
		},
		onLoad(option) {
			this.option = this.$utils.code2Object(option.data)
		},
		onShow() {
		},
		onUnload() {
		},
		onBackPress(e) {
			if(e.from === 'navigateBack') {
				return false
			} else {
				this.back()
				return true
			}
			// return true 表示禁止默认返回
			// if(this.option.isNoCheck) {
			// 	uni.navigateBack({delta: 2})
			// 	return false
			// } else {
			// 	uni.navigateBack({delta: 1})
			// 	return false
			// }
		}
	}
</script>

<style lang="scss" scoped>
.container-wrap {
	overflow: hidden;
	.container {
		padding: 10rpx;
		height: calc(100vh - var(--status-bar-height) - 44px);
		overflow: hidden;
		display: flex;
		flex-direction: column;
		.top {
			.info {
				padding: 10rpx 20rpx;
				font-size: 32rpx;
			}
			.title {
				margin-top: 20rpx;
				font-size: 36rpx;
				font-weight: bold;
				text-align: center;
			}
			.sub-title {
				padding: 10rpx 0;
				font-size: 24rpx;
				text-align: center;
				color: #7f7f7f;
			}
		}
		.list {
			padding: 10rpx 20rpx;
			margin-bottom: 10rpx;
			flex: 1;
			overflow: auto;
			.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);
					}
					.blue {
						color: #02A7F0;
					}
					.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>
