fix: list integration
This commit is contained in:
No files matched your search
@@ -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 Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
|
||||||
import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
|
import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
|
||||||
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
|
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
|
||||||
|
import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import type { DivisionFormData } from '~/schemas/division.schema.ts'
|
import type { DivisionFormData } from '~/schemas/division.schema.ts'
|
||||||
@@ -15,6 +16,7 @@ import { useForm } from 'vee-validate'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
schema: z.ZodSchema<any>
|
schema: z.ZodSchema<any>
|
||||||
|
divisions: any[]
|
||||||
values: any
|
values: any
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
isReadonly?: boolean
|
isReadonly?: boolean
|
||||||
@@ -85,6 +87,21 @@ function onCancelForm() {
|
|||||||
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
|
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
|
||||||
</Field>
|
</Field>
|
||||||
</Cell>
|
</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>
|
</Block>
|
||||||
<div class="my-2 flex justify-end gap-2 py-2">
|
<div class="my-2 flex justify-end gap-2 py-2">
|
||||||
<Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
|
<Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ type SmallDetailDto = any
|
|||||||
|
|
||||||
const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-ud.vue'))
|
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 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[] = [
|
export const delKeyNames: KeyLabel[] = [
|
||||||
{ key: 'code', label: 'Kode' },
|
{ key: 'code', label: 'Kode' },
|
||||||
@@ -24,13 +24,9 @@ export const delKeyNames: KeyLabel[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export const funcParsed: RecStrFuncUnknown = {
|
export const funcParsed: RecStrFuncUnknown = {
|
||||||
ancestor: (rec: unknown): unknown => {
|
parent: (rec: unknown): unknown => {
|
||||||
const recX = rec as SmallDetailDto
|
const recX = rec as SmallDetailDto
|
||||||
if (recX.meta === null) {
|
return recX.parent?.name || '-'
|
||||||
return '-'
|
|
||||||
}
|
|
||||||
|
|
||||||
return recX.meta.name
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
handleCancelForm,
|
||||||
} from '~/handlers/division.handler'
|
} from '~/handlers/division.handler'
|
||||||
|
import { divisions, getDivisionParentList } from '~/handlers/_shared.handler'
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getDivisions, getDivisionDetail } from '~/services/division.service'
|
import { getDivisions, getDivisionDetail } from '~/services/division.service'
|
||||||
@@ -111,6 +112,7 @@ watch([recId, recAction], () => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getDivisionList()
|
await getDivisionList()
|
||||||
|
await getDivisionParentList(false, data.value || [])
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -127,6 +129,7 @@ onMounted(async () => {
|
|||||||
<Dialog v-model:open="isFormEntryDialogOpen" :title="!!recItem ? title : 'Tambah Divisi'" size="lg" prevent-outside>
|
<Dialog v-model:open="isFormEntryDialogOpen" :title="!!recItem ? title : 'Tambah Divisi'" size="lg" prevent-outside>
|
||||||
<AppDivisionEntryForm
|
<AppDivisionEntryForm
|
||||||
:schema="DivisionSchema"
|
:schema="DivisionSchema"
|
||||||
|
:divisions="divisions"
|
||||||
:values="recItem"
|
:values="recItem"
|
||||||
:is-loading="isProcessing"
|
:is-loading="isProcessing"
|
||||||
:is-readonly="isReadonly"
|
:is-readonly="isReadonly"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import {
|
|||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
handleCancelForm,
|
||||||
} from '~/handlers/material.handler'
|
} from '~/handlers/material.handler'
|
||||||
import { uoms, getUomList } from "~/handlers/_shared.handler"
|
import { uoms, getUomList } from '~/handlers/_shared.handler'
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getMaterials, getMaterialDetail } from '~/services/material.service'
|
import { getMaterials, getMaterialDetail } from '~/services/material.service'
|
||||||
@@ -112,8 +112,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getUomList()
|
|
||||||
await getEquipmentList()
|
await getEquipmentList()
|
||||||
|
await getUomList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getEncounterClassConstants()
|
|
||||||
await getInstallationList()
|
await getInstallationList()
|
||||||
|
await getEncounterClassConstants()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,11 @@ const {
|
|||||||
fetchData: getMedicineList,
|
fetchData: getMedicineList,
|
||||||
} = usePaginatedList({
|
} = usePaginatedList({
|
||||||
fetchFn: async (params: any) => {
|
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 || {} }
|
return { success: result.success || false, body: result.body || {} }
|
||||||
},
|
},
|
||||||
entityName: 'medicine',
|
entityName: 'medicine',
|
||||||
@@ -120,10 +124,10 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
await getMedicineList()
|
||||||
await getMedicineGroupList()
|
await getMedicineGroupList()
|
||||||
await getMedicineMethodList()
|
await getMedicineMethodList()
|
||||||
await getUomList()
|
await getUomList()
|
||||||
await getMedicineList()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getUnitList()
|
|
||||||
await getSpecialistList()
|
await getSpecialistList()
|
||||||
|
await getUnitList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getSpecialistsList()
|
|
||||||
await getSubSpecialistList()
|
await getSubSpecialistList()
|
||||||
|
await getSpecialistsList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getUomList()
|
|
||||||
await getToolsList()
|
await getToolsList()
|
||||||
|
await getUomList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getInstallationList()
|
|
||||||
await getUnitList()
|
await getUnitList()
|
||||||
|
await getInstallationList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export function createCrudHandler<T = any>(crud: {
|
|||||||
if (refresh) refresh()
|
if (refresh) refresh()
|
||||||
},
|
},
|
||||||
onFinally: (isSuccess: boolean) => {
|
onFinally: (isSuccess: boolean) => {
|
||||||
if (isSuccess) setTimeout(reset, 500)
|
setTimeout(reset, 300)
|
||||||
isProcessing.value = false
|
isProcessing.value = false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -58,7 +58,7 @@ export function createCrudHandler<T = any>(crud: {
|
|||||||
if (refresh) refresh()
|
if (refresh) refresh()
|
||||||
},
|
},
|
||||||
onFinally: (isSuccess: boolean) => {
|
onFinally: (isSuccess: boolean) => {
|
||||||
if (isSuccess) setTimeout(reset, 500)
|
setTimeout(reset, 300)
|
||||||
isProcessing.value = false
|
isProcessing.value = false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -77,6 +77,7 @@ export function createCrudHandler<T = any>(crud: {
|
|||||||
if (refresh) refresh()
|
if (refresh) refresh()
|
||||||
},
|
},
|
||||||
onFinally: () => {
|
onFinally: () => {
|
||||||
|
setTimeout(refresh, 300)
|
||||||
isProcessing.value = false
|
isProcessing.value = false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// types
|
// types
|
||||||
import type { MedicineGroup } from '~/models/medicine-group'
|
import type { MedicineGroup } from '~/models/medicine-group'
|
||||||
import type { MedicineMethod } from '~/models/medicine-method'
|
import type { MedicineMethod } from '~/models/medicine-method'
|
||||||
|
import type { Division } from '~/models/division'
|
||||||
import type { Installation } from '~/models/installation'
|
import type { Installation } from '~/models/installation'
|
||||||
import type { Specialist } from '~/models/specialist'
|
import type { Specialist } from '~/models/specialist'
|
||||||
import type { Uom } from '~/models/uom'
|
import type { Uom } from '~/models/uom'
|
||||||
@@ -13,6 +14,7 @@ import { encounterClassCodes } from '~/lib/constants'
|
|||||||
import { getMedicineGroups } from '~/services/medicine-group.service'
|
import { getMedicineGroups } from '~/services/medicine-group.service'
|
||||||
import { getMedicineMethods } from '~/services/medicine-method.service'
|
import { getMedicineMethods } from '~/services/medicine-method.service'
|
||||||
import { getEncounters } from '~/services/encounter.service'
|
import { getEncounters } from '~/services/encounter.service'
|
||||||
|
import { getDivisions } from '~/services/division.service'
|
||||||
import { getInstallations } from '~/services/installation.service'
|
import { getInstallations } from '~/services/installation.service'
|
||||||
import { getSpecialists } from '~/services/specialist.service'
|
import { getSpecialists } from '~/services/specialist.service'
|
||||||
import { getUoms } from '~/services/uom.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 medicineGroups = ref<{ value: string; label: string }[]>([])
|
||||||
export const medicineMethods = ref<{ value: string; label: string }[]>([])
|
export const medicineMethods = ref<{ value: string; label: string }[]>([])
|
||||||
export const encounterClasses = 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 installations = ref<{ value: string; label: string }[]>([])
|
||||||
export const specialists = ref<{ value: string; label: string }[]>([])
|
export const specialists = ref<{ value: string; label: string }[]>([])
|
||||||
export const uoms = 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 () => {
|
export const getEncounterClassList = async () => {
|
||||||
const result = await getEncounters()
|
const result = await getEncounters()
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|||||||
@@ -1,5 +1,33 @@
|
|||||||
import { createCrudHandler } from '~/handlers/_handler'
|
import { createCrudHandler } from '~/handlers/_handler'
|
||||||
import { postDivision, patchDivision, removeDivision } from '~/services/division.service'
|
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 {
|
export const {
|
||||||
recId,
|
recId,
|
||||||
@@ -15,7 +43,7 @@ export const {
|
|||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
handleCancelForm,
|
||||||
} = createCrudHandler({
|
} = createCrudHandler({
|
||||||
post: postDivision,
|
post: (payload: any) => selectPost(payload)(payload),
|
||||||
patch: patchDivision,
|
patch: (id: number | string, payload: any) => selectPatch(id, payload)(id, payload),
|
||||||
remove: removeDivision,
|
remove: (payload: any) => selectRemove(payload)(payload),
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user