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:
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
|
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
|
import type { DivisionPosition } from '~/models/division-position'
|
||||||
|
|
||||||
type SmallDetailDto = any
|
type SmallDetailDto = any
|
||||||
|
|
||||||
@@ -10,9 +11,9 @@ export const config: Config = {
|
|||||||
|
|
||||||
headers: [
|
headers: [
|
||||||
[
|
[
|
||||||
{ label: 'Kode' },
|
{ label: 'Kode Posisi' },
|
||||||
{ label: 'Nama' },
|
{ label: 'Nama Posisi' },
|
||||||
{ label: 'Divisi Induk' },
|
{ label: 'Nama Divisi ' },
|
||||||
{ label: 'Karyawan' },
|
{ label: 'Karyawan' },
|
||||||
{ label: 'Status Kepala' },
|
{ label: 'Status Kepala' },
|
||||||
{ label: '' },
|
{ label: '' },
|
||||||
@@ -32,8 +33,13 @@ export const config: Config = {
|
|||||||
return recX.division?.name || '-'
|
return recX.division?.name || '-'
|
||||||
},
|
},
|
||||||
employee: (rec: unknown): unknown => {
|
employee: (rec: unknown): unknown => {
|
||||||
const recX = rec as SmallDetailDto
|
const recX = rec as DivisionPosition
|
||||||
return recX.employee?.name || '-'
|
const fullName = [recX.employee?.person.frontTitle, recX.employee?.person.name, recX.employee?.person.endTitle]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')
|
||||||
|
.trim()
|
||||||
|
|
||||||
|
return fullName || '-'
|
||||||
},
|
},
|
||||||
head: (rec: unknown): unknown => {
|
head: (rec: unknown): unknown => {
|
||||||
const recX = rec as SmallDetailDto
|
const recX = rec as SmallDetailDto
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ const {
|
|||||||
sort: 'createdAt:asc',
|
sort: 'createdAt:asc',
|
||||||
'page-number': params['page-number'] || 0,
|
'page-number': params['page-number'] || 0,
|
||||||
'page-size': params['page-size'] || 10,
|
'page-size': params['page-size'] || 10,
|
||||||
|
includes: 'division,Employee.Person',
|
||||||
})
|
})
|
||||||
return { success: result.success || false, body: result.body || {} }
|
return { success: result.success || false, body: result.body || {} }
|
||||||
},
|
},
|
||||||
@@ -61,7 +62,7 @@ const {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const headerPrep: HeaderPrep = {
|
const headerPrep: HeaderPrep = {
|
||||||
title: 'Divisi',
|
title: 'Divisi Position',
|
||||||
icon: 'i-lucide-box',
|
icon: 'i-lucide-box',
|
||||||
refSearchNav: {
|
refSearchNav: {
|
||||||
placeholder: 'Cari (min. 3 karakter)...',
|
placeholder: 'Cari (min. 3 karakter)...',
|
||||||
@@ -105,12 +106,12 @@ watch([recId, recAction], () => {
|
|||||||
switch (recAction.value) {
|
switch (recAction.value) {
|
||||||
case ActionEvents.showDetail:
|
case ActionEvents.showDetail:
|
||||||
getCurrentDivisionDetail(recId.value)
|
getCurrentDivisionDetail(recId.value)
|
||||||
title.value = 'Detail Divisi'
|
title.value = 'Detail Divisi Position'
|
||||||
isReadonly.value = true
|
isReadonly.value = true
|
||||||
break
|
break
|
||||||
case ActionEvents.showEdit:
|
case ActionEvents.showEdit:
|
||||||
getCurrentDivisionDetail(recId.value)
|
getCurrentDivisionDetail(recId.value)
|
||||||
title.value = 'Edit Divisi'
|
title.value = 'Edit Divisi Position'
|
||||||
isReadonly.value = false
|
isReadonly.value = false
|
||||||
break
|
break
|
||||||
case ActionEvents.showConfirmDelete:
|
case ActionEvents.showConfirmDelete:
|
||||||
@@ -120,9 +121,19 @@ watch([recId, recAction], () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
divisions.value = await getDivisionLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
|
try {
|
||||||
employees.value = await getEmployeeLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
|
divisions.value = await getDivisionLabelList({ sort: 'createdAt:asc', 'page-size': 100 })
|
||||||
await getDivisionList()
|
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>
|
</script>
|
||||||
|
|
||||||
@@ -142,7 +153,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<Dialog
|
<Dialog
|
||||||
v-model:open="isFormEntryDialogOpen"
|
v-model:open="isFormEntryDialogOpen"
|
||||||
:title="!!recItem ? title : 'Tambah Divisi'"
|
:title="!!recItem ? title : 'Tambah Divisi Position'"
|
||||||
size="lg"
|
size="lg"
|
||||||
prevent-outside
|
prevent-outside
|
||||||
@update:open="
|
@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>
|
||||||
@@ -320,6 +320,10 @@
|
|||||||
"title": "Divisi",
|
"title": "Divisi",
|
||||||
"link": "/org-src/division"
|
"link": "/org-src/division"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "Divisi Position",
|
||||||
|
"link": "/org-src/division-position"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Instalasi",
|
"title": "Instalasi",
|
||||||
"link": "/org-src/installation"
|
"link": "/org-src/installation"
|
||||||
|
|||||||
Reference in New Issue
Block a user