fix: list integration

This commit is contained in:
riefive
2025-10-02 14:12:10 +07:00
parent fc3bda14f4
commit 693d8225bf
13 changed files with 91 additions and 22 deletions
@@ -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 { DivisionFormData } from '~/schemas/division.schema.ts'
@@ -15,6 +16,7 @@ import { useForm } from 'vee-validate'
interface Props {
schema: z.ZodSchema<any>
divisions: any[]
values: any
isLoading?: boolean
isReadonly?: boolean
@@ -85,6 +87,21 @@ function onCancelForm() {
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
</Field>
</Cell>
<Cell>
<Label height="compact">Divisi Induk</Label>
<Field :errMessage="errors.division">
<Combobox
id="division"
v-model="division"
v-bind="divisionAttrs"
:items="divisions"
:disabled="isLoading || isReadonly"
placeholder="Pilih Divisi Induk"
search-placeholder="Cari divisi"
empty-message="Divisi tidak ditemukan"
/>
</Field>
</Cell>
</Block>
<div class="my-2 flex justify-end gap-2 py-2">
<Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
+4 -8
View File
@@ -12,11 +12,11 @@ type SmallDetailDto = any
const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-ud.vue'))
export const cols: Col[] = [{ width: 100 }, {}, {}, { width: 50 }]
export const cols: Col[] = [{}, {}, {}, { width: 50 }]
export const header: Th[][] = [[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Divisi Induk' }, { label: '' }]]
export const keys = ['code', 'name', 'ancestor', 'action']
export const keys = ['code', 'name', 'parent', 'action']
export const delKeyNames: KeyLabel[] = [
{ key: 'code', label: 'Kode' },
@@ -24,13 +24,9 @@ export const delKeyNames: KeyLabel[] = [
]
export const funcParsed: RecStrFuncUnknown = {
ancestor: (rec: unknown): unknown => {
parent: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
if (recX.meta === null) {
return '-'
}
return recX.meta.name
return recX.parent?.name || '-'
},
}
+3
View File
@@ -28,6 +28,7 @@ import {
handleActionRemove,
handleCancelForm,
} from '~/handlers/division.handler'
import { divisions, getDivisionParentList } from '~/handlers/_shared.handler'
// Services
import { getDivisions, getDivisionDetail } from '~/services/division.service'
@@ -111,6 +112,7 @@ watch([recId, recAction], () => {
onMounted(async () => {
await getDivisionList()
await getDivisionParentList(false, data.value || [])
})
</script>
@@ -127,6 +129,7 @@ onMounted(async () => {
<Dialog v-model:open="isFormEntryDialogOpen" :title="!!recItem ? title : 'Tambah Divisi'" size="lg" prevent-outside>
<AppDivisionEntryForm
:schema="DivisionSchema"
:divisions="divisions"
:values="recItem"
:is-loading="isProcessing"
:is-readonly="isReadonly"
+2 -2
View File
@@ -29,7 +29,7 @@ import {
handleActionRemove,
handleCancelForm,
} from '~/handlers/material.handler'
import { uoms, getUomList } from "~/handlers/_shared.handler"
import { uoms, getUomList } from '~/handlers/_shared.handler'
// Services
import { getMaterials, getMaterialDetail } from '~/services/material.service'
@@ -112,8 +112,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getUomList()
await getEquipmentList()
await getUomList()
})
</script>
+1 -1
View File
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getEncounterClassConstants()
await getInstallationList()
await getEncounterClassConstants()
})
</script>
+6 -2
View File
@@ -55,7 +55,11 @@ const {
fetchData: getMedicineList,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getMedicines({ search: params.search, page: params['page-number'] || 0, includes: 'medicineGroup,medicineMethod,uom' })
const result = await getMedicines({
search: params.search,
page: params['page-number'] || 0,
includes: 'medicineGroup,medicineMethod,uom',
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'medicine',
@@ -120,10 +124,10 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getMedicineList()
await getMedicineGroupList()
await getMedicineMethodList()
await getUomList()
await getMedicineList()
})
</script>
+1 -1
View File
@@ -112,8 +112,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getUnitList()
await getSpecialistList()
await getUnitList()
})
</script>
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getSpecialistsList()
await getSubSpecialistList()
await getSpecialistsList()
})
</script>
+1 -1
View File
@@ -116,8 +116,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getUomList()
await getToolsList()
await getUomList()
})
</script>
+1 -1
View File
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
await getInstallationList()
await getUnitList()
await getInstallationList()
})
</script>
+3 -2
View File
@@ -33,7 +33,7 @@ export function createCrudHandler<T = any>(crud: {
if (refresh) refresh()
},
onFinally: (isSuccess: boolean) => {
if (isSuccess) setTimeout(reset, 500)
setTimeout(reset, 300)
isProcessing.value = false
},
})
@@ -58,7 +58,7 @@ export function createCrudHandler<T = any>(crud: {
if (refresh) refresh()
},
onFinally: (isSuccess: boolean) => {
if (isSuccess) setTimeout(reset, 500)
setTimeout(reset, 300)
isProcessing.value = false
},
})
@@ -77,6 +77,7 @@ export function createCrudHandler<T = any>(crud: {
if (refresh) refresh()
},
onFinally: () => {
setTimeout(refresh, 300)
isProcessing.value = false
},
})
+20
View File
@@ -1,6 +1,7 @@
// types
import type { MedicineGroup } from '~/models/medicine-group'
import type { MedicineMethod } from '~/models/medicine-method'
import type { Division } from '~/models/division'
import type { Installation } from '~/models/installation'
import type { Specialist } from '~/models/specialist'
import type { Uom } from '~/models/uom'
@@ -13,6 +14,7 @@ import { encounterClassCodes } from '~/lib/constants'
import { getMedicineGroups } from '~/services/medicine-group.service'
import { getMedicineMethods } from '~/services/medicine-method.service'
import { getEncounters } from '~/services/encounter.service'
import { getDivisions } from '~/services/division.service'
import { getInstallations } from '~/services/installation.service'
import { getSpecialists } from '~/services/specialist.service'
import { getUoms } from '~/services/uom.service'
@@ -22,6 +24,7 @@ import { getUnits } from '~/services/unit.service'
export const medicineGroups = ref<{ value: string; label: string }[]>([])
export const medicineMethods = ref<{ value: string; label: string }[]>([])
export const encounterClasses = ref<{ value: string; label: string }[]>([])
export const divisions = 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 }[]>([])
@@ -49,6 +52,23 @@ export const getMedicineMethodList = async () => {
}
}
export const getDivisionParentList = async (isFetch = true, externalDivisions: any[] = []) => {
if (isFetch) {
const result = await getDivisions()
if (result.success) {
const currentDivisions = result.body?.data || []
divisions.value = currentDivisions.map((division: Division) => ({
value: division.code,
label: division.name,
}))
}
}
divisions.value = externalDivisions.map((division: Division) => ({
value: division.code,
label: division.name,
}))
}
export const getEncounterClassList = async () => {
const result = await getEncounters()
if (result.success) {
+31 -3
View File
@@ -1,5 +1,33 @@
import { createCrudHandler } from '~/handlers/_handler'
import { postDivision, patchDivision, removeDivision } from '~/services/division.service'
import {
postDivisionPosition,
patchDivisionPosition,
removeDivisionPosition,
} from '~/services/division-position.service'
function selectPost(payload: any) {
if (payload.division_id && Number(payload.division_id) > 0) {
return postDivisionPosition
}
delete payload.division_id;
return postDivision
}
function selectPatch(id: number | string, payload: any) {
if (payload.division_id && Number(payload.division_id) > 0) {
return patchDivisionPosition
}
delete payload.division_id;
return patchDivision
}
function selectRemove(payload: any) {
if (payload.division_id && Number(payload.division_id) > 0) {
return removeDivisionPosition
}
return removeDivision
}
export const {
recId,
@@ -15,7 +43,7 @@ export const {
handleActionRemove,
handleCancelForm,
} = createCrudHandler({
post: postDivision,
patch: patchDivision,
remove: removeDivision,
post: (payload: any) => selectPost(payload)(payload),
patch: (id: number | string, payload: any) => selectPatch(id, payload)(id, payload),
remove: (payload: any) => selectRemove(payload)(payload),
})