Merge pull request #93 from dikstub-rssa/feat/fe-integrasi-2-90

Feat: Integrasi Medicine Group, Method, Uom
This commit is contained in:
Munawwirul Jamal
2025-09-26 21:51:08 +07:00
committed by GitHub
42 changed files with 1198 additions and 401 deletions
+10 -8
View File
@@ -1,16 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
// types // Components
import type z from 'zod'
import type { MaterialFormData } from '~/schemas/material'
// helpers
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
// components
import Block from '~/components/pub/custom-ui/doc-entry/block.vue' import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
import Field from '~/components/pub/custom-ui/doc-entry/field.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
import Label from '~/components/pub/custom-ui/doc-entry/label.vue' import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
// Types
import type { MaterialFormData } from '~/schemas/material.schema'
// Helpers
import type z from 'zod'
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
interface Props { interface Props {
schema: z.ZodSchema<any> schema: z.ZodSchema<any>
uoms: any[] uoms: any[]
@@ -73,7 +75,7 @@ function onCancelForm() {
</script> </script>
<template> <template>
<form id="form-equipment"> <form id="form-equipment" @submit.prevent>
<Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1"> <Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<Cell> <Cell>
<Label height="">Kode</Label> <Label height="">Kode</Label>
-1
View File
@@ -30,7 +30,6 @@ function handlePageChange(page: number) {
:func-html="funcHtml" :func-html="funcHtml"
:func-component="funcComponent" :func-component="funcComponent"
/> />
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" /> <PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div> </div>
</template> </template>
@@ -1,37 +1,96 @@
<script setup lang="ts"> <script setup lang="ts">
import Block from '~/components/pub/custom-ui/form/block.vue' // Components
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue' import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
import Field from '~/components/pub/custom-ui/form/field.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
import Label from '~/components/pub/custom-ui/form/label.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
import Button from '~/components/pub/ui/button/Button.vue'
const props = defineProps<{ modelValue: any }>() // Types
const emit = defineEmits(['update:modelValue', 'event']) import type { MedicineBaseFormData } from '~/schemas/medicine.schema'
const data = computed({ // Helpers
get: () => props.modelValue, import type z from 'zod'
set: (val) => emit('update:modelValue', val), import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
interface Props {
schema?: z.ZodSchema<any>
values?: any
isLoading?: boolean
isReadonly?: boolean
}
const props = defineProps<Props>()
const isLoading = props.isLoading !== undefined ? props.isLoading : false
const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false
const emit = defineEmits<{
submit: [values: MedicineBaseFormData, resetForm: () => void]
cancel: [resetForm: () => void]
}>()
const { defineField, errors, meta } = useForm({
validationSchema: props.schema ? toTypedSchema(props.schema) : undefined,
initialValues: {
code: '',
name: '',
},
}) })
const [code, codeAttrs] = defineField('code')
const [name, nameAttrs] = defineField('name')
if (props.values) {
if (props.values.code !== undefined) code.value = props.values.code
if (props.values.name !== undefined) name.value = props.values.name
}
const resetForm = () => {
code.value = ''
name.value = ''
}
function onSubmitForm() {
const formData = {
name: name.value || '',
code: code.value || '',
}
emit('submit', formData, resetForm)
}
function onCancelForm() {
emit('cancel', resetForm)
}
</script> </script>
<template> <template>
<form id="entry-form"> <form id="form-medicine-group" @submit.prevent>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl"> <Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<div class="flex flex-col justify-between"> <Cell>
<Block> <Label height="">Kode</Label>
<FieldGroup> <Field :errMessage="errors.code">
<Label>Nama</Label> <Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading || isReadonly" />
<Field> </Field>
<Input v-model="data.name" /> </Cell>
</Field> <Cell>
</FieldGroup> <Label height="compact">Nama</Label>
<FieldGroup> <Field :errMessage="errors.name">
<Label>Kode</Label> <Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
<Field> </Field>
<Input /> </Cell>
</Field> </Block>
</FieldGroup> <div class="my-2 flex justify-end gap-2 py-2">
</Block> <Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
</div> <Button
v-if="!isReadonly"
type="button"
class="w-[120px]"
:disabled="isLoading || !meta.valid"
@click="onSubmitForm"
>
Simpan
</Button>
</div> </div>
</form> </form>
</template> </template>
+26 -10
View File
@@ -1,19 +1,35 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PaginationMeta } from '~/components/pub/custom-ui/pagination/pagination.type'
import PaginationView from '~/components/pub/custom-ui/pagination/pagination-view.vue'
import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg' import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg'
defineProps<{ interface Props {
data: any[] data: any[]
paginationMeta: PaginationMeta
}
defineProps<Props>()
const emit = defineEmits<{
pageChange: [page: number]
}>() }>()
function handlePageChange(page: number) {
emit('pageChange', page)
}
</script> </script>
<template> <template>
<PubBaseDataTable <div class="space-y-4">
:rows="data" <PubBaseDataTable
:cols="cols" :rows="data"
:header="header" :cols="cols"
:keys="keys" :header="header"
:func-parsed="funcParsed" :keys="keys"
:func-html="funcHtml" :func-parsed="funcParsed"
:func-component="funcComponent" :func-html="funcHtml"
/> :func-component="funcComponent"
/>
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
</template> </template>
@@ -1,29 +0,0 @@
<script setup lang="ts">
import { Badge } from '~/components/pub/ui/badge'
const props = defineProps<{
rec: any
idx?: number
}>()
const doctorStatus = {
0: 'Tidak Aktif',
1: 'Aktif',
}
const statusText = computed(() => {
return doctorStatus[props.rec.status_code as keyof typeof doctorStatus]
})
const badgeVariant = computed(() => {
return props.rec.status_code === 1 ? 'default' : 'destructive'
})
</script>
<template>
<div class="flex justify-center">
<Badge :variant="badgeVariant">
{{ statusText }}
</Badge>
</div>
</template>
@@ -1,37 +1,96 @@
<script setup lang="ts"> <script setup lang="ts">
import Block from '~/components/pub/custom-ui/form/block.vue' // Components
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue' import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
import Field from '~/components/pub/custom-ui/form/field.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
import Label from '~/components/pub/custom-ui/form/label.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
import Button from '~/components/pub/ui/button/Button.vue'
const props = defineProps<{ modelValue: any }>() // Types
const emit = defineEmits(['update:modelValue', 'event']) import type { MedicineBaseFormData } from '~/schemas/medicine.schema'
const data = computed({ // Helpers
get: () => props.modelValue, import type z from 'zod'
set: (val) => emit('update:modelValue', val), import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
interface Props {
schema?: z.ZodSchema<any>
values?: any
isLoading?: boolean
isReadonly?: boolean
}
const props = defineProps<Props>()
const isLoading = props.isLoading !== undefined ? props.isLoading : false
const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false
const emit = defineEmits<{
submit: [values: MedicineBaseFormData, resetForm: () => void]
cancel: [resetForm: () => void]
}>()
const { defineField, errors, meta } = useForm({
validationSchema: props.schema ? toTypedSchema(props.schema) : undefined,
initialValues: {
code: '',
name: '',
},
}) })
const [code, codeAttrs] = defineField('code')
const [name, nameAttrs] = defineField('name')
if (props.values) {
if (props.values.code !== undefined) code.value = props.values.code
if (props.values.name !== undefined) name.value = props.values.name
}
const resetForm = () => {
code.value = ''
name.value = ''
}
function onSubmitForm() {
const formData = {
name: name.value || '',
code: code.value || '',
}
emit('submit', formData, resetForm)
}
function onCancelForm() {
emit('cancel', resetForm)
}
</script> </script>
<template> <template>
<form id="entry-form"> <form id="form-medicine-method" @submit.prevent>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl"> <Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<div class="flex flex-col justify-between"> <Cell>
<Block> <Label height="">Kode</Label>
<FieldGroup> <Field :errMessage="errors.code">
<Label>Nama</Label> <Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading || isReadonly" />
<Field> </Field>
<Input v-model="data.name" /> </Cell>
</Field> <Cell>
</FieldGroup> <Label height="compact">Nama</Label>
<FieldGroup> <Field :errMessage="errors.name">
<Label>Kode</Label> <Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
<Field> </Field>
<Input /> </Cell>
</Field> </Block>
</FieldGroup> <div class="my-2 flex justify-end gap-2 py-2">
</Block> <Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
</div> <Button
v-if="!isReadonly"
type="button"
class="w-[120px]"
:disabled="isLoading || !meta.valid"
@click="onSubmitForm"
>
Simpan
</Button>
</div> </div>
</form> </form>
</template> </template>
+26 -10
View File
@@ -1,19 +1,35 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PaginationMeta } from '~/components/pub/custom-ui/pagination/pagination.type'
import PaginationView from '~/components/pub/custom-ui/pagination/pagination-view.vue'
import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg' import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg'
defineProps<{ interface Props {
data: any[] data: any[]
paginationMeta: PaginationMeta
}
defineProps<Props>()
const emit = defineEmits<{
pageChange: [page: number]
}>() }>()
function handlePageChange(page: number) {
emit('pageChange', page)
}
</script> </script>
<template> <template>
<PubBaseDataTable <div class="space-y-4">
:rows="data" <PubBaseDataTable
:cols="cols" :rows="data"
:header="header" :cols="cols"
:keys="keys" :header="header"
:func-parsed="funcParsed" :keys="keys"
:func-html="funcHtml" :func-parsed="funcParsed"
:func-component="funcComponent" :func-html="funcHtml"
/> :func-component="funcComponent"
/>
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
</template> </template>
+10 -8
View File
@@ -1,16 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
// helpers // Components
import { toTypedSchema } from '@vee-validate/zod'
import { useForm } from 'vee-validate'
// types
import type z from 'zod'
import type { DeviceFormData } from '~/schemas/device'
// components
import Block from '~/components/pub/custom-ui/doc-entry/block.vue' import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue' import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
import Field from '~/components/pub/custom-ui/doc-entry/field.vue' import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
import Label from '~/components/pub/custom-ui/doc-entry/label.vue' import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
// Types
import type { DeviceFormData } from '~/schemas/device.schema'
// Helpers
import type z from 'zod'
import { toTypedSchema } from '@vee-validate/zod'
import { useForm } from 'vee-validate'
interface Props { interface Props {
schema: z.ZodSchema<any> schema: z.ZodSchema<any>
uoms: any[] uoms: any[]
@@ -71,7 +73,7 @@ function onCancelForm() {
</script> </script>
<template> <template>
<form id="form-tools"> <form id="form-tools" @submit.prevent>
<Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1"> <Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<Cell> <Cell>
<Label height="compact">Kode</Label> <Label height="compact">Kode</Label>
+7 -3
View File
@@ -22,10 +22,14 @@ function handlePageChange(page: number) {
<template> <template>
<div class="space-y-4"> <div class="space-y-4">
<PubBaseDataTable <PubBaseDataTable
:rows="data" :cols="cols" :header="header" :keys="keys" :func-parsed="funcParsed" :rows="data"
:func-html="funcHtml" :func-component="funcComponent" :cols="cols"
:header="header"
:keys="keys"
:func-parsed="funcParsed"
:func-html="funcHtml"
:func-component="funcComponent"
/> />
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" /> <PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div> </div>
</template> </template>
+96
View File
@@ -0,0 +1,96 @@
<script setup lang="ts">
// Components
import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
import Button from '~/components/pub/ui/button/Button.vue'
// Types
import type { UomFormData } from '~/schemas/uom.schema'
// Helpers
import type z from 'zod'
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
interface Props {
schema?: z.ZodSchema<any>
values?: any
isLoading?: boolean
isReadonly?: boolean
}
const props = defineProps<Props>()
const isLoading = props.isLoading !== undefined ? props.isLoading : false
const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false
const emit = defineEmits<{
submit: [values: UomFormData, resetForm: () => void]
cancel: [resetForm: () => void]
}>()
const { defineField, errors, meta } = useForm({
validationSchema: props.schema ? toTypedSchema(props.schema) : undefined,
initialValues: {
code: '',
name: '',
},
})
const [code, codeAttrs] = defineField('code')
const [name, nameAttrs] = defineField('name')
if (props.values) {
if (props.values.code !== undefined) code.value = props.values.code
if (props.values.name !== undefined) name.value = props.values.name
}
const resetForm = () => {
code.value = ''
name.value = ''
}
function onSubmitForm() {
const formData = {
name: name.value || '',
code: code.value || '',
}
emit('submit', formData, resetForm)
}
function onCancelForm() {
emit('cancel', resetForm)
}
</script>
<template>
<form id="form-medicine-method" @submit.prevent>
<Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<Cell>
<Label height="">Kode</Label>
<Field :errMessage="errors.code">
<Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading || isReadonly" />
</Field>
</Cell>
<Cell>
<Label height="compact">Nama</Label>
<Field :errMessage="errors.name">
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
</Field>
</Cell>
</Block>
<div class="my-2 flex justify-end gap-2 py-2">
<Button type="button" variant="secondary" class="w-[120px]" @click="onCancelForm"> Kembali </Button>
<Button
v-if="!isReadonly"
type="button"
class="w-[120px]"
:disabled="isLoading || !meta.valid"
@click="onSubmitForm"
>
Simpan
</Button>
</div>
</form>
</template>
+46
View File
@@ -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 '-'
},
}
+35
View File
@@ -0,0 +1,35 @@
<script setup lang="ts">
import type { PaginationMeta } from '~/components/pub/custom-ui/pagination/pagination.type'
import PaginationView from '~/components/pub/custom-ui/pagination/pagination-view.vue'
import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg'
interface Props {
data: any[]
paginationMeta: PaginationMeta
}
defineProps<Props>()
const emit = defineEmits<{
pageChange: [page: number]
}>()
function handlePageChange(page: number) {
emit('pageChange', page)
}
</script>
<template>
<div class="space-y-4">
<PubBaseDataTable
:rows="data"
:cols="cols"
:header="header"
:keys="keys"
:func-parsed="funcParsed"
:func-html="funcHtml"
:func-component="funcComponent"
/>
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
</template>
+1 -1
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue' import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue'
import { MaterialSchema, type MaterialFormData } from '~/schemas/material' import { MaterialSchema, type MaterialFormData } from '~/schemas/material.schema'
const data = ref({ const data = ref({
name: '', name: '',
+27 -26
View File
@@ -1,16 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { MaterialSchema, type MaterialFormData } from '~/schemas/material' // Components
import { usePaginatedList } from '~/composables/usePaginatedList'
import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
import Dialog from '~/components/pub/base/modal/dialog.vue' import Dialog from '~/components/pub/base/modal/dialog.vue'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue' import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
import AppEquipmentEntryForm from '~/components/app/equipment/entry-form.vue' import AppEquipmentEntryForm from '~/components/app/equipment/entry-form.vue'
import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue' import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue'
// helpers // Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast' import { toast } from '~/components/pub/ui/toast'
// Types // Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
import { MaterialSchema, type MaterialFormData } from '~/schemas/material.schema'
import type { Uom } from '~/models/uom' import type { Uom } from '~/models/uom'
// Handlers // Handlers
@@ -29,29 +30,12 @@ import {
} from '~/handlers/material.handler' } from '~/handlers/material.handler'
// Services // Services
import { getSourceMaterials, getSourceMaterialDetail } from '~/services/material.service' import { getMaterials, getMaterialDetail } from '~/services/material.service'
import { getSourceUoms } from '~/services/uom.service' import { getUoms } from '~/services/uom.service'
const uoms = ref<{ value: string; label: string }[]>([]) const uoms = ref<{ value: string; label: string }[]>([])
const title = ref('') const title = ref('')
const getEquipmentDetail = async (id: number | string) => {
const result = await getSourceMaterialDetail(id)
if (result.success) {
const currentMaterial = result.body?.data || {}
recItem.value = currentMaterial
isFormEntryDialogOpen.value = true
}
}
const getUomList = async () => {
const result = await getSourceUoms()
if (result.success) {
const currentUoms = result.body?.data || []
uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
}
}
const { const {
data, data,
isLoading, isLoading,
@@ -62,7 +46,7 @@ const {
fetchData: getEquipmentList, fetchData: getEquipmentList,
} = usePaginatedList({ } = usePaginatedList({
fetchFn: async ({ page }) => { fetchFn: async ({ page }) => {
const result = await getSourceMaterials({ search: searchInput.value, page }) const result = await getMaterials({ search: searchInput.value, page })
return { success: result.success || false, body: result.body || {} } return { success: result.success || false, body: result.body || {} }
}, },
entityName: 'equipment', entityName: 'equipment',
@@ -103,16 +87,33 @@ provide('rec_action', recAction)
provide('rec_item', recItem) provide('rec_item', recItem)
provide('table_data_loader', isLoading) provide('table_data_loader', isLoading)
const getCurrentMaterialDetail = async (id: number | string) => {
const result = await getMaterialDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
const getUomList = async () => {
const result = await getUoms()
if (result.success) {
const currentUoms = result.body?.data || []
uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
}
}
// Watch for row actions when recId or recAction changes // Watch for row actions when recId or recAction changes
watch([recId, recAction], () => { watch([recId, recAction], () => {
switch (recAction.value) { switch (recAction.value) {
case ActionEvents.showDetail: case ActionEvents.showDetail:
getEquipmentDetail(recId.value) getCurrentMaterialDetail(recId.value)
title.value = 'Detail Perlengkapan' title.value = 'Detail Perlengkapan'
isReadonly.value = true isReadonly.value = true
break break
case ActionEvents.showEdit: case ActionEvents.showEdit:
getEquipmentDetail(recId.value) getCurrentMaterialDetail(recId.value)
title.value = 'Edit Perlengkapan' title.value = 'Edit Perlengkapan'
isReadonly.value = false isReadonly.value = false
break break
+2 -2
View File
@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
// types // types
import type { MaterialFormData } from '~/schemas/material' import type { MaterialFormData } from '~/schemas/material.schema'
import { MaterialSchema } from '~/schemas/material' import { MaterialSchema } from '~/schemas/material.schema'
const isLoading = ref(false) const isLoading = ref(false)
const uoms = [ const uoms = [
+141 -54
View File
@@ -1,75 +1,162 @@
<script setup lang="ts"> <script setup lang="ts">
import type { DataTableLoader } from '~/components/pub/base/data-table/type' // Components
import type { HeaderPrep, RefSearchNav } from '~/components/pub/custom-ui/data/types' import Dialog from '~/components/pub/base/modal/dialog.vue'
import Modal from '~/components/pub/base/modal/modal.vue'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue' import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
import AppMedicineGroupEntryForm from '~/components/app/medicine-group/entry-form.vue'
import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue'
const data = ref([]) // Helpers
const entry = ref<any>({}) import { usePaginatedList } from '~/composables/usePaginatedList'
const page = ref(1) import { toast } from '~/components/pub/ui/toast'
const rowsPerPage = ref(10)
const totalPages = 20
const refSearchNav: RefSearchNav = { // Types
onClick: () => { import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
// open filter modal import { MedicineBaseSchema, type MedicineBaseFormData } from '~/schemas/medicine.schema'
},
onInput: (_val: string) => {
// filter patient list
},
onClear: () => {
// clear url param
},
}
// Loading state management // Handlers
const isLoading = reactive<DataTableLoader>({ import {
summary: false, recId,
isTableLoading: false, recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/medicine-group.handler'
// Services
import { getMedicineGroups, getMedicineGroupDetail } from '~/services/medicine-group.service'
const title = ref('')
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMedicineGroupList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getMedicineGroups({ search, page })
return { success: result.success || false, body: result.body || {} }
},
entityName: 'medicine-group',
}) })
const isOpen = ref(false) const headerPrep: HeaderPrep = {
title: 'Kelompok Obat',
const recId = ref<number>(0) icon: 'i-lucide-medicine-bottle',
const recAction = ref<string>('') refSearchNav: {
const recItem = ref<any>(null) placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
const hreaderPrep: HeaderPrep = { debounceMs: 500,
title: 'Golongan Obat', showValidationFeedback: true,
icon: 'i-lucide-users', onInput: (_val: string) => {},
onClick: () => {},
onClear: () => {},
},
addNav: { addNav: {
label: 'Tambah', label: 'Tambah',
onClick: () => (isOpen.value = true), icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
},
}, },
} }
async function getPatientList() {
isLoading.isTableLoading = true
const resp = await xfetch('/api/v1/medicine-group')
if (resp.success) {
data.value = (resp.body as Record<string, any>).data
}
isLoading.isTableLoading = false
}
onMounted(() => {
getPatientList()
})
provide('rec_id', recId) provide('rec_id', recId)
provide('rec_action', recAction) provide('rec_action', recAction)
provide('rec_item', recItem) provide('rec_item', recItem)
provide('table_data_loader', isLoading) provide('table_data_loader', isLoading)
const getCurrentMedicineGroupDetail = async (id: number | string) => {
const result = await getMedicineGroupDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getCurrentMedicineGroupDetail(recId.value)
title.value = 'Detail Kelompok Obat'
isReadonly.value = true
break
case ActionEvents.showEdit:
getCurrentMedicineGroupDetail(recId.value)
title.value = 'Edit Kelompok Obat'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
onMounted(async () => {
await getMedicineGroupList()
})
</script> </script>
<template> <template>
<Header :prep="{ ...hreaderPrep }" :ref-search-nav="refSearchNav" /> <div class="p-4">
<div class="my-4 flex flex-1 flex-col gap-4 md:gap-8"> <Header v-model="searchInput" :prep="headerPrep" @search="handleSearch" />
<AppMedicineGroupList :data="data" /> <div class="rounded-md border p-4">
<Pagination v-model:page="page" v-model:rows-per-page="rowsPerPage" :total-pages="totalPages" /> <AppMedicineGroupList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div> </div>
<Modal v-model:open="isOpen" title="Tambah Golongan Obat" size="lg" prevent-outside> <Dialog
<AppMedicineGroupEntryForm v-model="entry" /> v-model:open="isFormEntryDialogOpen"
</Modal> :title="!!recItem ? title : 'Tambah Kelompok Obat'"
size="lg"
prevent-outside
>
<AppMedicineGroupEntryForm
:schema="MedicineBaseSchema"
:values="recItem"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: MedicineBaseFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMedicineGroupList, resetForm, toast)
return
}
handleActionSave(values, getMedicineGroupList, resetForm, toast)
}
"
@cancel="handleCancelForm"
/>
</Dialog>
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMedicineGroupList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p><strong>ID:</strong> {{ record?.id }}</p>
<p v-if="record?.name"><strong>Nama:</strong> {{ record.name }}</p>
<p v-if="record?.code"><strong>Kode:</strong> {{ record.code }}</p>
</div>
</template>
</RecordConfirmation>
</div>
</template> </template>
+140 -52
View File
@@ -1,74 +1,162 @@
<script setup lang="ts"> <script setup lang="ts">
import type { DataTableLoader } from '~/components/pub/base/data-table/type' // Components
import type { HeaderPrep, RefSearchNav } from '~/components/pub/custom-ui/data/types' import Dialog from '~/components/pub/base/modal/dialog.vue'
import Modal from '~/components/pub/base/modal/modal.vue'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue' import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
import { getMedicineMethods } from '~/services/medicine-method.service' import AppMedicineMethodEntryForm from '~/components/app/medicine-method/entry-form.vue'
import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue'
const data = ref([]) // Helpers
const entry = ref<any>({}) import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
const refSearchNav: RefSearchNav = { // Types
onClick: () => { import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
// open filter modal import { MedicineBaseSchema, type MedicineBaseFormData } from '~/schemas/medicine.schema'
},
onInput: (_val: string) => {
// filter patient list
},
onClear: () => {
// clear url param
},
}
// Loading state management // Handlers
const isLoading = reactive<DataTableLoader>({ import {
summary: false, recId,
isTableLoading: false, recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/medicine-method.handler'
// Services
import { getMedicineMethods, getMedicineMethodDetail } from '~/services/medicine-method.service'
const title = ref('')
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMedicineMethodList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getMedicineMethods({ search, page })
return { success: result.success || false, body: result.body || {} }
},
entityName: 'medicine-method',
}) })
const isOpen = ref(false) const headerPrep: HeaderPrep = {
title: 'Metode Obat',
const recId = ref<number>(0)
const recAction = ref<string>('')
const recItem = ref<any>(null)
const hreaderPrep: HeaderPrep = {
title: 'Metode Pemberian',
icon: 'i-lucide-medicine-bottle', icon: 'i-lucide-medicine-bottle',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
debounceMs: 500,
showValidationFeedback: true,
onInput: (_val: string) => {},
onClick: () => {},
onClear: () => {},
},
addNav: { addNav: {
label: 'Tambah', label: 'Tambah',
onClick: () => (isOpen.value = true), icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
},
}, },
} }
async function getData() {
try {
isLoading.isTableLoading = true
data.value = await getMedicineMethods()
} catch (err) {
console.error(err)
} finally {
isLoading.isTableLoading = false
}
}
onMounted(() => {
getData()
})
provide('rec_id', recId) provide('rec_id', recId)
provide('rec_action', recAction) provide('rec_action', recAction)
provide('rec_item', recItem) provide('rec_item', recItem)
provide('table_data_loader', isLoading) provide('table_data_loader', isLoading)
const getCurrentMedicineMethodDetail = async (id: number | string) => {
const result = await getMedicineMethodDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getCurrentMedicineMethodDetail(recId.value)
title.value = 'Detail Metode Obat'
isReadonly.value = true
break
case ActionEvents.showEdit:
getCurrentMedicineMethodDetail(recId.value)
title.value = 'Edit Metode Obat'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
onMounted(async () => {
await getMedicineMethodList()
})
</script> </script>
<template> <template>
<Header :prep="{ ...hreaderPrep }" :ref-search-nav="refSearchNav" /> <div class="p-4">
<div class="my-4 flex flex-1 flex-col gap-4 md:gap-8"> <Header v-model="searchInput" :prep="headerPrep" @search="handleSearch" />
<AppMedicineMethodList :data="data" /> <div class="rounded-md border p-4">
</div> <AppMedicineMethodList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
<Modal v-model:open="isOpen" title="Tambah Metode Pemberian" size="lg" prevent-outside> <Dialog
<AppMedicineMethodEntryForm v-model="entry" /> v-model:open="isFormEntryDialogOpen"
</Modal> :title="!!recItem ? title : 'Tambah Metode Obat'"
size="lg"
prevent-outside
>
<AppMedicineMethodEntryForm
:schema="MedicineBaseSchema"
:values="recItem"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: MedicineBaseFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMedicineMethodList, resetForm, toast)
return
}
handleActionSave(values, getMedicineMethodList, resetForm, toast)
}
"
@cancel="handleCancelForm"
/>
</Dialog>
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMedicineMethodList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p><strong>ID:</strong> {{ record?.id }}</p>
<p v-if="record?.name"><strong>Nama:</strong> {{ record.name }}</p>
<p v-if="record?.code"><strong>Kode:</strong> {{ record.code }}</p>
</div>
</template>
</RecordConfirmation>
</div>
</template> </template>
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue' import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue'
import { MaterialSchema, type MaterialFormData } from '~/schemas/material' import { MaterialSchema, type MaterialFormData } from '~/schemas/material.schema'
const data = ref({ const data = ref({
name: '', name: '',
+26 -25
View File
@@ -1,16 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { DeviceSchema, type DeviceFormData } from '~/schemas/device' // Components
import { usePaginatedList } from '~/composables/usePaginatedList'
import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
import Dialog from '~/components/pub/base/modal/dialog.vue' import Dialog from '~/components/pub/base/modal/dialog.vue'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue' import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
import AppToolsEntryForm from '~/components/app/tools/entry-form.vue' import AppToolsEntryForm from '~/components/app/tools/entry-form.vue'
import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue' import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue'
// helpers // Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast' import { toast } from '~/components/pub/ui/toast'
// Types // Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
import { DeviceSchema, type DeviceFormData } from '~/schemas/device.schema'
import type { Uom } from '~/models/uom' import type { Uom } from '~/models/uom'
// Handlers // Handlers
@@ -29,28 +30,12 @@ import {
} from '~/handlers/device.handler' } from '~/handlers/device.handler'
// Services // Services
import { getSourceDevices, getSourceDeviceDetail } from '~/services/device.service' import { getDevices, getDeviceDetail } from '~/services/device.service'
import { getSourceUoms } from '~/services/uom.service' import { getUoms } from '~/services/uom.service'
const uoms = ref<{ value: string; label: string }[]>([]) const uoms = ref<{ value: string; label: string }[]>([])
const title = ref('') const title = ref('')
const getToolsDetail = async (id: number | string) => {
const result = await getSourceDeviceDetail(id)
if (result.success) {
const currentDevice = result.body?.data || {}
recItem.value = currentDevice
}
}
const getUomList = async () => {
const result = await getSourceUoms()
if (result.success) {
const currentUoms = result.body?.data || []
uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
}
}
const { const {
data, data,
isLoading, isLoading,
@@ -61,7 +46,7 @@ const {
fetchData: getToolsList, fetchData: getToolsList,
} = usePaginatedList({ } = usePaginatedList({
fetchFn: async ({ page }) => { fetchFn: async ({ page }) => {
const result = await getSourceDevices({ search: searchInput.value, page }) const result = await getDevices({ search: searchInput.value, page })
return { success: result.success || false, body: result.body || {} } return { success: result.success || false, body: result.body || {} }
}, },
entityName: 'device', entityName: 'device',
@@ -102,17 +87,33 @@ provide('rec_action', recAction)
provide('rec_item', recItem) provide('rec_item', recItem)
provide('table_data_loader', isLoading) provide('table_data_loader', isLoading)
const getCurrentToolsDetail = async (id: number | string) => {
const result = await getDeviceDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
}
}
const getUomList = async () => {
const result = await getUoms()
if (result.success) {
const currentUoms = result.body?.data || []
uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
}
}
// Watch for row actions // Watch for row actions
watch([recId, recAction], () => { watch([recId, recAction], () => {
switch (recAction.value) { switch (recAction.value) {
case ActionEvents.showDetail: case ActionEvents.showDetail:
getToolsDetail(recId.value) getCurrentToolsDetail(recId.value)
title.value = 'Detail Peralatan' title.value = 'Detail Peralatan'
isReadonly.value = true isReadonly.value = true
isFormEntryDialogOpen.value = true isFormEntryDialogOpen.value = true
break break
case ActionEvents.showEdit: case ActionEvents.showEdit:
getToolsDetail(recId.value) getCurrentToolsDetail(recId.value)
title.value = 'Edit Peralatan' title.value = 'Edit Peralatan'
isReadonly.value = false isReadonly.value = false
isFormEntryDialogOpen.value = true isFormEntryDialogOpen.value = true
+162
View File
@@ -0,0 +1,162 @@
<script setup lang="ts">
// Components
import Dialog from '~/components/pub/base/modal/dialog.vue'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
import AppUomEntryForm from '~/components/app/uom/entry-form.vue'
import RecordConfirmation from '~/components/pub/custom-ui/confirmation/record-confirmation.vue'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/custom-ui/data/types'
import { UomSchema, type UomFormData } from '~/schemas/uom.schema'
// Handlers
import {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/uom.handler'
// Services
import { getUoms, getUomDetail } from '~/services/uom.service'
const title = ref('')
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getUomList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getUoms({ search, page })
return { success: result.success || false, body: result.body || {} }
},
entityName: 'uom',
})
const headerPrep: HeaderPrep = {
title: 'Uom',
icon: 'i-lucide-layout-dashboard',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
debounceMs: 500,
showValidationFeedback: true,
onInput: (_val: string) => {},
onClick: () => {},
onClear: () => {},
},
addNav: {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
},
},
}
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
const getCurrentUomDetail = async (id: number | string) => {
const result = await getUomDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getCurrentUomDetail(recId.value)
title.value = 'Detail Uom'
isReadonly.value = true
break
case ActionEvents.showEdit:
getCurrentUomDetail(recId.value)
title.value = 'Edit Uom'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
onMounted(async () => {
await getUomList()
})
</script>
<template>
<div class="p-4">
<Header v-model="searchInput" :prep="headerPrep" @search="handleSearch" />
<div class="rounded-md border p-4">
<AppUomList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
<Dialog
v-model:open="isFormEntryDialogOpen"
:title="!!recItem ? title : 'Tambah Uom'"
size="lg"
prevent-outside
>
<AppUomEntryForm
:schema="UomSchema"
:values="recItem"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: UomFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getUomList, resetForm, toast)
return
}
handleActionSave(values, getUomList, resetForm, toast)
}
"
@cancel="handleCancelForm"
/>
</Dialog>
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getUomList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p><strong>ID:</strong> {{ record?.id }}</p>
<p v-if="record?.name"><strong>Nama:</strong> {{ record.name }}</p>
<p v-if="record?.code"><strong>Kode:</strong> {{ record.code }}</p>
</div>
</template>
</RecordConfirmation>
</div>
</template>
+4 -4
View File
@@ -4,7 +4,7 @@ import { ref } from 'vue'
import { type ToastFn, handleAsyncAction } from '~/handlers/_handler' import { type ToastFn, handleAsyncAction } from '~/handlers/_handler'
// Services // Services
import { postSourceDevice, patchSourceDevice, removeSourceDevice } from '~/services/device.service' import { postDevice, patchDevice, removeDevice } from '~/services/device.service'
const recId = ref<number>(0) const recId = ref<number>(0)
const recAction = ref<string>('') const recAction = ref<string>('')
@@ -28,7 +28,7 @@ export async function handleActionSave(
) { ) {
isProcessing.value = true; isProcessing.value = true;
await handleAsyncAction<[any], any>({ await handleAsyncAction<[any], any>({
action: postSourceDevice, action: postDevice,
args: [values], args: [values],
toast, toast,
successMessage: 'Data berhasil disimpan', successMessage: 'Data berhasil disimpan',
@@ -53,7 +53,7 @@ export async function handleActionEdit(
) { ) {
isProcessing.value = true; isProcessing.value = true;
await handleAsyncAction<[number | string, any], any>({ await handleAsyncAction<[number | string, any], any>({
action: patchSourceDevice, action: patchDevice,
args: [id, values], args: [id, values],
toast, toast,
successMessage: 'Data berhasil diubah', successMessage: 'Data berhasil diubah',
@@ -76,7 +76,7 @@ export async function handleActionRemove(
) { ) {
isProcessing.value = true; isProcessing.value = true;
await handleAsyncAction<[number | string], any>({ await handleAsyncAction<[number | string], any>({
action: removeSourceDevice, action: removeDevice,
args: [id], args: [id],
toast, toast,
successMessage: 'Data berhasil dihapus', successMessage: 'Data berhasil dihapus',
+4 -4
View File
@@ -4,7 +4,7 @@ import { ref } from 'vue'
import { type ToastFn, handleAsyncAction } from '~/handlers/_handler' import { type ToastFn, handleAsyncAction } from '~/handlers/_handler'
// Services // Services
import { postSourceMaterial, patchSourceMaterial, removeSourceMaterial } from '~/services/material.service' import { postMaterial, patchMaterial, removeMaterial } from '~/services/material.service'
const recId = ref<number>(0) const recId = ref<number>(0)
const recAction = ref<string>('') const recAction = ref<string>('')
@@ -23,7 +23,7 @@ function onResetState() {
export async function handleActionSave(values: any, refresh: () => void, reset: () => void, toast: ToastFn) { export async function handleActionSave(values: any, refresh: () => void, reset: () => void, toast: ToastFn) {
isProcessing.value = true isProcessing.value = true
await handleAsyncAction<[any], any>({ await handleAsyncAction<[any], any>({
action: postSourceMaterial, action: postMaterial,
args: [values], args: [values],
toast, toast,
successMessage: 'Data berhasil disimpan', successMessage: 'Data berhasil disimpan',
@@ -48,7 +48,7 @@ export async function handleActionEdit(
) { ) {
isProcessing.value = true isProcessing.value = true
await handleAsyncAction<[number | string, any], any>({ await handleAsyncAction<[number | string, any], any>({
action: patchSourceMaterial, action: patchMaterial,
args: [id, values], args: [id, values],
toast, toast,
successMessage: 'Data berhasil diubah', successMessage: 'Data berhasil diubah',
@@ -67,7 +67,7 @@ export async function handleActionEdit(
export async function handleActionRemove(id: number | string, refresh: () => void, toast: ToastFn) { export async function handleActionRemove(id: number | string, refresh: () => void, toast: ToastFn) {
isProcessing.value = true isProcessing.value = true
await handleAsyncAction<[number | string], any>({ await handleAsyncAction<[number | string], any>({
action: removeSourceMaterial, action: removeMaterial,
args: [id], args: [id],
toast, toast,
successMessage: 'Data berhasil dihapus', successMessage: 'Data berhasil dihapus',
+92
View File
@@ -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<number>(0)
const recAction = ref<string>('')
const recItem = ref<any>(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 }
+13 -8
View File
@@ -1,15 +1,20 @@
// Default item meta model for entities // Default item meta model for entities
export interface ItemMeta { export interface ItemMeta {
id: number; id: number
createdAt: string | null; createdAt: string | null
deletedAt: string | null; deletedAt: string | null
updatedAt: string | null; updatedAt: string | null
} }
// Pagination meta model for API responses // Pagination meta model for API responses
export interface PaginationMeta { export interface PaginationMeta {
page_number: string; page_number: string
page_size: string; page_size: string
record_totalCount: string; record_totalCount: string
source: string; source: string
}
export interface Base {
name: string
code: string
} }
+5
View File
@@ -1,3 +1,8 @@
export interface MedicineBase {
name: string
code: string
}
export interface Medicine { export interface Medicine {
id: string id: string
name: string name: string
@@ -6,7 +6,7 @@ import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({ definePageMeta({
middleware: ['rbac'], middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'], roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Tambah User', title: 'Daftar User',
contentFrame: 'cf-full-width', contentFrame: 'cf-full-width',
}) })
@@ -18,24 +18,23 @@ useHead({
const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor'] const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor']
const { checkRole, hasCreateAccess } = useRBAC() const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page // Check if user has access to this page
const hasAccess = checkRole(roleAccess) const hasAccess = checkRole(roleAccess)
if (!hasAccess) { if (!hasAccess) {
throw createError({ navigateTo('/403')
statusCode: 403,
statusMessage: 'Access denied',
})
} }
// Define permission-based computed properties // Define permission-based computed properties
const canCreate = hasCreateAccess(roleAccess) const canRead = true // hasReadAccess(roleAccess)
</script> </script>
<template> <template>
<div v-if="canCreate"> <div>
<ContentDeviceEntry /> <div v-if="canRead">
<ContentUomList />
</div>
<Error v-else :status-code="403" />
</div> </div>
<Error v-else :status-code="403" />
</template> </template>
@@ -1,41 +0,0 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/base/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Tambah User',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor']
const { checkRole, hasCreateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
statusCode: 403,
statusMessage: 'Access denied',
})
}
// Define permission-based computed properties
const canCreate = hasCreateAccess(roleAccess)
</script>
<template>
<div v-if="canCreate">
<ContentMaterialEntry />
</div>
<Error v-else :status-code="403" />
</template>
+12
View File
@@ -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<typeof BaseSchema> & Base
export { BaseSchema }
export type { BaseFormData }
+12
View File
@@ -0,0 +1,12 @@
import { z } from 'zod'
import type { MedicineBase } from '~/models/medicine'
const MedicineBaseSchema = 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 MedicineBaseFormData = z.infer<typeof MedicineBaseSchema> & MedicineBase
export { MedicineBaseSchema }
export type { MedicineBaseFormData }
+4
View File
@@ -0,0 +1,4 @@
import { BaseSchema, type BaseFormData } from './base.schema'
export { BaseSchema as UomSchema }
export type { BaseFormData as UomFormData }
+7 -7
View File
@@ -2,7 +2,7 @@ import { xfetch } from '~/composables/useXfetch'
const mainUrl = '/api/v1/device' const mainUrl = '/api/v1/device'
export async function getSourceDevices(params: any = null) { export async function getDevices(params: any = null) {
try { try {
let url = mainUrl let url = mainUrl
if (params && typeof params === 'object' && Object.keys(params).length > 0) { if (params && typeof params === 'object' && Object.keys(params).length > 0) {
@@ -21,12 +21,12 @@ export async function getSourceDevices(params: any = null) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source devices:', error) console.error('Error fetching devices:', error)
throw new Error('Failed to fetch source devices') throw new Error('Failed to fetch devices')
} }
} }
export async function getSourceDeviceDetail(id: string | number) { export async function getDeviceDetail(id: string | number) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'GET') const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
const result: any = {} const result: any = {}
@@ -39,7 +39,7 @@ export async function getSourceDeviceDetail(id: string | number) {
} }
} }
export async function postSourceDevice(data: any) { export async function postDevice(data: any) {
try { try {
const resp = await xfetch(mainUrl, 'POST', data) const resp = await xfetch(mainUrl, 'POST', data)
const result: any = {} const result: any = {}
@@ -52,7 +52,7 @@ export async function postSourceDevice(data: any) {
} }
} }
export async function patchSourceDevice(id: string | number, data: any) { export async function patchDevice(id: string | number, data: any) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', data) const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', data)
const result: any = {} const result: any = {}
@@ -65,7 +65,7 @@ export async function patchSourceDevice(id: string | number, data: any) {
} }
} }
export async function removeSourceDevice(id: string | number) { export async function removeDevice(id: string | number) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE') const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
const result: any = {} const result: any = {}
+14 -14
View File
@@ -2,7 +2,7 @@ import { xfetch } from '~/composables/useXfetch'
const mainUrl = '/api/v1/material' const mainUrl = '/api/v1/material'
export async function getSourceMaterials(params: any = null) { export async function getMaterials(params: any = null) {
try { try {
let url = mainUrl let url = mainUrl
if (params && typeof params === 'object' && Object.keys(params).length > 0) { if (params && typeof params === 'object' && Object.keys(params).length > 0) {
@@ -21,12 +21,12 @@ export async function getSourceMaterials(params: any = null) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source materials:', error) console.error('Error fetching materials:', error)
throw new Error('Failed to fetch source materials') throw new Error('Failed to fetch materials')
} }
} }
export async function getSourceMaterialDetail(id: number | string) { export async function getMaterialDetail(id: number | string) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'GET') const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
const result: any = {} const result: any = {}
@@ -34,12 +34,12 @@ export async function getSourceMaterialDetail(id: number | string) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source material detail:', error) console.error('Error fetching material detail:', error)
throw new Error('Failed to get source material detail') throw new Error('Failed to get material detail')
} }
} }
export async function postSourceMaterial(record: any) { export async function postMaterial(record: any) {
try { try {
const resp = await xfetch(mainUrl, 'POST', record) const resp = await xfetch(mainUrl, 'POST', record)
const result: any = {} const result: any = {}
@@ -47,12 +47,12 @@ export async function postSourceMaterial(record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error posting source material:', error) console.error('Error posting material:', error)
throw new Error('Failed to post source material') throw new Error('Failed to post material')
} }
} }
export async function patchSourceMaterial(id: number | string, record: any) { export async function patchMaterial(id: number | string, record: any) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record) const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
const result: any = {} const result: any = {}
@@ -60,12 +60,12 @@ export async function patchSourceMaterial(id: number | string, record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error putting source material:', error) console.error('Error putting material:', error)
throw new Error('Failed to put source material') throw new Error('Failed to put material')
} }
} }
export async function removeSourceMaterial(id: number | string) { export async function removeMaterial(id: number | string) {
try { try {
const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE') const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
const result: any = {} const result: any = {}
@@ -74,6 +74,6 @@ export async function removeSourceMaterial(id: number | string) {
return result return result
} catch (error) { } catch (error) {
console.error('Error deleting record:', error) console.error('Error deleting record:', error)
throw new Error('Failed to delete source material') throw new Error('Failed to delete material')
} }
} }
+9 -9
View File
@@ -21,8 +21,8 @@ export async function getMedicineGroups(params: any = null) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source materials:', error) console.error('Error fetching medicine groups:', error)
throw new Error('Failed to fetch source materials') throw new Error('Failed to fetch medicine groups')
} }
} }
@@ -34,8 +34,8 @@ export async function getMedicineGroupDetail(id: number | string) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source material detail:', error) console.error('Error fetching medicine group detail:', error)
throw new Error('Failed to get source material detail') throw new Error('Failed to get medicine group detail')
} }
} }
@@ -47,8 +47,8 @@ export async function postMedicineGroup(record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error posting source material:', error) console.error('Error posting medicine group:', error)
throw new Error('Failed to post source material') throw new Error('Failed to post medicine group')
} }
} }
@@ -60,8 +60,8 @@ export async function patchMedicineGroup(id: number | string, record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error putting source material:', error) console.error('Error putting medicine group:', error)
throw new Error('Failed to put source material') throw new Error('Failed to put medicine group')
} }
} }
@@ -74,6 +74,6 @@ export async function removeMedicineGroup(id: number | string) {
return result return result
} catch (error) { } catch (error) {
console.error('Error deleting record:', error) console.error('Error deleting record:', error)
throw new Error('Failed to delete source material') throw new Error('Failed to delete medicine group')
} }
} }
+9 -9
View File
@@ -29,8 +29,8 @@ export async function getMedicineMethods(params: any = null) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source materials:', error) console.error('Error fetching medicine methods:', error)
throw new Error('Failed to fetch source materials') throw new Error('Failed to fetch medicine methods')
} }
} }
@@ -42,8 +42,8 @@ export async function getMedicineMethodDetail(id: number | string) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source material detail:', error) console.error('Error fetching medicine method detail:', error)
throw new Error('Failed to get source material detail') throw new Error('Failed to get medicine method detail')
} }
} }
@@ -55,8 +55,8 @@ export async function postMedicineMethod(record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error posting source material:', error) console.error('Error posting medicine method:', error)
throw new Error('Failed to post source material') throw new Error('Failed to post medicine method')
} }
} }
@@ -68,8 +68,8 @@ export async function patchMedicineMethod(id: number | string, record: any) {
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error putting source material:', error) console.error('Error putting medicine method:', error)
throw new Error('Failed to put source material') throw new Error('Failed to put medicine method')
} }
} }
@@ -82,6 +82,6 @@ export async function removeMedicineMethod(id: number | string) {
return result return result
} catch (error) { } catch (error) {
console.error('Error deleting record:', error) console.error('Error deleting record:', error)
throw new Error('Failed to delete source material') throw new Error('Failed to delete medicine method')
} }
} }
+59 -5
View File
@@ -1,8 +1,10 @@
import { xfetch } from '~/composables/useXfetch' import { xfetch } from '~/composables/useXfetch'
export async function getSourceUoms(params: any = null) { const mainUrl = '/api/v1/uom'
export async function getUoms(params: any = null) {
try { try {
let url = '/api/v1/uom' let url = mainUrl
if (params && typeof params === 'object' && Object.keys(params).length > 0) { if (params && typeof params === 'object' && Object.keys(params).length > 0) {
const searchParams = new URLSearchParams() const searchParams = new URLSearchParams()
for (const key in params) { for (const key in params) {
@@ -13,13 +15,65 @@ export async function getSourceUoms(params: any = null) {
const queryString = searchParams.toString() const queryString = searchParams.toString()
if (queryString) url += `?${queryString}` if (queryString) url += `?${queryString}`
} }
const resp = await xfetch(url, 'GET') const resp = await xfetch(mainUrl, 'GET')
const result: any = {} const result: any = {}
result.success = resp.success result.success = resp.success
result.body = (resp.body as Record<string, any>) || {} result.body = (resp.body as Record<string, any>) || {}
return result return result
} catch (error) { } catch (error) {
console.error('Error fetching source uoms:', error) console.error('Error fetching uoms:', error)
throw new Error('Failed to fetch source uoms') throw new Error('Failed to fetch uoms')
} }
} }
export async function getUomDetail(id: number | string) {
try {
const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error fetching uom detail:', error)
throw new Error('Failed to get uom detail')
}
}
export async function postUom(record: any) {
try {
const resp = await xfetch(mainUrl, 'POST', record)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error posting uom:', error)
throw new Error('Failed to post uom')
}
}
export async function patchUom(id: number | string, record: any) {
try {
const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error putting uom:', error)
throw new Error('Failed to put uom')
}
}
export async function removeUom(id: number | string) {
try {
const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error deleting record:', error)
throw new Error('Failed to delete uom')
}
}
+16 -5
View File
@@ -287,11 +287,6 @@
} }
] ]
}, },
{
"title": "Item & Item Price",
"icon": "i-lucide-shopping-basket",
"link": "/item-src/item"
},
{ {
"title": "Organisasi", "title": "Organisasi",
"icon": "i-lucide-network", "icon": "i-lucide-network",
@@ -322,6 +317,22 @@
"link": "/org-src/subspecialist" "link": "/org-src/subspecialist"
} }
] ]
},
{
"title": "Umum",
"icon": "i-lucide-airplay",
"children": [
{
"title": "Item & Pricing",
"icon": "i-lucide-airplay",
"link": "/common/item"
},
{
"title": "Uom",
"icon": "i-lucide-airplay",
"link": "/common/uom"
}
]
} }
] ]
} }