Form updates
This commit is contained in:
@@ -188,30 +188,24 @@ const aircraftOptionsData = ref<{ value: number; title: string }[]>(props.flight
|
||||
|
||||
|
||||
watch(() => form.departure_date, (newVal) => {
|
||||
if (!newVal) return
|
||||
if (!newVal || form.arrival_date) return
|
||||
const dep = new Date(newVal)
|
||||
const arr = new Date(dep.getTime() + 60 * 60 * 1000)
|
||||
|
||||
// Format in local time, not UTC
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
form.arrival_date = `${arr.getFullYear()}-${pad(arr.getMonth() + 1)}-${pad(arr.getDate())}T${pad(arr.getHours())}:${pad(arr.getMinutes())}`
|
||||
})
|
||||
|
||||
const arrivalMin = computed(() => {
|
||||
const getArrivalBound = (form, offsetDays: number) => {
|
||||
if (!form.departure_date) return undefined
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
const d = new Date(form.departure_date)
|
||||
d.setDate(d.getDate() - 2)
|
||||
d.setDate(d.getDate() + offsetDays)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
})
|
||||
}
|
||||
|
||||
const arrivalMax = computed(() => {
|
||||
if (!form.departure_date) return undefined
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
const d = new Date(form.departure_date)
|
||||
d.setDate(d.getDate() + 3)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
})
|
||||
const arrivalMin = computed(() => getArrivalBound(form, -2))
|
||||
const arrivalMax = computed(() => getArrivalBound(form, 3))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user