diff --git a/app/components/app/subspecialist-position/entry-detail.vue b/app/components/app/subspecialist-position/entry-detail.vue new file mode 100644 index 00000000..fd3f91b7 --- /dev/null +++ b/app/components/app/subspecialist-position/entry-detail.vue @@ -0,0 +1,192 @@ + + + diff --git a/app/components/app/subspecialist/detail/index.vue b/app/components/app/subspecialist/detail/index.vue new file mode 100644 index 00000000..ed3f1478 --- /dev/null +++ b/app/components/app/subspecialist/detail/index.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/app/components/app/subspecialist/detail/list.cfg.ts b/app/components/app/subspecialist/detail/list.cfg.ts new file mode 100644 index 00000000..8faf9e61 --- /dev/null +++ b/app/components/app/subspecialist/detail/list.cfg.ts @@ -0,0 +1,61 @@ +import type { Config, RecComponent } from '~/components/pub/my-ui/data-table' +import { defineAsyncComponent } from 'vue' +import type { UnitPosition } from '~/models/unit-position' + +type SmallDetailDto = any + +const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue')) + +export const config: Config = { + cols: [{}, {}, {}, {}, {}, { width: 50 }], + + headers: [ + [ + { label: '#' }, + { label: 'Kode Posisi' }, + { label: 'Nama Posisi' }, + { label: 'Karyawan' }, + { label: 'Status Kepala' }, + { label: '' }, + ], + ], + + keys: ['index', 'code', 'name', 'employee', 'head', 'action'], + + delKeyNames: [ + { key: 'code', label: 'Kode' }, + { key: 'name', label: 'Nama' }, + ], + + parses: { + employee: (rec: unknown): unknown => { + const recX = rec as UnitPosition + 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 + return recX.headStatus ? 'Ya' : 'Tidak' + }, + }, + + components: { + action(rec, idx) { + const res: RecComponent = { + idx, + rec: rec as object, + component: action, + props: { + size: 'sm', + }, + } + return res + }, + }, + + htmls: {}, +} diff --git a/app/components/app/subspecialist/detail/list.vue b/app/components/app/subspecialist/detail/list.vue new file mode 100644 index 00000000..11431e25 --- /dev/null +++ b/app/components/app/subspecialist/detail/list.vue @@ -0,0 +1,45 @@ + + + diff --git a/app/components/content/subspecialist/detail.vue b/app/components/content/subspecialist/detail.vue new file mode 100644 index 00000000..ccecaa0d --- /dev/null +++ b/app/components/content/subspecialist/detail.vue @@ -0,0 +1,239 @@ + + + diff --git a/app/components/content/subspecialist/entry.ts b/app/components/content/subspecialist/entry.ts deleted file mode 100644 index 5a93847d..00000000 --- a/app/components/content/subspecialist/entry.ts +++ /dev/null @@ -1,98 +0,0 @@ -import * as z from 'zod' - -export const schemaConf = z.object({ - name: z - .string({ - required_error: 'Nama spesialisasi harus diisi', - }) - .min(3, 'Nama spesialisasi minimal 3 karakter'), - - code: z - .string({ - required_error: 'Kode spesialisasi harus diisi', - }) - .min(3, 'Kode spesialisasi minimal 3 karakter'), - - installationId: z - .string({ - required_error: 'Instalasi harus dipilih', - }) - .min(1, 'Instalasi harus dipilih'), - - unitId: z - .string({ - required_error: 'Unit harus dipilih', - }) - .min(1, 'Unit harus dipilih'), - specialistId: z - .string({ - required_error: 'Specialist harus dipilih', - }) - .min(1, 'Specialist harus dipilih'), -}) - -// Unit mapping berdasarkan installation -export const installationUnitMapping: Record = { - '1': ['1', '3'], - '2': ['2', '3'], - '3': ['1', '2', '3'], -} - -export const unitConf = { - msg: { - placeholder: '---pilih unit', - search: 'kode, nama unit', - empty: 'unit tidak ditemukan', - }, - items: [ - { value: '1', label: 'Instalasi Medis', code: 'MED' }, - { value: '2', label: 'Instalasi Keperawatan', code: 'NUR' }, - { value: '3', label: 'Instalasi Administrasi', code: 'ADM' }, - ], -} - -export const specialistConf = { - msg: { - placeholder: '---pilih specialist', - search: 'kode, nama specialist', - empty: 'specialist tidak ditemukan', - }, - items: [ - { value: '1', label: 'Spesialis Jantung', code: 'CARD' }, - { value: '2', label: 'Spesialis Mata', code: 'OPHT' }, - { value: '3', label: 'Spesialis Bedah', code: 'SURG' }, - { value: '4', label: 'Spesialis Anak', code: 'PEDI' }, - { value: '5', label: 'Spesialis Kandungan', code: 'OBGY' }, - ], -} - -export const installationConf = { - msg: { - placeholder: '---pilih instalasi', - search: 'kode, nama instalasi', - empty: 'instalasi tidak ditemukan', - }, - items: [ - { value: '1', label: 'Ambulatory', code: 'AMB' }, - { value: '2', label: 'Inpatient', code: 'IMP' }, - { value: '3', label: 'Emergency', code: 'EMER' }, - ], -} - -// Helper function untuk filter unit berdasarkan installation -export function getFilteredUnits(installationId: string) { - if (!installationId || !installationUnitMapping[installationId]) { - return [] - } - - const allowedUnitIds = installationUnitMapping[installationId] - return unitConf.items.filter((unit) => allowedUnitIds.includes(unit.value)) -} - -// Helper function untuk membuat unit config yang ter-filter -export function createFilteredUnitConf(installationId: string) { - return { - ...unitConf, - items: getFilteredUnits(installationId), - } -} diff --git a/app/components/content/subspecialist/list.vue b/app/components/content/subspecialist/list.vue index e2c6db52..bb1b63f5 100644 --- a/app/components/content/subspecialist/list.vue +++ b/app/components/content/subspecialist/list.vue @@ -103,9 +103,23 @@ const getCurrentSubSpecialistDetail = async (id: number | string) => { watch([recId, recAction], () => { switch (recAction.value) { case ActionEvents.showDetail: - getCurrentSubSpecialistDetail(recId.value) - title.value = 'Detail Sub Spesialis' - isReadonly.value = true + if (Number(recId.value) > 0) { + const id = Number(recId.value) + + recAction.value = '' + recItem.value = null + recId.value = 0 + isFormEntryDialogOpen.value = false + isReadonly.value = false + + navigateTo({ + name: 'org-src-subspecialist-id', + params: { + id, + }, + }) + } + break case ActionEvents.showEdit: getCurrentSubSpecialistDetail(recId.value) diff --git a/app/models/subspecialist.ts b/app/models/subspecialist.ts index 6343b847..e67333e9 100644 --- a/app/models/subspecialist.ts +++ b/app/models/subspecialist.ts @@ -1,9 +1,11 @@ -import { type Base, genBase } from "./_base" - +import { type Base, genBase } from './_base' +import { type Specialist } from './specialist' export interface Subspecialist extends Base { code: string name: string specialist_id?: number | string | null + + specialist?: Specialist | null } export function genSubspecialist(): Subspecialist { @@ -11,6 +13,6 @@ export function genSubspecialist(): Subspecialist { ...genBase(), code: '', name: '', - specialist_id: 0 + specialist_id: 0, } } diff --git a/app/pages/(features)/org-src/subspecialist/[id]/index.vue b/app/pages/(features)/org-src/subspecialist/[id]/index.vue new file mode 100644 index 00000000..7bd0b8ee --- /dev/null +++ b/app/pages/(features)/org-src/subspecialist/[id]/index.vue @@ -0,0 +1,42 @@ + + + diff --git a/app/services/subspecialist.service.ts b/app/services/subspecialist.service.ts index 94e70a09..e384f059 100644 --- a/app/services/subspecialist.service.ts +++ b/app/services/subspecialist.service.ts @@ -15,8 +15,8 @@ export function getList(params: any = null) { return base.getList(path, params, name) } -export function getDetail(id: number | string) { - return base.getDetail(path, id, name) +export function getDetail(id: number | string, params?: any) { + return base.getDetail(path, id, name, params) } export function update(id: number | string, data: any) {