| | |
| | | popper-class="pam-time-popper" |
| | | v-model="timeValue" |
| | | :clearable="false" |
| | | :editable="false" |
| | | :picker-options="pickerOptions" |
| | | placeholder="選擇時間" |
| | | prefix-icon="icon-down down-icon" |
| | |
| | | @Prop() |
| | | isPastDateDisabled!: boolean; |
| | | |
| | | @Prop() |
| | | isFutureDateDisabled!: boolean; |
| | | |
| | | /////////////////////////////////////////////////////////////////////// |
| | | |
| | | @Emit('changeTime') |
| | |
| | | |
| | | get pickerOptions() { |
| | | let minTime = ''; |
| | | let maxTime = ''; |
| | | const currentDate = new Date(); |
| | | |
| | | if (this.isPastDateDisabled && this.changeDate && this.isPickedToday(currentDate)) { |
| | | minTime = this.formatTimeString(currentDate); |
| | | this.isPickedDisableTime(currentDate, minTime); |
| | | if (this.changeDate && this.isPickedToday(currentDate)) { |
| | | |
| | | if (this.isPastDateDisabled) { |
| | | minTime = this.formatTimeString(currentDate); |
| | | this.isPickedDisableTime(currentDate, minTime); |
| | | } |
| | | |
| | | if (this.isFutureDateDisabled) { |
| | | maxTime = this.formatTimeString(currentDate); |
| | | this.isPickedDisableTime(currentDate, maxTime); |
| | | } |
| | | |
| | | } |
| | | |
| | | return { |
| | | start: '09:00', |
| | | step: '00:15', |
| | | end: '21:00', |
| | | minTime: minTime |
| | | minTime: minTime, |
| | | maxTime: maxTime |
| | | } |
| | | } |
| | | |
| | | private isPickedDisableTime(currentDate: Date, minTime: string) { |
| | | const currentTime = this.getTimeValue(currentDate, minTime); |
| | | private isPickedDisableTime(currentDate: Date, minMaxTime: string) { |
| | | const currentTime = this.getTimeValue(currentDate, minMaxTime); |
| | | const pickedTime = this.getTimeValue(currentDate, this.timeValue); |
| | | if (pickedTime < currentTime) { |
| | | if (this.isPastDateDisabled && pickedTime < currentTime) { |
| | | this.timeValue = ''; |
| | | this.changeTime(); |
| | | } |
| | | if (this.isFutureDateDisabled && currentTime < pickedTime) { |
| | | this.timeValue = ''; |
| | | this.changeTime(); |
| | | } |