<template>
	<view>
		<view class="form-area">
			<view>
				<h4>类型名称</h4>
				<span>{{ upperInfo.typeName }}</span>
			</view>
			<view>
				<h4>规格型号</h4>
				<span>{{ upperInfo.typeCode }}</span>
			</view>
			<view>
				<h4>待入库数量</h4>
				<span>{{ upperInfo.num }}</span>
			</view>
			<view>
				<h4>合格数量</h4>
				<uni-easyinput type="number" v-model="lowerIpt.passedNum" placeholder="请输入数量"></uni-easyinput>
			</view>
			<view>
				<h4>待修数量</h4>	
				<uni-easyinput type="number" v-model="lowerIpt.waitRepairNum" placeholder="请输入数量"></uni-easyinput>
			</view>
			<view>
				<h4>待报废数量</h4>
				<uni-easyinput type="number" v-model="lowerIpt.waitCrashNum" placeholder="请输入数量"></uni-easyinput>
			</view>
		</view>
		<view 
			class="sub-btn"
			@click="subForm"
		>
			确认
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				upperInfo: {
					parentId: '',
					typeName: '',
					typeCode: '',
					num: ''
				},
				lowerIpt: {
					passedNum: '',
					waitRepairNum: '',
					waitCrashNum: ''
				},
				totalNum: 0
			}
		},
		methods: {
			subForm () {
				let that = this
				that.totalNum = Number(that.lowerIpt.passedNum) + Number(that.lowerIpt.waitRepairNum) + Number(that.lowerIpt.waitCrashNum) 
				console.log(that.totalNum);
				if (that.totalNum > that.upperInfo.num) {
					uni.showToast({
						icon: 'none',
						title: '接收总量不能大于退库数量！'
					})
				} else {
					console.log(1);
				}
			}
		},
		onLoad(params) {
			console.log(params);
			this.upperInfo = params
		}
	}
</script>

<style lang="scss">
	.form-area{
		width: 90%;
		margin: 40rpx auto;
		display: flex;
		flex-direction: column;
		view{
			width: 100%;
			display: flex;
			align-items: center;
			margin-bottom: 25rpx;
			h4{
				width: 35%;
				font-weight: normal;
				font-size: 28rpx;
			}
			span{
				font-size: 28rpx;
			}
		}
		view:last-child{
			margin-bottom: 0;
		}
	}
	.sub-btn{
		width: 80%;
		margin: 20vh auto;
		box-sizing: border-box;
		padding: 15rpx 0;
		background-color: #3788FF;
		color: #fff;
		border-radius: 40rpx;
		font-size: 28rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
