feat/procedure-room-order: finishing

This commit is contained in:
Andrian Roshandy
2025-12-04 10:25:50 +07:00
parent acb573e279
commit a0dfd214e5
5 changed files with 209 additions and 55 deletions

No files matched your search

@@ -2,38 +2,37 @@
// Composables
import { usePaginatedList } from '~/composables/usePaginatedList'
// Handlers
import type { ToastFn } from '~/handlers/_handler'
// Pubs component
import { toast } from '~/components/pub/ui/toast'
import { type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
// Handlers
// Order
import {
recId,
recAction,
recItem,
isReadonly,
isRecordConfirmationOpen,
handleActionRemove,
handleActionSave,
} from '~/handlers/procedure-room-order.handler'
// Services
import { getList, getDetail } from '~/services/procedure-room-order.service'
import List from '~/components/app/procedure-room-order/list.vue'
import { getList, create, submit } from '~/services/procedure-room-order.service'
import type { ProcedureRoomOrder } from '~/models/procedure-room-order'
// import { submit } from '~/services/prescription.service'
import type { ToastFn } from '~/handlers/_handler'
import List from '~/components/app/procedure-room-order/list.vue'
// Common prep
const route = useRoute()
const { setQueryParams } = useQueryParam()
const isSubmitConfirmationOpen = ref(false)
const { crudQueryParams } = useQueryCRUD()
const plainEid = route.params.id
const encounter_id = (plainEid && typeof plainEid == 'string') ? parseInt(plainEid) : 0
const isSubmitConfirmationOpen = ref(false)
// Main data
const {
data,
isLoading,
@@ -44,7 +43,7 @@ const {
fetchFn: async (params: any) => {
const result = await getList({
'encounter-id': encounter_id,
// includes: '',
includes: 'items',
search: params.search,
page: params.page,
'page-number': params['page-number'] || 0,
@@ -55,7 +54,7 @@ const {
entityName: 'prescription'
})
const vFn = () => {} // Void function
// Header things
const headerPrep: HeaderPrep = {
title: 'Order Ruang Tindakan',
icon: 'i-lucide-box',
@@ -76,17 +75,35 @@ const headerPrep: HeaderPrep = {
onClick: async () => {
recItem.value = null
recId.value = 0
setQueryParams({
'mode': 'entry',
})
const res = await create({ encounter_id })
if (res.success) {
crudQueryParams.value = { mode: 'entry', recordId: res.body?.data.id.toString() || '0' }
}
},
},
}
// list actions
const timestamp = ref<any>({})
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
provide('timestamp', timestamp)
watch(recAction, () => {
if (!recAction.value) {
return
} else if (recAction.value === ActionEvents.showDetail) {
crudQueryParams.value = { mode: 'entry', recordId: recId.value || '0' }
} else if (recAction.value === ActionEvents.showConfirmSubmit) {
isSubmitConfirmationOpen.value = true
} else if (recAction.value === ActionEvents.showConfirmDelete) {
isRecordConfirmationOpen.value = true
}
recAction.value = ''
})
///// functions
function confirmCancel(data: ProcedureRoomOrder) {
recId.value = data.id
@@ -109,13 +126,13 @@ function confirmSubmit(data: ProcedureRoomOrder) {
}
async function handleActionSubmit(id: number, refresh: () => void, toast: ToastFn) {
// const result = await submit(id)
// if (result.success) {
// toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
// setTimeout(refresh, 300)
// } else {
// toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' })
// }
const result = await submit(id)
if (result.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
setTimeout(refresh, 300)
} else {
toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' })
}
}
</script>
@@ -141,7 +158,7 @@ async function handleActionSubmit(id: number, refresh: () => void, toast: ToastF
<div class="flex mb-2">
<div class="w-20">Tanggal</div>
<div class="w-4">:</div>
<div class="">{{ recItem.createdAt.substring(0, 10) }}</div>
<div class="">{{ recItem.createdAt?.substring(0, 10) }}</div>
</div>
<div class="flex">
<div class="w-20">DPJP</div>