diff --git a/app/components/app/installation/entry-form.vue b/app/components/app/installation/entry-form.vue index ac0d068b..fe853bb0 100644 --- a/app/components/app/installation/entry-form.vue +++ b/app/components/app/installation/entry-form.vue @@ -4,6 +4,7 @@ import Block from '~/components/pub/custom-ui/doc-entry/block.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue' import Label from '~/components/pub/custom-ui/doc-entry/label.vue' +import Combobox from '~/components/pub/custom-ui/form/combobox.vue' // Types import type { InstallationFormData } from '~/schemas/installation.schema.ts' @@ -86,6 +87,21 @@ function onCancelForm() { + + + + + +
diff --git a/app/components/app/specialist/entry-form.vue b/app/components/app/specialist/entry-form.vue index 7254ec98..6f02c425 100644 --- a/app/components/app/specialist/entry-form.vue +++ b/app/components/app/specialist/entry-form.vue @@ -4,7 +4,7 @@ import Block from '~/components/pub/custom-ui/doc-entry/block.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue' import Label from '~/components/pub/custom-ui/doc-entry/label.vue' -// import Combobox from '~/components/pub/custom-ui/form/combobox.vue' +import Combobox from '~/components/pub/custom-ui/form/combobox.vue' // Types import type { SpecialistFormData } from '~/schemas/specialist.schema.ts' @@ -90,24 +90,15 @@ function onCancelForm() { - - diff --git a/app/components/app/unit/entry-form.vue b/app/components/app/unit/entry-form.vue index 7bad3552..5f9e86ff 100644 --- a/app/components/app/unit/entry-form.vue +++ b/app/components/app/unit/entry-form.vue @@ -4,6 +4,7 @@ import Block from '~/components/pub/custom-ui/doc-entry/block.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue' import Label from '~/components/pub/custom-ui/doc-entry/label.vue' +import Combobox from '~/components/pub/custom-ui/form/combobox.vue' // Types import type { UnitFormData } from '~/schemas/unit.schema.ts' @@ -15,6 +16,7 @@ import { useForm } from 'vee-validate' interface Props { schema: z.ZodSchema + installations: any[] values: any isLoading?: boolean isReadonly?: boolean @@ -33,13 +35,13 @@ const { defineField, errors, meta } = useForm({ initialValues: { code: '', name: '', - installation: '', + installation_id: 0, } as Partial, }) const [code, codeAttrs] = defineField('code') const [name, nameAttrs] = defineField('name') -const [installation, installationAttrs] = defineField('installation') +const [installation, installationAttrs] = defineField('installation_id') // Fill fields from props.values if provided if (props.values) { @@ -59,7 +61,7 @@ function onSubmitForm(values: any) { const formData: UnitFormData = { name: name.value || '', code: code.value || '', - installation: installation.value || '', + installation_id: installation.value || '', } emit('submit', formData, resetForm) } @@ -85,6 +87,21 @@ function onCancelForm() { + + + + + +
diff --git a/app/components/content/specialist/list.vue b/app/components/content/specialist/list.vue index d1c3bb21..b6d7048a 100644 --- a/app/components/content/specialist/list.vue +++ b/app/components/content/specialist/list.vue @@ -13,7 +13,6 @@ import { toast } from '~/components/pub/ui/toast' // Types import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types' import { SpecialistSchema, type SpecialistFormData } from '~/schemas/specialist.schema' -import type { Unit } from '~/models/unit' // Handlers import { @@ -29,12 +28,11 @@ import { handleActionRemove, handleCancelForm, } from '~/handlers/specialist.handler' +import { units, getUnitList } from '~/handlers/_shared.handler' // Services import { getSpecialists, getSpecialistDetail } from '~/services/specialist.service' -import { getUnits } from '~/services/unit.service' -const units = ref<{ value: string; label: string }[]>([]) const title = ref('') const { @@ -93,14 +91,6 @@ const getCurrentSpecialistDetail = async (id: number | string) => { } } -const getUnitList = async () => { - const result = await getUnits() - if (result.success) { - const currentUnits = result.body?.data || [] - units.value = currentUnits.map((item: Unit) => ({ value: item.id ? Number(item.id) : item.code, label: item.name })) - } -} - // Watch for row actions when recId or recAction changes watch([recId, recAction], () => { switch (recAction.value) { diff --git a/app/components/content/subspecialist/list.vue b/app/components/content/subspecialist/list.vue index ad38241f..ec8520fd 100644 --- a/app/components/content/subspecialist/list.vue +++ b/app/components/content/subspecialist/list.vue @@ -13,7 +13,6 @@ import { toast } from '~/components/pub/ui/toast' // Types import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types' import { SubspecialistSchema, type SubspecialistFormData } from '~/schemas/subspecialist.schema' -import type { Specialist } from '~/models/specialist' // Handlers import { @@ -29,12 +28,11 @@ import { handleActionRemove, handleCancelForm, } from '~/handlers/subspecialist.handler' +import { specialists, getSpecialistsList } from '~/handlers/_shared.handler' // Services import { getSubspecialists, getSubspecialistDetail } from '~/services/subspecialist.service' -import { getSpecialists } from '~/services/specialist.service' -const specialists = ref<{ value: string; label: string }[]>([]) const title = ref('') const { @@ -93,17 +91,6 @@ const getCurrentSubSpecialistDetail = async (id: number | string) => { } } -const getSpecialistsList = async () => { - const result = await getSpecialists() - if (result.success) { - const currentSpecialists = result.body?.data || [] - specialists.value = currentSpecialists.map((item: Specialist) => ({ - value: item.id ? Number(item.id) : item.code, - label: item.name, - })) - } -} - // Watch for row actions when recId or recAction changes watch([recId, recAction], () => { switch (recAction.value) { diff --git a/app/components/content/unit/list.vue b/app/components/content/unit/list.vue index 3dcd184d..0ecde4c5 100644 --- a/app/components/content/unit/list.vue +++ b/app/components/content/unit/list.vue @@ -28,6 +28,7 @@ import { handleActionRemove, handleCancelForm, } from '~/handlers/unit.handler' +import { installations, getInstallationList } from '~/handlers/_shared.handler' // Services import { getUnits, getUnitDetail } from '~/services/unit.service' @@ -110,6 +111,7 @@ watch([recId, recAction], () => { }) onMounted(async () => { + await getInstallationList() await getUnitList() }) @@ -127,6 +129,7 @@ onMounted(async () => { ([]) 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 installations = ref<{ value: string; label: string }[]>([]) +export const specialists = ref<{ value: string; label: string }[]>([]) +export const uoms = ref<{ value: string; label: string }[]>([]) +export const units = ref<{ value: string; label: string }[]>([]) export const getMedicineGroupList = async () => { const result = await getMedicineGroups() @@ -37,14 +46,6 @@ export const getMedicineMethodList = async () => { } } -export 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 })) - } -} - export const getEncounterClassList = async () => { const result = await getEncounters() if (result.success) { @@ -52,3 +53,41 @@ export const getEncounterClassList = async () => { encounterClasses.value = currentValues.map((item: any) => ({ value: item.code || item.id, label: item.name })) } } + +export const getInstallationList = async () => { + const result = await getInstallations() + if (result.success) { + const currentInstallations = result.body?.data || [] + installations.value = currentInstallations.map((item: Installation) => ({ + value: item.id ? Number(item.id) : item.code, + label: item.name, + })) + } +} + +export const getSpecialistsList = async () => { + const result = await getSpecialists() + if (result.success) { + const currentSpecialists = result.body?.data || [] + specialists.value = currentSpecialists.map((item: Specialist) => ({ + value: item.id ? Number(item.id) : item.code, + label: item.name, + })) + } +} + +export const getUnitList = async () => { + const result = await getUnits() + if (result.success) { + const currentUnits = result.body?.data || [] + units.value = currentUnits.map((item: Unit) => ({ value: item.id ? Number(item.id) : item.code, label: item.name })) + } +} + +export 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 })) + } +} diff --git a/app/models/installation.ts b/app/models/installation.ts index 3b027962..bb6e3786 100644 --- a/app/models/installation.ts +++ b/app/models/installation.ts @@ -1,4 +1,5 @@ export interface Installation { + id?: number | null code: string name: string encounterClass_code?: string | null diff --git a/app/models/unit.ts b/app/models/unit.ts index 27348354..dca2a771 100644 --- a/app/models/unit.ts +++ b/app/models/unit.ts @@ -2,5 +2,5 @@ export interface Unit { id?: number code: string name: string - installation?: string | number + installation_id?: string | number } diff --git a/app/schemas/unit.schema.ts b/app/schemas/unit.schema.ts index 30a5a075..ec6c80d4 100644 --- a/app/schemas/unit.schema.ts +++ b/app/schemas/unit.schema.ts @@ -4,6 +4,7 @@ import type { Unit } from '~/models/unit' const UnitSchema = z.object({ code: z.string({ required_error: 'Kode harus diisi' }).min(1, 'Kode minimum 1 karakter'), name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'), + installation_id: z.number().min(1, 'Instalasi harus diisi').nullable(), }) type UnitFormData = z.infer & Unit