<template>
	<view class="warp">
		<view class="content1">
			<u-form :model="purchaseOrder" ref="uForm" class="uForm">
				<u-form-item label="任务类型" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<view v-if="type=='移库'" class="title part2">移库出库</view>
				<view v-if="type=='退库'" class="title part2">退库</view>
				<u-form-item label="编号" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='移库'||type=='退库'" label="仓库" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='出库'||type=='移库'" label="出库类型" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='入库'||type=='退库'" label="入库类型" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='移库'" label="移库任务编号" prop="receivingAddress" label-width="180">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item label="合同编号" v-if="type!='移库'" prop="freightUnitPrice" label-width="250">
					<u-input v-model="purchaseOrder.freightUnitPrice" input-align="right" placeholder="请输入运费单价" />
				</u-form-item>
				<u-form-item label="货名" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item label="重量(吨)" prop="receivingAddress" label-width="140">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='出库'||type=='移库'" label="预计出库日期" prop="receivingAddress" label-width="180">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='入库'||type=='退库'" label="预计入库日期" prop="receivingAddress" label-width="180">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='入库'||type=='退库'" label="入库经办人" prop="receivingAddress" label-width="150">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<u-form-item v-if="type=='出库'||type=='移库'" label="出库经办人" prop="receivingAddress" label-width="150">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
				</u-form-item>
				<view class="title part2">可编辑项</view>
				<u-form-item label="品级" prop="receivingAddress" label-width="150">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" @click='show=true' disabled/>
					<u-picker :range="pjList" range-key="type" @confirm='pjPicker($event)' v-model="show" mode="selector">
					</u-picker>
				</u-form-item>
				<u-form-item label="容重(克/升)>=" prop="receivingAddress" label-width="190">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
				</u-form-item>
				<u-form-item label="水分(%)<=" prop="receivingAddress" label-width="160">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
				</u-form-item>
				<u-form-item label="单价(元/吨)" prop="receivingAddress" label-width="160">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
				</u-form-item>
				<u-form-item v-if="type!='移库'&&type!='退库'" label="业务描述" prop="receivingAddress" label-width="160" label-position="top">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="left" placeholder="" type="textarea" class="textarea"/>
				</u-form-item>
				<u-form-item v-if="type!='退库'" label="仓位号(选填)" prop="receivingAddress" label-width="170">
					<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="未指定"/>
				</u-form-item>
				<view v-if="type=='移库'">
					<view class="title part2">移库入库</view>
					<u-form-item label="编号" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="仓库" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="入库类型" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="移库任务编号" prop="receivingAddress" label-width="180">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="货名" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="重量(吨)" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="预计入库时间" prop="receivingAddress" label-width="180">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="入库经办人" prop="receivingAddress" label-width="150">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="品级" prop="receivingAddress" label-width="150">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" @click='show=true' disabled/>
						<u-picker :range="pjList" range-key="type" @confirm='pjPicker($event)' v-model="show" mode="selector">
						</u-picker>
					</u-form-item>
					<u-form-item label="容重(克/升)>=" prop="receivingAddress" label-width="190">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<u-form-item label="水分(%)<=" prop="receivingAddress" label-width="160">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<u-form-item label="单价(元/吨)" prop="receivingAddress" label-width="160">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<view class="title part2">可编辑项</view>
					<u-form-item label="业务描述" prop="receivingAddress" label-width="160" label-position="top">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="left" placeholder="" type="textarea" class="textarea"/>
					</u-form-item>
					<u-form-item label="仓位号(选填)" prop="receivingAddress" label-width="170">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="未指定"/>
					</u-form-item>
				</view>
				<view v-if="type=='退库'">
					<view class="title part2">出</view>
					<u-form-item label="编号" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="仓库" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="出库类型" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="合同编号" prop="receivingAddress" label-width="180">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="货名" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="重量(吨)" prop="receivingAddress" label-width="140">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="预计出库时间" prop="receivingAddress" label-width="180">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="出库经办人" prop="receivingAddress" label-width="150">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" disabled/>
					</u-form-item>
					<u-form-item label="品级" prop="receivingAddress" label-width="150">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="" @click='show=true' disabled/>
						<u-picker :range="pjList" range-key="type" @confirm='pjPicker($event)' v-model="show" mode="selector">
						</u-picker>
					</u-form-item>
					<u-form-item label="容重(克/升)>=" prop="receivingAddress" label-width="190">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<u-form-item label="水分(%)<=" prop="receivingAddress" label-width="160">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<u-form-item label="单价(元/吨)" prop="receivingAddress" label-width="160">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder=""/>
					</u-form-item>
					<view class="title part2">可编辑项</view>
					<u-form-item label="业务描述" prop="receivingAddress" label-width="160" label-position="top">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="left" placeholder="" type="textarea" class="textarea"/>
					</u-form-item>
					<u-form-item label="仓位号(选填)" prop="receivingAddress" label-width="170">
						<u-input v-model="purchaseOrder.receivingAddress" input-align="right" placeholder="未指定"/>
					</u-form-item>
				</view>
			</u-form>
		</view>
		<u-toast ref="uToast" />
		<!-- <u-modal v-model="show" content="确定通过出入库任务？" showCancelButton></u-modal> -->
		<view class="bottom-btn">
