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">
|
2023-07-05 14:45:30 +08:00
|
|
|
<input
|
|
|
|
@change="update"
|
|
|
|
type="datetime"
|
|
|
|
class="form-control calendar-input sci-input-field"
|
|
|
|
:id="this.selectorId"
|
2023-08-23 17:59:21 +08:00
|
|
|
:placeholder="placeholder || 'dd/mm/yyyy'"
|
2023-07-05 14:45:30 +08:00
|
|
|
/>
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-calendar"></i>
|
2021-12-15 19:22:24 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-08-23 17:59:21 +08:00
|
|
|
import '../../../../vendor/assets/javascripts/bootstrap-datetimepicker';
|
|
|
|
|
2021-12-15 19:22:24 +08:00
|
|
|
export default {
|
|
|
|
name: 'DatePicker',
|
|
|
|
props: {
|
2023-08-23 17:59:21 +08:00
|
|
|
placeholder: { type: String },
|
2021-12-15 19:22:24 +08:00
|
|
|
selectorId: { type: String, required: true },
|
2022-02-18 18:25:51 +08:00
|
|
|
useCurrent: { type: Boolean, default: true },
|
2023-07-05 14:30:37 +08:00
|
|
|
defaultValue: { type: Date, default: null }
|
2021-12-15 19:22:24 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
$("#" + this.selectorId).datetimepicker(
|
|
|
|
{
|
|
|
|
useCurrent: this.useCurrent,
|
|
|
|
ignoreReadonly: this.ignoreReadOnly,
|
|
|
|
locale: this.i18n.locale,
|
2023-08-23 17:59:21 +08:00
|
|
|
format: $('body').data('datetime-picker-format'),
|
2022-02-18 18:25:51 +08:00
|
|
|
date: this.defaultValue
|
2021-12-15 19:22:24 +08:00
|
|
|
}
|
2023-07-05 14:30:37 +08:00
|
|
|
);
|
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() : '');
|
2023-07-05 14:30:37 +08:00
|
|
|
},
|
|
|
|
isValidDate(date) {
|
|
|
|
return (date instanceof Date) && !isNaN(date.getTime());
|
|
|
|
},
|
2021-12-15 19:22:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|