From a973040ec6b1d92b1440132d77fe41072585c1a0 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期六, 22 一月 2022 11:40:46 +0800 Subject: [PATCH] fixed TODO#134578 約訪通知 : 預計約訪時段不可選擇過去時間 --- PAMapp/components/Ui/UiDatePicker.vue | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/PAMapp/components/Ui/UiDatePicker.vue b/PAMapp/components/Ui/UiDatePicker.vue index ef89297..20132bc 100644 --- a/PAMapp/components/Ui/UiDatePicker.vue +++ b/PAMapp/components/Ui/UiDatePicker.vue @@ -8,13 +8,14 @@ format="yyyy/MM/dd" placeholder="������" prefix-icon="icon-down down-icon" + :picker-options="pickerOptions" @change="changeDate" > </el-date-picker> </template> <script lang="ts"> -import { Component, Emit, Prop, Vue, Watch } from "nuxt-property-decorator"; +import { Component, Emit, Prop, PropSync, Vue, Watch } from "nuxt-property-decorator"; @Component export default class UiDatePicker extends Vue { @@ -22,6 +23,9 @@ @Prop() defaultValue!: string; + + @Prop({default: false}) + isPastDateDisabled!: boolean; @Emit('changeDate') changeDate() { @@ -35,5 +39,19 @@ this.changeDate(); } } + + get pickerOptions() { + 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()}` + return new Date(pickedDate).getTime() < new Date(currentDate).getTime(); + } + } + } + } + } </script> \ No newline at end of file -- Gitblit v1.8.0