保誠-保戶業務員媒合平台
Mila
2022-01-17 8ece1a33dd0776e8a3cc94d3ac4faf8c6f7ff03c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
 
<template>
    <div class="dateTime">
        <UiDatePicker @changeDate="changeDateTime($event, 'date')"></UiDatePicker>
        <UiTimePicker @changeTime="changeDateTime($event, 'time')"></UiTimePicker>
    </div>
</template>
 
<script lang="ts">
import { Component, Emit, Vue } from "nuxt-property-decorator";
 
@Component
export default class DateTimePicker extends Vue {
    changeDate!: Date;
    changeTime!: string;
 
    @Emit('changeDateTime')
    changeDateTime(event, type) {
        if (type === 'date') {
            this.changeDate = event;
        }
        if (type === 'time') {
            this.changeTime = event;
        }
        if (this.changeDate && this.changeTime) {
            const timeArray = this.changeTime.split(':');
            const interViewTime = this.changeDate.setHours(+timeArray[0], +timeArray[1]);
            return new Date(interViewTime);
        }
        return '';
    }
}
</script>
 
<style lang="scss" scoped>
.dateTime {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    font-size: 20px;
}
</style>