From 85c39644533f93559ccf51cc4c8dfa7388d36cd4 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 27 四月 2022 14:46:55 +0800
Subject: [PATCH] fix#137058: 顧問管理流程 - 約訪記錄填寫日期需要卡控

---
 PAMapp/components/Ui/UiDatePicker.vue |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/PAMapp/components/Ui/UiDatePicker.vue b/PAMapp/components/Ui/UiDatePicker.vue
index ee2a5a2..890c5ec 100644
--- a/PAMapp/components/Ui/UiDatePicker.vue
+++ b/PAMapp/components/Ui/UiDatePicker.vue
@@ -28,6 +28,12 @@
     @Prop({default: false})
     isPastDateDisabled!: boolean;
 
+    @Prop({default: false})
+    isFutureDateDisabled!: boolean;
+
+    @Prop()
+    disabledBeforeSpecificDate?: string;
+
     @Emit('changeDate')
     changeDate() {
         return this.dateValue;
@@ -42,17 +48,37 @@
     }
 
     get pickerOptions() {
+        const date = new Date();
+        const currentDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
+
+        if (!!this.disabledBeforeSpecificDate) {
+          const compareDate = new Date(this.disabledBeforeSpecificDate);
+          return {
+              disabledDate(time: Date) {
+                  const pickedDate = `${time.getFullYear()}/${time.getMonth() + 1}/${time.getDate()}`;
+                  return new Date(pickedDate).getTime() < compareDate.getTime();
+              }
+          }
+        }
+
         if (this.isPastDateDisabled) {
             return {
                 disabledDate(time: Date) {
-                    const date = new Date();
-                    const currentDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
-                    const pickedDate = `${time.getFullYear()}/${time.getMonth() + 1}/${time.getDate()}`
+                    const pickedDate = `${time.getFullYear()}/${time.getMonth() + 1}/${time.getDate()}`;
                     return new Date(pickedDate).getTime() < new Date(currentDate).getTime();
+                }
+            }
+        }
+
+        if (this.isFutureDateDisabled) {
+            return {
+                disabledDate(time: Date) {
+                    const pickedDate = `${time.getFullYear()}/${time.getMonth() + 1}/${time.getDate()}`;
+                    return new Date(pickedDate).getTime() > new Date(currentDate).getTime();
                 }
             }
         }
     }
 
 }
-</script>
\ No newline at end of file
+</script>

--
Gitblit v1.8.0