// 简要情况 - 货代
<template>
	<view class="container">
		<title-status />
		<h-navbar title="简要情况" />
		<nav-button :menus="menuDatas" @itemClick="menuClick"></nav-button>
		<u-form
			labelPosition="left"
			ref="uForm"
			:labelStyle="labelStyle"
			labelWidth="100"
			:model="formData"
			:rules="rules">
			<u-form-item
				label="托运人/公司"
				required
				prop="shipper"
				borderBottom>
				<u-input
					v-model="formData.shipper"
					inputAlign="right"
					placeholder="请输入托运人/公司"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="经办人"
				required
				prop="operator"
				borderBottom>
				<u-input
					v-model="formData.operator"
					inputAlign="right"
					placeholder="请输入经办人"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="运单号"
				required
				prop="waybillNumber"
				borderBottom>
				<u-input
					v-model="formData.waybillNumber"
					inputAlign="right"
					placeholder="请输入运单号"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="始发地"
				required
				prop="beginningPlace"
				borderBottom>
				<u-input
					v-model="formData.beginningPlace"
					inputAlign="right"
					placeholder="请输入始发地"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="目的地"
				required
				prop="destination"
				borderBottom>
				<u-input
					v-model="formData.destination"
					inputAlign="right"
					placeholder="请输入目的地"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="可疑物品"
				required
				prop="suspiciousItems"
				borderBottom>
				<u-input
					v-model="formData.suspiciousItems"
					inputAlign="right"
					placeholder="请输入可疑物品"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="违法嫌疑点"
				required
				prop="suspectedIllegalPoints"
				borderBottom>
				<u-input
					v-model="formData.suspectedIllegalPoints"
					inputAlign="right"
					placeholder="请输入违法嫌疑点"
					border="none"/>
			</u-form-item>
		</u-form>
	</view>
</template>

<script>
	import TitleStatus from '@/components/title-status/title-status'
	import HNavbar from '@/components/h-navbar/h-navbar.vue'
	import NavButton from '@/components/nav-bottom/nav-button.vue'
	
	export default {
		components: {
			TitleStatus,
			HNavbar,
			NavButton
		},
		data() {
			return {
				labelStyle: {
					fontSize: '30rpx',
					color: '#606266',
					fontWeight: '400'
				},
				menuDatas: [
					{
						title: '确定',
						plain: false,
						disabled: false,
						bgColor: '#4983FB'
					}
				],
				formData: {
					// 始发地
					beginningPlace: null,
					// 目的地
					destination: null,
					// 经办人
					operator: null,
					// 托运人
					shipper: null,
					// 违法嫌疑点
					suspectedIllegalPoints: null,
					// 可疑物品
					suspiciousItems: null,
					// 运单号
					waybillNumber: null
				},
				rules: {
					beginningPlace: [
						{
							required: true,
							whitespace: true,
							message: '请输入始发地',
							trigger: ['change','blur'],
						}
					],
					destination: [
						{
							required: true, 
							whitespace: true,
							message: '请输入目的地',
							trigger: ['change','blur'],
						}
					],
					operator: [
						{
							required: true, 
							whitespace: true,
							message: '请输入经办人',
							trigger: ['change','blur'],
						}
					],
					shipper: [
						{
							required: true, 
							whitespace: true,
							message: '请输入托运人/公司',
							trigger: ['change','blur'],
						}
					],
					suspectedIllegalPoints: [
						{
							required: true, 
							whitespace: true,
							message: '请输入违法嫌疑点',
							trigger: ['change','blur'],
						}
					],
					suspiciousItems: [
						{
							required: true, 
							whitespace: true,
							message: '请输入可疑物品',
							trigger: ['change','blur'],
						}
					],
					waybillNumber: [
						{
							required: true, 
							whitespace: true,
							message: '请输入运单号',
							trigger: ['change','blur'],
						}
					]
				}
			}
		},
		onLoad(options) {
			if(options && options.obj && Object.keys(options.obj).length > 0) {
				this.formData = JSON.parse(decodeURIComponent(options.obj))
			}
		},
		methods: {
			menuClick() {
				this.$refs.uForm.validate().then(res => {
					this.getOpenerEventChannel().emit('changeSuccess', this.formData)
					this.$navigate.navigateBack()
				}).catch(errors => {
					// console.log('addSubmit', errors)
					// uni.$u.toast('校验失败')
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/common/css/form.scss";
	.container {
		display: flex;
		flex-direction: column;
	}
</style>
