diff --git a/src/frontend/src/components/fields/DateField.vue b/src/frontend/src/components/fields/DateField.vue index 4681cf78..98bd5de7 100644 --- a/src/frontend/src/components/fields/DateField.vue +++ b/src/frontend/src/components/fields/DateField.vue @@ -1,27 +1,36 @@ - + @@ -29,45 +38,45 @@ import { computed } from 'vue'; import DatePicker from 'primevue/datepicker'; +defineOptions({ + inheritAttrs: false +}); + const props = defineProps<{ + id?: string; label?: string; - modelValue?: string; + modelValue?: string | Date; + placeholder?: string; required?: boolean; - readonly?: boolean; disabled?: boolean; showTodayBtn?: boolean; }>(); const emit = defineEmits(['update:modelValue', 'change']); -const parsedDate = computed(() => { +const dateValue = computed(() => { if (!props.modelValue) return null; + if (props.modelValue instanceof Date) return props.modelValue; const d = new Date(props.modelValue); return isNaN(d.getTime()) ? null : d; }); -const handleChange = (val: any) => { +const onDateChange = (val: Date | null) => { if (!val) { emit('update:modelValue', ''); emit('change', ''); return; } - let dateStr = ''; - if (val instanceof Date) { - const yyyy = val.getFullYear(); - const mm = String(val.getMonth() + 1).padStart(2, '0'); - const dd = String(val.getDate()).padStart(2, '0'); - dateStr = `${yyyy}-${mm}-${dd}`; - } else { - dateStr = String(val); - } - emit('update:modelValue', dateStr); - emit('change', dateStr); + const yyyy = val.getFullYear(); + const mm = String(val.getMonth() + 1).padStart(2, '0'); + const dd = String(val.getDate()).padStart(2, '0'); + const strVal = `${yyyy}-${mm}-${dd}`; + emit('update:modelValue', strVal); + emit('change', strVal); }; const setToday = () => { - const today = new Date().toISOString().substring(0, 10); - emit('update:modelValue', today); - emit('change', today); + const d = new Date(); + onDateChange(d); }; diff --git a/src/frontend/src/components/fields/StringField.vue b/src/frontend/src/components/fields/StringField.vue index 45774d63..a002cce8 100644 --- a/src/frontend/src/components/fields/StringField.vue +++ b/src/frontend/src/components/fields/StringField.vue @@ -1,40 +1,48 @@ - + diff --git a/src/frontend/src/components/primitives/DialogModal.vue b/src/frontend/src/components/primitives/DialogModal.vue index 7370c7e7..55244ff2 100644 --- a/src/frontend/src/components/primitives/DialogModal.vue +++ b/src/frontend/src/components/primitives/DialogModal.vue @@ -1,8 +1,9 @@ - +