<template>
	<view>
		<view class="box">
			<view class="item">
				<view class="l">订单号：</view>
				<view class="r">
					{{form.no}}
				</view>
			</view>
			<view class="item">
				<view class="l" style="flex: 7;"><text style="color: red;">*</text>境外车入场时间：</view>
				<view class="r">
					<uni-datetime-picker placeholder="入场时间" type="datetime" v-model="form.realInTime" />
				</view>
			</view>
			<view class="item">
				<view class="l" style="flex: 7;"><text style="color: red;">*</text>中国车入场时间：</view>
				<view class="r">
					<uni-datetime-picker placeholder="入场时间" type="datetime" v-model="form.chinaCarInTime" />
				</view>
			</view>
		</view>
		<u-button type="primary" @click="confirmFn">确认</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				form: {
					realInTime: new Date(),
					chinaCarInTime: new Date()
				},
			}
		},
		onLoad(options) {
			this.id = options.id;
		},
		onShow() {
			this.getBusinessById();
		},
		methods: {
			getBusinessById() {
				this.$api.getBusinessById({
					id: this.id
				}).then(resp => {
					this.form = resp.data;
				})
			},
			confirmFn() {
				let realInTime = this.form.realInTime;
				let chinaCarInTime = this.form.chinaCarInTime;
				if (!realInTime||realInTime.length<=12) {
					this.$common.toast('境外车入场时间不正确')
					return;
				}
				if (!chinaCarInTime||chinaCarInTime.length<=12) {
					this.$common.toast('中国车入场时间不正确')
					return;
				}
				this.$api.adminSetIn(this.form).then(Resp => {
					this.$common.toast('操作成功');
					setTimeout(() => {
						this.$common.back()
					}, 500)
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	@import '@/common/common.scss'
</style>
