From 05e2f32197381cf6caa6115a9172ecc35d4c1ab4 Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Sat, 6 Dec 2025 09:13:28 +0700 Subject: [PATCH] edit-mode: unwrap detail data and use strict type refactor(patient-form): simplify address synchronization logic - Extract address sync logic into helper functions - Remove unused schema imports - Streamline mounted hook with new loadInitData function - Consolidate watchers into single efficient watcher feat(forms): add readonly support across all form components Implement readonly state handling for patient, relative, contact, and address forms Add isDisabled prop to all form fields to support readonly mode Update form components to respect isReadonly prop from parent refactor(patient-form): reorganize imports and improve type usage - Group related imports and move type imports to the top - Replace genPatient with genPatientEntity for better type safety - Remove console.log statement - Fix formatting and indentation issues --- app/components/app/patient/entry-form.vue | 54 ++- .../app/patient/fields/input-name.vue | 2 + .../fields/radio-communication-barrier.vue | 12 +- .../app/patient/fields/radio-disability.vue | 12 +- .../app/patient/fields/radio-nationality.vue | 12 +- .../app/patient/fields/radio-newborn.vue | 17 +- .../app/patient/fields/select-dob.vue | 2 + .../app/patient/fields/select-job.vue | 4 +- .../app/patient/fields/select-lang.vue | 2 + .../patient/fields/select-marital-status.vue | 4 +- .../app/patient/fields/select-religion.vue | 2 + .../person-address/entry-form-relative.vue | 18 +- .../app/person-address/entry-form.vue | 8 + .../app/person-contact/entry-form.vue | 6 +- .../app/person-relative/entry-form.vue | 4 +- .../app/person/family-parents-form.vue | 12 +- .../app/person/fields/radio-parents-input.vue | 10 +- app/components/content/patient/form.vue | 388 +++++++++++------- 18 files changed, 392 insertions(+), 177 deletions(-) diff --git a/app/components/app/patient/entry-form.vue b/app/components/app/patient/entry-form.vue index 26f18c56..341bdcd5 100644 --- a/app/components/app/patient/entry-form.vue +++ b/app/components/app/patient/entry-form.vue @@ -27,8 +27,35 @@ import { } from './fields' interface FormData extends PatientFormData {} + +// Type untuk initial values (sebelum transform schema) +interface PatientFormInput { + identityNumber?: string + drivingLicenseNumber?: string + passportNumber?: string + fullName?: string + isNewBorn?: 'YA' | 'TIDAK' + gender?: string + birthPlace?: string + birthDate?: string + education?: string + job?: string + maritalStatus?: string + nationality?: string + ethnicity?: string + language?: string + religion?: string + communicationBarrier?: 'YA' | 'TIDAK' + disability?: 'YA' | 'TIDAK' + disabilityType?: string + note?: string + residentIdentityFile?: File + familyIdentityFile?: File +} + interface Props { - initialValues?: FormData + isReadonly: boolean + initialValues?: PatientFormInput } const props = defineProps() @@ -37,7 +64,7 @@ const formSchema = toTypedSchema(PatientSchema) const { values, resetForm, setValues, validate } = useForm({ name: 'patientForm', validationSchema: formSchema, - initialValues: props.initialValues && {}, + initialValues: (props.initialValues ?? {}) as any, validateOnMount: false, }) @@ -61,6 +88,7 @@ defineExpose({ label="No. KTP" placeholder="Masukkan NIK" numeric-only + :is-disabled="isReadonly" /> @@ -183,6 +227,7 @@ defineExpose({ placeholder="Unggah scan dokumen KTP" :accept="['pdf', 'jpg', 'png']" :max-size-mb="1" + :is-disabled="isReadonly" /> diff --git a/app/components/app/patient/fields/input-name.vue b/app/components/app/patient/fields/input-name.vue index db9005f1..14a27e63 100644 --- a/app/components/app/patient/fields/input-name.vue +++ b/app/components/app/patient/fields/input-name.vue @@ -17,6 +17,7 @@ defineProps<{ labelClass?: string maxLength?: number isRequired?: boolean + isDisabled?: boolean }>() @@ -40,6 +41,7 @@ defineProps<{ () const { @@ -55,6 +56,7 @@ const genderOptions = [
() const { @@ -55,6 +56,7 @@ const dissabilityOptions = [
() const { @@ -55,6 +56,7 @@ const nationalityOptions = [
() const { @@ -34,7 +35,10 @@ const newbornOptions = [