feat(org-src): add division position management page

- Add new division position page to side menu
- Implement division position list with improved employee name display
- Include necessary API calls with proper includes for related data
- Add error handling for data loading failures
This commit is contained in:
Khafid Prayoga
2025-10-27 14:31:09 +07:00
parent 16a4fc5d7f
commit af932ebfbc
4 changed files with 75 additions and 12 deletions
@@ -1,5 +1,6 @@
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'
import type { DivisionPosition } from '~/models/division-position'
type SmallDetailDto = any
@@ -10,9 +11,9 @@ export const config: Config = {
headers: [
[
{ label: 'Kode' },
{ label: 'Nama' },
{ label: 'Divisi Induk' },
{ label: 'Kode Posisi' },
{ label: 'Nama Posisi' },
{ label: 'Nama Divisi ' },
{ label: 'Karyawan' },
{ label: 'Status Kepala' },
{ label: '' },
@@ -32,8 +33,13 @@ export const config: Config = {
return recX.division?.name || '-'
},
employee: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return recX.employee?.name || '-'
const recX = rec as DivisionPosition
const fullName = [recX.employee?.person.frontTitle, recX.employee?.person.name, recX.employee?.person.endTitle]
.filter(Boolean)
.join(' ')
.trim()
return fullName || '-'
},
head: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
@@ -54,6 +54,7 @@ const {
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
includes: 'division,Employee.Person',
})
return { success: result.success || false, body: result.body || {} }
},
@@ -61,7 +62,7 @@ const {
})
const headerPrep: HeaderPrep = {
title: 'Divisi',
title: 'Divisi Position',
icon: 'i-lucide-box',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
@@ -105,12 +106,12 @@ watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getCurrentDivisionDetail(recId.value)
title.value = 'Detail Divisi'
title.value = 'Detail Divisi Position'
isReadonly.value = true
break
case ActionEvents.showEdit:
getCurrentDivisionDetail(recId.value)
title.value = 'Edit Divisi'
title.value = 'Edit Divisi Position'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
@@ -120,9 +121,19 @@ watch([recId, recAction], () => {
})
onMounted(async () => {
divisions.value = await getDivisionLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
employees.value = await getEmployeeLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
await getDivisionList()
try {
divisions.value = await getDivisionLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
employees.value = await getEmployeeLabelList({ sort: 'createdAt:asc', 'page-size': 100, includes: 'person' })
await getDivisionList()
} catch (err) {
console.log(err)
// show toast
toast({
title: 'Terjadi Kesalahan',
description: 'Terjadi kesalahan saat memuat data',
variant: 'destructive',
})
}
})
</script>
@@ -142,7 +153,7 @@ onMounted(async () => {
<Dialog
v-model:open="isFormEntryDialogOpen"
:title="!!recItem ? title : 'Tambah Divisi'"
:title="!!recItem ? title : 'Tambah Divisi Position'"
size="lg"
prevent-outside
@update:open="
@@ -0,0 +1,42 @@
<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: 'Daftar Divisi',
contentFrame: 'cf-container-lg',
})
const route = useRoute()
useHead({
title: () => route.meta.title as string,
})
// const roleAccess: PagePermission = PAGE_PERMISSIONS['/patient']
// 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 = hasReadAccess(roleAccess)
const canRead = true
</script>
<template>
<template v-if="canRead">
<ContentDivisionPositionList />
</template>
<Error
v-else
:status-code="403"
/>
</template>
+4
View File
@@ -320,6 +320,10 @@
"title": "Divisi",
"link": "/org-src/division"
},
{
"title": "Divisi Position",
"link": "/org-src/division-position"
},
{
"title": "Instalasi",
"link": "/org-src/installation"