diff --git a/app/components/app/medicine-group/picker.vue b/app/components/app/medicine-group/picker.vue deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/app/medicine-group/search.vue b/app/components/app/medicine-group/search.vue deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/app/medicine-group/status-badge.vue b/app/components/app/medicine-group/status-badge.vue deleted file mode 100644 index 32cdfbca..00000000 --- a/app/components/app/medicine-group/status-badge.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - diff --git a/app/components/app/medicine-method/picker.vue b/app/components/app/medicine-method/picker.vue deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/app/medicine-method/search.vue b/app/components/app/medicine-method/search.vue deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/app/uom/entry-form.vue b/app/components/app/uom/entry-form.vue new file mode 100644 index 00000000..3bf95352 --- /dev/null +++ b/app/components/app/uom/entry-form.vue @@ -0,0 +1,96 @@ + + + + diff --git a/app/components/app/uom/list-cfg.ts b/app/components/app/uom/list-cfg.ts new file mode 100644 index 00000000..e2c72f9c --- /dev/null +++ b/app/components/app/uom/list-cfg.ts @@ -0,0 +1,46 @@ +import type { + Col, + KeyLabel, + RecComponent, + RecStrFuncComponent, + RecStrFuncUnknown, + Th, +} from '~/components/pub/custom-ui/data/types' +import { defineAsyncComponent } from 'vue' + +const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue')) + +const _doctorStatus = { + 0: 'Tidak Aktif', + 1: 'Aktif', +} + +export const cols: Col[] = [{}, {}, { width: 50 }] + +export const header: Th[][] = [[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Aksi' }]] + +export const keys = ['code', 'name', 'action'] + +export const delKeyNames: KeyLabel[] = [ + { key: 'code', label: 'Kode' }, + { key: 'name', label: 'Nama' }, +] + +export const funcParsed: RecStrFuncUnknown = {} + +export const funcComponent: RecStrFuncComponent = { + action(rec, idx) { + const res: RecComponent = { + idx, + rec: rec as object, + component: action, + } + return res + }, +} + +export const funcHtml: RecStrFuncUnknown = { + patient_address(_rec) { + return '-' + }, +} diff --git a/app/components/app/uom/list.vue b/app/components/app/uom/list.vue new file mode 100644 index 00000000..d44aa4d8 --- /dev/null +++ b/app/components/app/uom/list.vue @@ -0,0 +1,35 @@ + + + diff --git a/app/components/content/equipment/list.vue b/app/components/content/equipment/list.vue index 497b9bd1..40f5417b 100644 --- a/app/components/content/equipment/list.vue +++ b/app/components/content/equipment/list.vue @@ -90,8 +90,8 @@ provide('table_data_loader', isLoading) const getCurrentMaterialDetail = async (id: number | string) => { const result = await getMaterialDetail(id) if (result.success) { - const currentMaterial = result.body?.data || {} - recItem.value = currentMaterial + const currentValue = result.body?.data || {} + recItem.value = currentValue isFormEntryDialogOpen.value = true } } diff --git a/app/components/content/medicine-group/list.vue b/app/components/content/medicine-group/list.vue index 34e8d628..5dd89f9c 100644 --- a/app/components/content/medicine-group/list.vue +++ b/app/components/content/medicine-group/list.vue @@ -81,8 +81,8 @@ provide('table_data_loader', isLoading) const getCurrentMedicineGroupDetail = async (id: number | string) => { const result = await getMedicineGroupDetail(id) if (result.success) { - const currentMaterial = result.body?.data || {} - recItem.value = currentMaterial + const currentValue = result.body?.data || {} + recItem.value = currentValue isFormEntryDialogOpen.value = true } } @@ -115,7 +115,7 @@ onMounted(async () => {
- +
{ const result = await getMedicineMethodDetail(id) if (result.success) { - const currentMaterial = result.body?.data || {} - recItem.value = currentMaterial + const currentValue = result.body?.data || {} + recItem.value = currentValue isFormEntryDialogOpen.value = true } } diff --git a/app/components/content/tools/list.vue b/app/components/content/tools/list.vue index 31cdc2cb..613df671 100644 --- a/app/components/content/tools/list.vue +++ b/app/components/content/tools/list.vue @@ -90,8 +90,8 @@ provide('table_data_loader', isLoading) const getCurrentToolsDetail = async (id: number | string) => { const result = await getDeviceDetail(id) if (result.success) { - const currentDevice = result.body?.data || {} - recItem.value = currentDevice + const currentValue = result.body?.data || {} + recItem.value = currentValue } } diff --git a/app/components/content/uom/list.vue b/app/components/content/uom/list.vue new file mode 100644 index 00000000..fee2e16f --- /dev/null +++ b/app/components/content/uom/list.vue @@ -0,0 +1,162 @@ + + + diff --git a/app/handlers/uom.handler.ts b/app/handlers/uom.handler.ts new file mode 100644 index 00000000..e24fbcfa --- /dev/null +++ b/app/handlers/uom.handler.ts @@ -0,0 +1,92 @@ +import { ref } from 'vue' + +// Handlers +import { type ToastFn, handleAsyncAction } from '~/handlers/_handler' + +// Services +import { postUom, patchUom, removeUom } from '~/services/uom.service' + +const recId = ref(0) +const recAction = ref('') +const recItem = ref(null) +const isReadonly = ref(false) +const isProcessing = ref(false) +const isFormEntryDialogOpen = ref(false) +const isRecordConfirmationOpen = ref(false) + +function onResetState() { + recId.value = 0 + recAction.value = '' + recItem.value = null +} + +export async function handleActionSave(values: any, refresh: () => void, reset: () => void, toast: ToastFn) { + isProcessing.value = true + await handleAsyncAction<[any], any>({ + action: postUom, + args: [values], + toast, + successMessage: 'Data berhasil disimpan', + errorMessage: 'Gagal menyimpan data', + onSuccess: () => { + isFormEntryDialogOpen.value = false + if (refresh) refresh() + }, + onFinally: (isSuccess: boolean) => { + if (isSuccess) setTimeout(reset, 500) + isProcessing.value = false + }, + }) +} + +export async function handleActionEdit( + id: number | string, + values: any, + refresh: () => void, + reset: () => void, + toast: ToastFn, +) { + isProcessing.value = true + await handleAsyncAction<[number | string, any], any>({ + action: patchUom, + args: [id, values], + toast, + successMessage: 'Data berhasil diubah', + errorMessage: 'Gagal mengubah data', + onSuccess: () => { + isFormEntryDialogOpen.value = false + if (refresh) refresh() + }, + onFinally: (isSuccess: boolean) => { + if (isSuccess) setTimeout(reset, 500) + isProcessing.value = false + }, + }) +} + +export async function handleActionRemove(id: number | string, refresh: () => void, toast: ToastFn) { + isProcessing.value = true + await handleAsyncAction<[number | string], any>({ + action: removeUom, + args: [id], + toast, + successMessage: 'Data berhasil dihapus', + errorMessage: 'Gagal menghapus data', + onSuccess: () => { + if (refresh) refresh() + }, + onFinally: () => { + onResetState() + isProcessing.value = false + }, + }) +} + +export function handleCancelForm(reset: () => void) { + isFormEntryDialogOpen.value = false + setTimeout(() => { + reset() + }, 500) +} + +export { recId, recAction, recItem, isReadonly, isProcessing, isFormEntryDialogOpen, isRecordConfirmationOpen } diff --git a/app/models/_model.ts b/app/models/_model.ts index 64e4a972..b5f09a71 100644 --- a/app/models/_model.ts +++ b/app/models/_model.ts @@ -1,15 +1,20 @@ // Default item meta model for entities export interface ItemMeta { - id: number; - createdAt: string | null; - deletedAt: string | null; - updatedAt: string | null; + id: number + createdAt: string | null + deletedAt: string | null + updatedAt: string | null } // Pagination meta model for API responses export interface PaginationMeta { - page_number: string; - page_size: string; - record_totalCount: string; - source: string; + page_number: string + page_size: string + record_totalCount: string + source: string +} + +export interface Base { + name: string + code: string } diff --git a/app/schemas/base.schema.ts b/app/schemas/base.schema.ts new file mode 100644 index 00000000..b46857ac --- /dev/null +++ b/app/schemas/base.schema.ts @@ -0,0 +1,12 @@ +import { z } from 'zod' +import type { Base } from '~/models/_model' + +const BaseSchema = z.object({ + code: z.string({ required_error: 'Kode harus diisi' }).min(1, 'Kode minimum 1 karakter'), + name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'), +}) + +type BaseFormData = z.infer & Base + +export { BaseSchema } +export type { BaseFormData } diff --git a/app/schemas/uom.schema.ts b/app/schemas/uom.schema.ts new file mode 100644 index 00000000..4229e420 --- /dev/null +++ b/app/schemas/uom.schema.ts @@ -0,0 +1,4 @@ +import { BaseSchema, type BaseFormData } from './base.schema' + +export { BaseSchema as UomSchema } +export type { BaseFormData as UomFormData }