From 73307b0ada907f8ac857b3dfc4e7d50e3b7b92e9 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期一, 24 一月 2022 16:24:52 +0800 Subject: [PATCH] Merge branch 'Phase3' of https://dev.pollex.com.tw:8443/r/pcalife/PAM into Phase3 --- PAMapp/components/Ui/UiTimePicker.vue | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/PAMapp/components/Ui/UiTimePicker.vue b/PAMapp/components/Ui/UiTimePicker.vue index b661e00..291fbcd 100644 --- a/PAMapp/components/Ui/UiTimePicker.vue +++ b/PAMapp/components/Ui/UiTimePicker.vue @@ -4,6 +4,7 @@ popper-class="pam-time-popper" v-model="timeValue" :clearable="false" + :editable="false" :picker-options="pickerOptions" placeholder="������" prefix-icon="icon-down down-icon" @@ -29,6 +30,9 @@ @Prop() isPastDateDisabled!: boolean; + @Prop() + isFutureDateDisabled!: boolean; + /////////////////////////////////////////////////////////////////////// @Emit('changeTime') @@ -49,25 +53,40 @@ 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(); } -- Gitblit v1.8.0