2021-12-15 19:22:24 +08:00
|
|
|
<template>
|
2022-01-17 17:24:57 +08:00
|
|
|
<div class="datepicker sci-input-container right-icon">
|
|
|
|
<input @change="update" type="datetime" class="form-control calendar-input sci-input-field" :id="this.selectorId" placeholder="" />
|
|
|
|
<i class="fas fa-calendar-alt"></i>
|
2021-12-15 19:22:24 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'DatePicker',
|
|
|
|
props: {
|
|
|
|
selectorId: { type: String, required: true },
|
2022-02-18 18:25:51 +08:00
|
|
|
useCurrent: { type: Boolean, default: true },
|
|
|
|
defaultValue: { type: Date, default: true }
|
2021-12-15 19:22:24 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
$("#" + this.selectorId).datetimepicker(
|
|
|
|
{
|
|
|
|
useCurrent: this.useCurrent,
|
|
|
|
ignoreReadonly: this.ignoreReadOnly,
|
|
|
|
locale: this.i18n.locale,
|
2022-02-18 18:25:51 +08:00
|
|
|
format: this.dateFormat,
|
|
|
|
date: this.defaultValue
|
2021-12-15 19:22:24 +08:00
|
|
|
}
|
|
|
|
);
|
2022-02-18 18:25:51 +08:00
|
|
|
this.update($("#" + this.selectorId).data("DateTimePicker").date());
|
2021-12-15 19:22:24 +08:00
|
|
|
$("#" + this.selectorId).on('dp.change', (e) => this.update(e.date))
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
update(value) {
|
2022-02-22 16:40:16 +08:00
|
|
|
this.$emit('change', (value._isAMomentObject) ? value.toDate() : '');
|
2021-12-15 19:22:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|