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

No files matched your search

+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),
})