From f9a1aa3874b74f1f9f2d67d64220e324b6925985 Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期四, 09 六月 2022 15:42:16 +0800
Subject: [PATCH] TODO#139892 [ FAQ 常見問題 -我如何預約顧問? ] 文案調整

---
 PAMapp/components/Ui/UiTimePicker.vue |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/PAMapp/components/Ui/UiTimePicker.vue b/PAMapp/components/Ui/UiTimePicker.vue
index fee41e2..291fbcd 100644
--- a/PAMapp/components/Ui/UiTimePicker.vue
+++ b/PAMapp/components/Ui/UiTimePicker.vue
@@ -30,6 +30,9 @@
     @Prop()
     isPastDateDisabled!: boolean;
 
+    @Prop()
+    isFutureDateDisabled!: boolean;
+
     ///////////////////////////////////////////////////////////////////////
 
     @Emit('changeTime')
@@ -50,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