<!-- 			<u-button type="primary" class="submit" hover-class="none" @click="rejectSubmit()">驳回</u-button>
			<u-button type="primary" class="submit" hover-class="none" @click="passSubmit()">通过</u-button> -->
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				type:'移库',
				show:false,
				purchaseOrder: {
					freightUnitPrice: "123",
					receivingAddress:'出库',
					grade:"1"
				},
				pjList:[{
					type:'一等品'
				},
				{
					type:'二等品'
				},
				{
					type:'三等品'
				},
				{
					type:'等外'
				}],
				rules: {
					freightUnitPrice: [{
							validator: (rule, value, callback) => {
								return !this.$u.test.isEmpty(value)
							},
							message: '运费不能为空',
							trigger: ['change', 'blur']
						},
						{
							validator: (rule, value, callback) => {
								return this.$u.test.amount(value)
							},
							message: '数值类型，最多保留两位小数',
							trigger: ['change', 'blur'],
						}
					]
				}
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			pjPicker(){},
			passSubmit(){
				this.$refs.uForm.validate(valid => {
					if (valid) {
						// uni.showLoading({
						// 	title: '正在加载',
						// 	mask: true
						// })
						console.log('验证通过');
						
				// 		this.$api.doRequest('post',
				// 			'/freightReceivingDispatching/api/insertFreightReceivingDispatching',
				// 			this
				// 			.purchaseOrder).then(res => {
				// 			if (res.data.code == 200) {
				// 				uni.showToast({
				// 					title: '提交成功',
				// 					icon: 'none',
				// 					duration: 2000,
				// 					success: function() {
				// 						uni.navigateTo({
				// 							url: `/pageA/freightTransport/index`
				// 						})
				// 					}
				// 				})
				
				// 			}
				
				// 		}).catch(res => {
				// 			// uni.showToast({
				// 			// 	title: res.data.message,
				// 			// 	icon: 'none',
				// 			// 	duration: 2000
				// 			// })
				// 		})
					} else {
						console.log('验证失败');
					}
				});
			},
			rejectSubmit(){
				this.$refs.uForm.validate(valid => {
					if (valid) {
						uni.showLoading({
							title: '正在加载',
							mask: true
						})
						console.log('验证通过');
						this.show = true
				// 		this.$api.doRequest('post',
				// 			'/freightReceivingDispatching/api/insertFreightReceivingDispatching',
				// 			this
				// 			.purchaseOrder).then(res => {
				// 			if (res.data.code == 200) {
				// 				uni.showToast({
				// 					title: '提交成功',
				// 					icon: 'none',
				// 					duration: 2000,
				// 					success: function() {
				// 						uni.navigateTo({
				// 							url: `/pageA/freightTransport/index`
				// 						})
				// 					}
				// 				})
				
				// 			}
				
				// 		}).catch(res => {
				// 			// uni.showToast({
				// 			// 	title: res.data.message,
				// 			// 	icon: 'none',
				// 			// 	duration: 2000
				// 			// })
				// 		})
					} else {
						console.log('验证失败');
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.content1,.content2 {
		background-color: #FFFFFF;
		margin: 10rpx;
		padding-bottom: 10rpx;
		border-radius: 20rpx;
		.title {
			font-size: 28rpx;
			font-weight: 600;
			color: #333333;
			text-align: center;
		}
	}
	.uForm {
		padding: 0 40rpx;
	}
	.u-form-item{
		padding: 0;
	}
	.bottom-btn {
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		display: flex;
		z-index: 2;
	}
	.submit {
		width: 40%;
		background: #22C572;
		border-radius: 10rpx;
	}
	.part2{
		margin-top: 20rpx;
	}
	.textarea{
		border: 1px solid #ccc;
	}
</style>
