diff --git a/app/components/app/consultation/entry.vue b/app/components/app/consultation/entry.vue index db983ef1..db93e1e2 100644 --- a/app/components/app/consultation/entry.vue +++ b/app/components/app/consultation/entry.vue @@ -27,16 +27,19 @@ const emit = defineEmits<{ cancel: [resetForm: () => void] }>() +const today = new Date() const { defineField, errors, meta } = useForm({ validationSchema: toTypedSchema(props.schema), initialValues: { id: 0, encounter_id: 0, + date: props.values.date || today.toISOString().slice(0, 10), problem: '', unit_id: 0, } as Partial, }) +const [date, dateAttrs] = defineField('date') const [unit_id, unitAttrs] = defineField('unit_id') const [problem, problemAttrs] = defineField('problem') @@ -47,6 +50,7 @@ if (props.values) { } const resetForm = () => { + date.value = date.value ?? today.toISOString().slice(0, 10) unit_id.value = 0 problem.value = '' } @@ -56,6 +60,7 @@ function onSubmitForm(values: any) { const formData: ConsultationFormData = { id: 0, encounter_id: 0, + date: date.value || '', problem: problem.value || '', unit_id: unit_id.value || 0, } @@ -71,16 +76,15 @@ function onCancelForm() {