feat/device-order: adjustment wip

This commit is contained in:
Andrian Roshandy
2025-11-16 11:21:02 +07:00
parent cbe1883c9f
commit 7253272681
4 changed files with 110 additions and 42 deletions

No files matched your search

+81 -25
View File
@@ -32,21 +32,18 @@ import {
handleCancelForm,
} from '~/handlers/device-order.handler'
//
import { getList } from '~/services/device-order.service'
// Props
interface Props {
encounter_id: number
}
const props = defineProps<Props>()
// Services
import { getList, getDetail } from '~/services/device-order.service'
const route = useRoute()
const title = ref('')
const { setQueryParams } = useQueryParam()
const plainEid = route.params.id
const encounter_id = (plainEid && typeof plainEid == 'string') ? parseInt(plainEid) : 0
// const { mode, openForm, backToList } = useQueryMode()
const { mode, goToEntry, backToList } = useQueryCRUDMode()
const { recordId } = useQueryCRUDRecordId()
// const { recordId } = useQueryCRUDRecordId()
const {
data,
@@ -59,18 +56,18 @@ const {
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getList({
'encounter-id': encounter_id,
search: params.search,
sort: 'createdAt:asc',
includes: 'doctor,doctor-employee,doctor-employee-person,items',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
// includes: 'encounter',
includes: 'parent,childrens',
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'device-order',
})
const voidFn = () => {}
const headerPrep: HeaderPrep = {
title: 'Order Alkes',
icon: 'i-lucide-box',
@@ -89,19 +86,18 @@ const headerPrep: HeaderPrep = {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: async () => {
const data = {
encounter_id: props.encounter_id,
}
const dateResp = await handleActionSave(data, getMyList, () => {}, () => {})
if (dateResp.success) {
const currentData = dateResp.body.data || []
// goToEntry()
}
recItem.value = null
recId.value = 0
isReadonly.value = false
const saveResp = await handleActionSave({ encounter_id }, voidFn, voidFn, voidFn)
if (saveResp.success) {
setQueryParams({
'mode': 'entry',
'id': saveResp.body?.data?.id.toString()
})
}
// await handleActionSave(recItem, getMyList, () => {}, () => {})
goToEntry()
// goToEntry()
},
},
}
@@ -111,10 +107,66 @@ provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
// Watch for row actions when recId or recAction changes
onMounted(async () => {
await getMyList()
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getMyDetail(recId.value)
isReadonly.value = true
break
case ActionEvents.showEdit:
getMyDetail(recId.value)
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
break
}
})
// watch([isFormEntryDialogOpen], async () => {
// if (isFormEntryDialogOpen.value) {
// isFormEntryDialogOpen.value = false;
// const saveResp = await handleActionSave({ encounter_id }, getMyList, () =>{}, toast)
// if (saveResp.success) {
// setQueryParams({
// 'mode': 'entry',
// 'id': saveResp.body?.data?.id.toString()
// })
// }
// }
// })
// Watch for row actions when recId or recAction changes
// onMounted(async () => {
// await getMyList()
// })
// Functions
const getMyDetail = async (id: number | string) => {
const result = await getDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
function cancel(data: DeviceOrder) {
recId.value = data.id
recItem.value = data
isRecordConfirmationOpen.value = true
}
function edit(data: DeviceOrder) {
setQueryParams({
'mode': 'entry',
'id': data.id.toString()
})
recItem.value = data
}
function submit(data: DeviceOrder) {
}
</script>
<template>
@@ -127,8 +179,12 @@ onMounted(async () => {
/>
<List
v-if="!isLoading.dataListLoading"
:data="data"
:pagination-meta="paginationMeta"
@cancel="cancel"
@edit="edit"
@submit="submit"
@page-change="handlePageChange"
/>