diff --git a/app/components/app/installation/entry-form.vue b/app/components/app/installation/entry-form.vue index c32b9ad9..ac0d068b 100644 --- a/app/components/app/installation/entry-form.vue +++ b/app/components/app/installation/entry-form.vue @@ -15,6 +15,7 @@ import { useForm } from 'vee-validate' interface Props { schema: z.ZodSchema + encounterClasses: any[] values: any isLoading?: boolean isReadonly?: boolean diff --git a/app/components/content/installation/list.vue b/app/components/content/installation/list.vue index ef580cf8..7c3986e0 100644 --- a/app/components/content/installation/list.vue +++ b/app/components/content/installation/list.vue @@ -28,6 +28,7 @@ import { handleActionRemove, handleCancelForm, } from '~/handlers/installation.handler' +import { encounterClasses, getEncounterClassList } from '~/handlers/_shared.handler' // Services import { getInstallations, getInstallationDetail } from '~/services/installation.service' @@ -110,6 +111,7 @@ watch([recId, recAction], () => { }) onMounted(async () => { + await getEncounterClassList(); await getInstallationList() }) @@ -124,9 +126,15 @@ onMounted(async () => { /> - + ([]) -const medicineMethods = ref<{ value: string; label: string }[]>([]) -const uoms = ref<{ value: string; label: string }[]>([]) const title = ref('') const { @@ -99,36 +101,6 @@ const getCurrentMedicineDetail = async (id: number | string) => { } } -const getMedicineGroupList = async () => { - const result = await getMedicineGroups() - if (result.success) { - const currentMedicineGroups = result.body?.data || [] - medicineGroups.value = currentMedicineGroups.map((medicineGroup: MedicineGroup) => ({ - value: medicineGroup.code, - label: medicineGroup.name, - })) - } -} - -const getMedicineMethodList = async () => { - const result = await getMedicineMethods() - if (result.success) { - const currentMedicineMethods = result.body?.data || [] - medicineMethods.value = currentMedicineMethods.map((medicineMethod: MedicineMethod) => ({ - value: medicineMethod.code, - label: medicineMethod.name, - })) - } -} - -const getUomList = async () => { - const result = await getUoms() - if (result.success) { - const currentUoms = result.body?.data || [] - uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name })) - } -} - watch([recId, recAction], () => { switch (recAction.value) { case ActionEvents.showDetail: diff --git a/app/handlers/_shared.handler.ts b/app/handlers/_shared.handler.ts index 0e421d0f..05599509 100644 --- a/app/handlers/_shared.handler.ts +++ b/app/handlers/_shared.handler.ts @@ -1,14 +1,42 @@ // types +import type { MedicineGroup } from '~/models/medicine-group' +import type { MedicineMethod } from '~/models/medicine-method' import type { Uom } from '~/models/uom' // services +import { getMedicineGroups } from '~/services/medicine-group.service' +import { getMedicineMethods } from '~/services/medicine-method.service' import { getUoms } from '~/services/uom.service' import { getEncounters } from '~/services/encounter.service' // variables +export const medicineGroups = ref<{ value: string; label: string }[]>([]) +export const medicineMethods = ref<{ value: string; label: string }[]>([]) export const uoms = ref<{ value: string; label: string }[]>([]) export const encounterClasses = ref<{ value: string; label: string }[]>([]) +export const getMedicineGroupList = async () => { + const result = await getMedicineGroups() + if (result.success) { + const currentMedicineGroups = result.body?.data || [] + medicineGroups.value = currentMedicineGroups.map((medicineGroup: MedicineGroup) => ({ + value: medicineGroup.code, + label: medicineGroup.name, + })) + } +} + +export const getMedicineMethodList = async () => { + const result = await getMedicineMethods() + if (result.success) { + const currentMedicineMethods = result.body?.data || [] + medicineMethods.value = currentMedicineMethods.map((medicineMethod: MedicineMethod) => ({ + value: medicineMethod.code, + label: medicineMethod.name, + })) + } +} + export const getUomList = async () => { const result = await getUoms() if (result.success) {