// 查获位置 - 货代
<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="130"
			:model="formData"
			:rules="rules">
			<u-form-item
				label="检查通道（号）"
				required
				prop="checkPoint"
				borderBottom>
				<u-input
					v-model="formData.checkPoint"
					inputAlign="right"
					placeholder="请输入几号检查通道"
					border="none"/>
			</u-form-item>
			<u-form-item
				label="岗位"
				required
				prop="postName"
				borderBottom>
				<u-input
					v-model="formData.postName"
					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: {
					checkPoint: null,
					postName: null
				},
				rules: {
					checkPoint: [
						{
							required: true,
							whitespace: true,
							message: '请输入检查通道',
							trigger: ['change','blur'],
						}
					],
					postName: [
						{
							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>
