保誠-保戶業務員媒合平台
Jack
2022-01-18 dc0e7366e96ce773ae1690f6db28e03a684bb45e
PAMapp/components/Ui/UiTimePicker.vue
@@ -14,7 +14,7 @@
</template>
<script lang="ts">
import { Component, Emit, Vue } from "nuxt-property-decorator";
import { Component, Emit, Prop, Vue, Watch } from "nuxt-property-decorator";
@Component
export default class UiTimePicker extends Vue {
@@ -25,9 +25,22 @@
        end: '21:00'
    }
    @Prop()
    defaultValue!: string;
    @Emit('changeTime')
    changeTime() {
        return this.timeValue;
    }
    @Watch('defaultValue', {immediate: true})
    updateDefault() {
        if (this.defaultValue) {
            const hours = new Date(this.defaultValue).getHours();
            const minutes = new Date(this.defaultValue).getMinutes();
            this.timeValue = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}`;
            this.changeTime();
        }
    }
}
</script>