diff --git a/app/components/app/unit/detail/index.vue b/app/components/app/unit/detail/index.vue new file mode 100644 index 00000000..9b38aa2b --- /dev/null +++ b/app/components/app/unit/detail/index.vue @@ -0,0 +1,35 @@ + + + + {{ unit.code || '-' }} + {{ unit.name || '-' }} + + + + diff --git a/app/components/app/unit/detail/list.cfg.ts b/app/components/app/unit/detail/list.cfg.ts new file mode 100644 index 00000000..8faf9e61 --- /dev/null +++ b/app/components/app/unit/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/unit/detail/list.vue b/app/components/app/unit/detail/list.vue new file mode 100644 index 00000000..f878d14c --- /dev/null +++ b/app/components/app/unit/detail/list.vue @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/app/components/content/unit/detail.vue b/app/components/content/unit/detail.vue new file mode 100644 index 00000000..1310621e --- /dev/null +++ b/app/components/content/unit/detail.vue @@ -0,0 +1,234 @@ + + + + + + + + + + + { + onResetState() + isFormEntryDialogOpen = value + } + " + > + , resetForm: () => void) => { + console.log(values) + if (recId > 0) { + handleActionEdit(recId, values, getPositionList, onResetState, toast) + return + } + handleActionSave(values, getPositionList, onResetState, toast) + } + " + @cancel="handleCancelForm" + /> + + handleActionRemove(recId, getPositionList, toast)" + @cancel="" + > + + + + {{ field.label }}: + {{ record[field.key] }} + + + + + diff --git a/app/components/content/unit/entry.ts b/app/components/content/unit/entry.ts deleted file mode 100644 index bf85a0ed..00000000 --- a/app/components/content/unit/entry.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as z from 'zod' - -export const unitConf = { - msg: { - placeholder: '--- pilih instalasi', - search: 'kode, nama instalasi', - empty: 'instalasi tidak ditemukan', - }, - items: [ - { value: '1', label: 'Instalasi Medis', code: 'MED' }, - { value: '2', label: 'Instalasi Keperawatan', code: 'NUR' }, - { value: '3', label: 'Instalasi Administrasi', code: 'ADM' }, - { value: '4', label: 'Instalasi Penunjang Non-Medis', code: 'SUP' }, - { value: '5', label: 'Instalasi Pendidikan & Pelatihan', code: 'EDU' }, - { value: '6', label: 'Instalasi Farmasi', code: 'PHA' }, - { value: '7', label: 'Instalasi Radiologi', code: 'RAD' }, - { value: '8', label: 'Instalasi Laboratorium', code: 'LAB' }, - { value: '9', label: 'Instalasi Keuangan', code: 'FIN' }, - { value: '10', label: 'Instalasi SDM', code: 'HR' }, - { value: '11', label: 'Instalasi Teknologi Informasi', code: 'ITS' }, - { value: '12', label: 'Instalasi Pemeliharaan & Sarana', code: 'MNT' }, - { value: '13', label: 'Instalasi Gizi / Catering', code: 'CAT' }, - { value: '14', label: 'Instalasi Keamanan', code: 'SEC' }, - { value: '15', label: 'Instalasi Gawat Darurat', code: 'EMR' }, - { value: '16', label: 'Instalasi Bedah Sentral', code: 'SUR' }, - { value: '17', label: 'Instalasi Rawat Jalan', code: 'OUT' }, - { value: '18', label: 'Instalasi Rawat Inap', code: 'INP' }, - { value: '19', label: 'Instalasi Rehabilitasi Medik', code: 'REB' }, - { value: '20', label: 'Instalasi Penelitian & Pengembangan', code: 'RSH' }, - ], -} - -export const schemaConf = z.object({ - name: z - .string({ - required_error: 'Nama unit harus diisi', - }) - .min(1, 'Nama unit harus diisi'), - - code: z - .string({ - required_error: 'Kode unit harus diisi', - }) - .min(1, 'Kode unit harus diisi'), - parentId: z.preprocess( - (input: unknown) => { - if (typeof input === 'string') { - // Handle empty string case - if (input.trim() === '') { - return 0 - } - return Number(input) - } - - return input - }, - z - .number({ - required_error: 'Instalasi induk harus dipilih', - }) - .refine((num) => num > 0, 'Instalasi induk harus dipilih'), - ), -}) diff --git a/app/components/content/unit/list.vue b/app/components/content/unit/list.vue index 03edd231..34b647ef 100644 --- a/app/components/content/unit/list.vue +++ b/app/components/content/unit/list.vue @@ -103,9 +103,23 @@ const getCurrentUnitDetail = async (id: number | string) => { watch([recId, recAction], () => { switch (recAction.value) { case ActionEvents.showDetail: - getCurrentUnitDetail(recId.value) - title.value = 'Detail Unit' - 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-unit-id', + params: { + id, + }, + }) + } + break case ActionEvents.showEdit: getCurrentUnitDetail(recId.value) diff --git a/app/models/unit.ts b/app/models/unit.ts index 142f0570..0588dd80 100644 --- a/app/models/unit.ts +++ b/app/models/unit.ts @@ -1,9 +1,11 @@ -import { type Base, genBase } from "./_base" - +import { type Base, genBase } from './_base' +import { type Installation } from '~/models/installation' export interface Unit extends Base { code: string name: string installation_id?: number | string | null + + installation?: Installation } export function genUnit(): Unit { diff --git a/app/pages/(features)/org-src/unit/[id]/index.vue b/app/pages/(features)/org-src/unit/[id]/index.vue new file mode 100644 index 00000000..f118d9fc --- /dev/null +++ b/app/pages/(features)/org-src/unit/[id]/index.vue @@ -0,0 +1,42 @@ + + + + + + + + diff --git a/app/services/unit.service.ts b/app/services/unit.service.ts index 438625f1..ec1ccec0 100644 --- a/app/services/unit.service.ts +++ b/app/services/unit.service.ts @@ -2,7 +2,7 @@ import * as base from './_crud-base' // Types -import type { Unit } from "~/models/unit"; +import type { Unit } from '~/models/unit' const path = '/api/v1/unit' const name = 'unit'
+ {{ field.label }}: + {{ record[field.key] }} +