保誠-保戶業務員媒合平台
Jack
2022-01-24 f8ab133a7dc20562c25a092a402266f5e7b0b296
PAMapp/components/DateTimePicker.vue
@@ -4,25 +4,31 @@
    <div class="dateTime">
        <UiDatePicker
            @changeDate="changeDateTime($event, 'date')"
            :isPastDateDisabled="isPastDateDisabled"
            :defaultValue="defaultValue"
        ></UiDatePicker>
        <UiTimePicker
            @changeTime="changeDateTime($event, 'time')"
            :defaultValue="defaultValue"
            :isPastDateDisabled="isPastDateDisabled"
            :changeDate="changeDate"
        ></UiTimePicker>
    </div>
</template>
<script lang="ts">
import { Component, Emit, Prop, Vue } from "nuxt-property-decorator";
import { Component, Emit, Prop, Vue, Watch } from "nuxt-property-decorator";
@Component
export default class DateTimePicker extends Vue {
    changeDate!: Date;
    changeDate: Date | string = '';
    changeTime!: string;
    @Prop()
    defaultValue!: string;
    @Prop()
    isPastDateDisabled!: boolean;
    @Emit('changeDateTime')
    changeDateTime(event, type) {
@@ -33,12 +39,14 @@
            this.changeTime = event;
        }
        if (this.changeDate && this.changeTime) {
            const timeArray = this.changeTime.split(':');
            const interViewTime = this.changeDate.setHours(+timeArray[0], +timeArray[1]);
            const hour = this.changeTime.split(':')[0];
            const minute = this.changeTime.split(':')[1];
            const interViewTime = new Date(this.changeDate).setHours(+hour, +minute);
            return new Date(interViewTime);
        }
        return '';
    }
}
</script>