Feat:旅居日期选了开始日期自动选择结束日期
This commit is contained in:
@@ -318,6 +318,16 @@ export default {
|
|||||||
|
|
||||||
const selectedDate = this.getDateFromDay(day)
|
const selectedDate = this.getDateFromDay(day)
|
||||||
|
|
||||||
|
// 如果设置了最小预订天数,则自动计算结束日期
|
||||||
|
if (this.minBookingDays > 0) {
|
||||||
|
this.tempStartDate = selectedDate
|
||||||
|
const endDate = new Date(selectedDate)
|
||||||
|
endDate.setDate(selectedDate.getDate() + this.minBookingDays - 1)
|
||||||
|
this.tempEndDate = endDate
|
||||||
|
this.selectionState = 'completed'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 如果已有完整的日期区间(开始日期和结束日期都存在),重置选择
|
// 如果已有完整的日期区间(开始日期和结束日期都存在),重置选择
|
||||||
if (this.tempStartDate && this.tempEndDate && this.selectionState === 'completed') {
|
if (this.tempStartDate && this.tempEndDate && this.selectionState === 'completed') {
|
||||||
// 重置选择状态,将点击的日期作为新的开始日期
|
// 重置选择状态,将点击的日期作为新的开始日期
|
||||||
|
|||||||
Reference in New Issue
Block a user