feat(cemo): change flow admin

This commit is contained in:
riefive
2025-11-04 13:23:52 +07:00
parent 64fe2524fb
commit be0a761170
7 changed files with 215 additions and 47 deletions
@@ -0,0 +1,63 @@
<script setup lang="ts">
import type { LinkItem, ListItemDto } from '~/components/pub/my-ui/data/types'
const props = defineProps<{
rec: ListItemDto
}>()
const recId = inject<Ref<number>>('rec_id')!
const recAction = inject<Ref<string>>('rec_action')!
const recItem = inject<Ref<any>>('rec_item')!
const activeKey = ref<string | null>(null)
const linkItems: LinkItem[] = [
{
label: 'Proses',
onClick: () => {
process()
},
icon: 'i-lucide-pencil',
},
]
function process() {
recId.value = props.rec.id || 0
recAction.value = 'Process'
recItem.value = props.rec
}
</script>
<template>
<div>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<SidebarMenuButton
size="lg"
class="data-[state=open]:text-sidebar-accent-foreground data-[state=open]:bg-white dark:data-[state=open]:bg-slate-800"
>
<Icon
name="i-lucide-chevrons-up-down"
class="ml-auto size-4"
/>
</SidebarMenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent
class="w-[--radix-dropdown-menu-trigger-width] min-w-40 rounded-lg border border-slate-200 bg-white text-black dark:border-slate-700 dark:bg-slate-800 dark:text-white"
align="end"
>
<DropdownMenuGroup>
<DropdownMenuItem
v-for="item in linkItems"
:key="item.label"
class="hover:bg-gray-100 dark:hover:bg-slate-700"
@click="item.onClick"
@mouseenter="activeKey = item.label"
@mouseleave="activeKey = null"
>
<Icon :name="item.icon ?? ''" />
<span :class="activeKey === item.label ? 'text-sidebar-accent-foreground' : ''">{{ item.label }}</span>
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
</template>
@@ -0,0 +1,80 @@
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'
type SmallDetailDto = any
const action = defineAsyncComponent(() => import('./dropdown-action-process.vue'))
export const config: Config = {
cols: [
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 50 },
],
headers: [
[
{ label: 'TANGGAL' },
{ label: 'NO. RM' },
{ label: 'NO. BILL' },
{ label: 'JK' },
{ label: 'ALAMAT' },
{ label: 'KLINIK ASAL' },
{ label: 'NAMA DOKTER' },
{ label: 'CARA BAYAR' },
{ label: 'RUJUKAN' },
{ label: 'KET. RUJUKAN' },
{ label: 'ASAL' },
{ label: '' },
],
],
keys: [
'tanggal',
'noRm',
'noBill',
'jk',
'alamat',
'klinik',
'dokter',
'caraBayar',
'rujukan',
'ketRujukan',
'asal',
'action',
],
delKeyNames: [
{ key: 'code', label: 'Kode' },
{ key: 'name', label: 'Nama' },
],
parses: {
parent: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return recX.parent?.name || '-'
},
},
components: {
action(rec, idx) {
const res: RecComponent = {
idx,
rec: rec as object,
component: action,
}
return res
},
},
htmls: {},
}
@@ -13,7 +13,14 @@ import type { PaginationMeta } from '~/components/pub/my-ui/pagination/paginatio
// Sample data - replace with actual API call
import { sampleRows, type ChemotherapyData } from '~/components/app/chemotherapy/sample'
const route = useRoute()
const recId = ref(0)
const recAction = ref('')
const recItem = ref<any>(null)
const search = ref('')
const mode = route.params.mode as string || 'admin'
const dateRange = ref<{ from: Date | null; to: Date | null }>({
from: null,
to: null,
@@ -65,6 +72,19 @@ function handleProses(rec: any) {
navigateTo(`/outpation-action/chemotherapy/verification?id=${rec.id}`)
}
watch([recId, recAction], () => {
switch (recAction.value) {
case 'Process':
navigateTo(`/outpation-action/chemotherapy/${mode}/${recId.value}/verification`)
break
case 'Verification':
break
}
})
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('proses-handler', handleProses)
</script>
@@ -102,7 +122,7 @@ provide('proses-handler', handleProses)
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0">
<RangeCalendar v-model="dateRange" />
<RangeCalendar />
</PopoverContent>
</Popover>
@@ -205,7 +205,7 @@ function handleBackToAdmin() {
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0">
<RangeCalendar v-model="dateRange" />
<RangeCalendar />
</PopoverContent>
</Popover>
@@ -1,42 +0,0 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Kemoterapi - Proses',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => `${route.meta.title}`,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/rehab/encounter']
const { checkRole, hasCreateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
statusCode: 403,
statusMessage: 'Access denied',
})
}
// Define permission-based computed properties
const canCreate = hasCreateAccess(roleAccess)
</script>
<template>
<div v-if="canCreate">
<ContentChemotherapyProcess />
</div>
<Error v-else :status-code="403" />
</template>
@@ -0,0 +1,47 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
import ContentChemotherapyAdminList from '~/components/content/chemotherapy/admin-list.vue'
import ContentChemotherapyVerification from '~/components/content/chemotherapy/verification.vue'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Kemoterapi Admin',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => 'Verifikasi Jadwal Pasien',
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor'] || {}
const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
navigateTo('/403')
}
// Define permission-based computed properties
const canRead = true // hasReadAccess(roleAccess)
const mode = computed(() => route.params.mode as string)
</script>
<template>
<div>
<div v-if="canRead">
<ContentChemotherapyVerification />
</div>
<Error
v-else
:status-code="403"
/>
</div>
</template>
@@ -19,8 +19,8 @@ useHead({
const mode = route.params.mode as string
if (mode === 'admin') {
return 'Administrasi Pasien Rawat Jalan Kemoterapi'
} else if (mode === 'verification') {
return 'Verifikasi Jadwal Pasien'
} else if (mode === 'series') {
return 'Proses Jadwal Pasien'
}
return route.meta.title as string
},
@@ -46,7 +46,7 @@ const mode = computed(() => route.params.mode as string)
<div>
<div v-if="canRead">
<ContentChemotherapyAdminList v-if="mode === 'admin'" />
<ContentChemotherapyVerification v-else-if="mode === 'verification'" />
<ContentChemotherapyProcess v-else-if="mode === 'series'" />
<Error v-else :status-code="404" status-message="Mode tidak ditemukan" />
</div>
<Error v-else :status-code="403" />