feat/prescription: added group and flat list
This commit is contained in:
@@ -29,7 +29,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
watch(medicines, (data) => {
|
||||
medicineItems.value = CB.objectsToItem(data, 'code', 'name')
|
||||
medicineItems.value = CB.objectsToItems(data, 'code', 'name')
|
||||
})
|
||||
|
||||
function navClick(type: ClickType) {
|
||||
|
||||
@@ -48,7 +48,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
watch(medicines, (data) => {
|
||||
medicineItems.value = CB.objectsToItem(data, 'code', 'name')
|
||||
medicineItems.value = CB.objectsToItems(data, 'code', 'name')
|
||||
})
|
||||
|
||||
function navClick(type: ClickType) {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import * as Table from '~/components/pub/ui/table'
|
||||
import * as DE from '~/components/pub/my-ui/doc-entry';
|
||||
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
|
||||
import Nav from '~/components/pub/my-ui/nav-footer/ca-ed-su.vue'
|
||||
|
||||
import type { Prescription } from '~/models/prescription';
|
||||
import PrescriptionItem from '~/components/app/prescription-item/list.vue';
|
||||
|
||||
interface Props {
|
||||
data: Prescription[]
|
||||
paginationMeta: PaginationMeta
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
cancel: [data: any]
|
||||
edit: [data: any],
|
||||
submit: [data: any]
|
||||
}>()
|
||||
|
||||
function navClick(type: 'cancel' | 'edit' | 'submit', data: Prescription): void {
|
||||
if (type === 'cancel') {
|
||||
emit('cancel', data)
|
||||
} else if (type === 'edit') {
|
||||
emit('edit', data)
|
||||
} else if (type === 'submit') {
|
||||
emit('submit', data)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="data.length == 0" class="p-10 text-center">
|
||||
<div class="mb-4 xl:mb-5">Belum Ada Data</div>
|
||||
<div>
|
||||
<Button>
|
||||
<Icon name="i-lucide-plus" class="me-2 align-middle" />
|
||||
Tambah Order
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Table.Table>
|
||||
<Table.TableHeader>
|
||||
<Table.TableRow>
|
||||
<Table.TableHead class="w-28">Tgl Order</Table.TableHead>
|
||||
<Table.TableHead>DPJP</Table.TableHead>
|
||||
<Table.TableHead>PPDS</Table.TableHead>
|
||||
<Table.TableHead>Jenis Obat</Table.TableHead>
|
||||
<Table.TableHead class="text-center">Status</Table.TableHead>
|
||||
<Table.TableHead class="w-20"></Table.TableHead>
|
||||
</Table.TableRow>
|
||||
</Table.TableHeader>
|
||||
<Table.TableBody>
|
||||
<Table.TableRow v-for="item, idx in data">
|
||||
<Table.TableCell>
|
||||
{{ item.issuedAt?.substring(0, 10) || item.createdAt?.substring(0, 10) }}
|
||||
</Table.TableCell>
|
||||
<Table.TableCell>
|
||||
{{ item.doctor?.employee?.person?.name || '-' }}
|
||||
</Table.TableCell>
|
||||
<Table.TableCell>
|
||||
</Table.TableCell>
|
||||
<Table.TableCell>
|
||||
<div>
|
||||
Racikan: {{ item.items.filter(function(element){ return element.isMix}).length }}
|
||||
</div>
|
||||
<div>
|
||||
Non Racikan: {{ item.items.filter(function(element){ return !element.isMix}).length }}
|
||||
</div>
|
||||
</Table.TableCell>
|
||||
<Table.TableCell class="text-center">
|
||||
{{ item.status_code }}
|
||||
</Table.TableCell>
|
||||
<Table.TableCell class="text-end">
|
||||
<Nav
|
||||
v-if="item.status_code == 'new'"
|
||||
:small-mode="true"
|
||||
:default-class="'flex gap-1'"
|
||||
@click="(type) => { navClick(type, item) }"
|
||||
/>
|
||||
</Table.TableCell>
|
||||
</Table.TableRow>
|
||||
</Table.TableBody>
|
||||
</Table.Table>
|
||||
<template v-for="item, idx in data">
|
||||
</template>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
// Composables
|
||||
import { usePaginatedList } from '~/composables/usePaginatedList'
|
||||
|
||||
// Pubs component
|
||||
import { toast } from '~/components/pub/ui/toast'
|
||||
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||
@@ -20,15 +22,12 @@ import {
|
||||
|
||||
// Services
|
||||
import { getList, getDetail } from '~/services/prescription.service'
|
||||
import List from '~/components/app/prescription/list.vue'
|
||||
import FlatList from '~/components/app/prescription/flat-list.vue'
|
||||
import Grouped from '~/components/app/prescription/grouped-list.vue'
|
||||
import type { Prescription } from '~/models/prescription'
|
||||
import { submit } from '~/services/prescription.service'
|
||||
import type { ToastFn } from '~/handlers/_handler'
|
||||
|
||||
const props = defineProps<{
|
||||
encounter_id: number
|
||||
}>()
|
||||
|
||||
const route = useRoute()
|
||||
const { setQueryParams } = useQueryParam()
|
||||
|
||||
@@ -45,21 +44,40 @@ const {
|
||||
searchInput,
|
||||
fetchData: getMyList,
|
||||
} = usePaginatedList<Prescription>({
|
||||
fetchFn: async ({ page, search }) => {
|
||||
fetchFn: async (params: any) => {
|
||||
const result = await getList({
|
||||
search,
|
||||
page,
|
||||
'encounter-id': encounter_id,
|
||||
includes: 'doctor,doctor-employee,doctor-employee-person,items,items-medicine,items-medicine-medicineForm',
|
||||
search: params.search,
|
||||
page: params.page,
|
||||
'page-number': params['page-number'] || 0,
|
||||
'page-size': params['page-size'] || 10,
|
||||
})
|
||||
return { success: result.success || false, body: result.body || {} }
|
||||
},
|
||||
entityName: 'prescription'
|
||||
})
|
||||
|
||||
function updateProvidedVal(val: boolean) {
|
||||
flatMode.value = val
|
||||
}
|
||||
const flatMode = ref(false)
|
||||
const flatModeLabel = ref('Mode Flat: Tidak')
|
||||
provide('flatMode', { flatMode, updateProvidedVal })
|
||||
watch(flatMode, (newVal) => {
|
||||
flatModeLabel.value = newVal ? 'Mode Flat: Ya' : 'Mode Flat: Tidak'
|
||||
})
|
||||
|
||||
const voidFn = () => {}
|
||||
const headerPrep: HeaderPrep = {
|
||||
title: 'Order Obat',
|
||||
icon: 'i-lucide-box',
|
||||
components: [
|
||||
{
|
||||
component: defineAsyncComponent(() => import('~/components/pub/my-ui/toggle/provided-toggle.vue')),
|
||||
props: { variant: 'outline', label: flatModeLabel, providedKey: 'flatMode' }
|
||||
},
|
||||
],
|
||||
refSearchNav: {
|
||||
placeholder: 'Cari (min. 3 karakter)...',
|
||||
minLength: 3,
|
||||
@@ -74,11 +92,17 @@ const headerPrep: HeaderPrep = {
|
||||
addNav: {
|
||||
label: 'Tambah',
|
||||
icon: 'i-lucide-plus',
|
||||
onClick: () => {
|
||||
onClick: async () => {
|
||||
recItem.value = null
|
||||
recId.value = 0
|
||||
isFormEntryDialogOpen.value = true
|
||||
isReadonly.value = false
|
||||
const saveResp = await handleActionSave({ encounter_id }, voidFn, voidFn, voidFn)
|
||||
if (saveResp.success) {
|
||||
setQueryParams({
|
||||
'mode': 'entry',
|
||||
'id': saveResp.body?.data?.id.toString()
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -88,6 +112,28 @@ provide('rec_action', recAction)
|
||||
provide('rec_item', recItem)
|
||||
provide('table_data_loader', isLoading)
|
||||
|
||||
// Watch for row actions when recId or recAction changes
|
||||
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) {
|
||||
// }
|
||||
// })
|
||||
|
||||
// Functions
|
||||
const getMyDetail = async (id: number | string) => {
|
||||
const result = await getDetail(id)
|
||||
if (result.success) {
|
||||
@@ -161,14 +207,26 @@ async function handleActionSubmit(id: number, refresh: () => void, toast: ToastF
|
||||
|
||||
<template>
|
||||
<Header :prep="{ ...headerPrep }" />
|
||||
<List
|
||||
v-if="!isLoading.dataListLoading"
|
||||
:data="data"
|
||||
:pagination-meta="paginationMeta"
|
||||
@cancel="confirmCancel"
|
||||
@edit="goToEdit"
|
||||
@submit="confirmSubmit"
|
||||
/>
|
||||
<template v-if="!flatMode">
|
||||
<Grouped
|
||||
v-if="!isLoading.dataListLoading"
|
||||
:data="data"
|
||||
:pagination-meta="paginationMeta"
|
||||
@cancel="confirmCancel"
|
||||
@edit="goToEdit"
|
||||
@submit="confirmSubmit"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<FlatList
|
||||
v-if="!isLoading.dataListLoading"
|
||||
:data="data"
|
||||
:pagination-meta="paginationMeta"
|
||||
@cancel="confirmCancel"
|
||||
@edit="goToEdit"
|
||||
@submit="confirmSubmit"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<RecordConfirmation
|
||||
v-model:open="isRecordConfirmationOpen"
|
||||
|
||||
@@ -22,7 +22,7 @@ const selected = ref<any[]>([])
|
||||
function toggleSelection(row: any, event?: Event) {
|
||||
if (event) event.stopPropagation() // cegah event bubble ke TableRow
|
||||
|
||||
const isMultiple = props.selectMode === 'multiple' // props.selectMode === 'multi' ||
|
||||
const isMultiple = props.selectMode === 'multiple' // props.selectMode === 'multi' ||
|
||||
|
||||
// gunakan pembanding berdasarkan id atau stringify data
|
||||
const findIndex = selected.value.findIndex((r) => JSON.stringify(r) === JSON.stringify(row))
|
||||
@@ -128,7 +128,7 @@ function handleActionCellClick(event: Event, _cellRef: string) {
|
||||
'bg-green-50':
|
||||
props.selectMode === 'single' && selected.some((r) => JSON.stringify(r) === JSON.stringify(row)),
|
||||
'bg-blue-50':
|
||||
(props.selectMode === 'multiple') && // props.selectMode === 'multi' ||
|
||||
(props.selectMode === 'multiple') && // props.selectMode === 'multi' ||
|
||||
selected.some((r) => JSON.stringify(r) === JSON.stringify(row)),
|
||||
}"
|
||||
@click="toggleSelection(row)"
|
||||
|
||||
Reference in New Issue
Block a user