Merge branch 'dev' into feat/encounter-status-107
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
import { defineAsyncComponent } from 'vue'
|
||||||
|
import type { Config } from '~/components/pub/my-ui/data-table'
|
||||||
|
|
||||||
|
|
||||||
|
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
||||||
|
|
||||||
|
export const config: Config = {
|
||||||
|
cols: [{}, {}, { width: 50 }],
|
||||||
|
headers: [[{ label: 'Nama' }, { label: 'Jumlah' }, { label: '' }]],
|
||||||
|
keys: ['name', 'count', 'action'],
|
||||||
|
delKeyNames: [
|
||||||
|
{ key: 'name', label: 'Nama' },
|
||||||
|
{ key: 'count', label: 'Jumlah' },
|
||||||
|
],
|
||||||
|
skeletonSize: 10
|
||||||
|
// funcParsed: {
|
||||||
|
// parent: (rec: unknown): unknown => {
|
||||||
|
// const recX = rec as SmallDetailDto
|
||||||
|
// return recX.parent?.name || '-'
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// funcComponent: {
|
||||||
|
// action(rec: object, idx: any) {
|
||||||
|
// const res: RecComponent = {
|
||||||
|
// idx,
|
||||||
|
// rec: rec as object,
|
||||||
|
// component: action,
|
||||||
|
// props: {
|
||||||
|
// size: 'sm',
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import DataTable from '~/components/pub/my-ui/data-table/data-table.vue'
|
||||||
|
import { config } from './list-entry.config'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<DataTable v-bind="config" :rows="[]" class="border mb-3 2xl:mb-4" />
|
||||||
|
<div>
|
||||||
|
<Button>
|
||||||
|
Tambah
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
Test
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import type { Config } from '~/components/pub/my-ui/data-table'
|
||||||
|
import type { DeviceOrder } from '~/models/device-order'
|
||||||
|
import { defineAsyncComponent } from 'vue'
|
||||||
|
|
||||||
|
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
||||||
|
|
||||||
|
export const config: Config = {
|
||||||
|
cols: [{ width: 120 }, { }, { }, { width: 50 }],
|
||||||
|
headers: [[{ label: 'Tanggal' }, { label: 'DPJP' }, { label: 'Alat Kesehatan' }, { label: '' }]],
|
||||||
|
keys: ['createdAt', 'encounter.doctor.person.name', 'items', 'action'],
|
||||||
|
delKeyNames: [
|
||||||
|
{ key: 'code', label: 'Kode' },
|
||||||
|
{ key: 'name', label: 'Nama' },
|
||||||
|
],
|
||||||
|
skeletonSize: 10,
|
||||||
|
htmls: {
|
||||||
|
items: (rec: unknown): unknown => {
|
||||||
|
const recX = rec as DeviceOrder
|
||||||
|
return recX.items?.length || 0
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// funcParsed: {
|
||||||
|
// parent: (rec: unknown): unknown => {
|
||||||
|
// const recX = rec as SmallDetailDto
|
||||||
|
// return recX.parent?.name || '-'
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// funcComponent: {
|
||||||
|
// action(rec: object, idx: any) {
|
||||||
|
// const res: RecComponent = {
|
||||||
|
// idx,
|
||||||
|
// rec: rec as object,
|
||||||
|
// component: action,
|
||||||
|
// props: {
|
||||||
|
// size: 'sm',
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Components
|
||||||
|
import PaginationView from '~/components/pub/my-ui/pagination/pagination-view.vue'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
|
||||||
|
|
||||||
|
// Configs
|
||||||
|
import { config } from './list.config'
|
||||||
|
|
||||||
|
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">
|
||||||
|
<PubMyUiDataTable
|
||||||
|
v-bind="config"
|
||||||
|
:rows="[]"
|
||||||
|
/>
|
||||||
|
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Nav from '~/components/pub/my-ui/nav-footer/ba-su.vue'
|
||||||
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
|
|
||||||
|
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
|
||||||
|
|
||||||
|
import ItemListEntry from '~/components/app/device-order-item/list-entry.vue'
|
||||||
|
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
|
|
||||||
|
const { backToList } = useQueryCRUDMode()
|
||||||
|
|
||||||
|
const headerPrep: HeaderPrep = {
|
||||||
|
title: 'Tambah Order Alkes',
|
||||||
|
icon: 'i-lucide-box',
|
||||||
|
}
|
||||||
|
|
||||||
|
function navClick(type: 'cancel' | 'submit') {
|
||||||
|
if (type === 'cancel') {
|
||||||
|
backToList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Header
|
||||||
|
:prep="headerPrep"
|
||||||
|
:ref-search-nav="headerPrep.refSearchNav"
|
||||||
|
class="mb-4 xl:mb-5"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ItemListEntry />
|
||||||
|
<Separator class="my-5" />
|
||||||
|
|
||||||
|
<div class="w-full flex justify-center">
|
||||||
|
<Nav @click="navClick" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Components
|
||||||
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||||
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
||||||
|
import List from '~/components/app/device-order/list.vue'
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
import { usePaginatedList } from '~/composables/usePaginatedList'
|
||||||
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
|
// import { useQueryMode } from '~/composables/useQueryMode'
|
||||||
|
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
|
import { type DeviceOrderFormData, DeviceOrderSchema } from '~/schemas/device-order.schema'
|
||||||
|
import type { DeviceOrder } from "~/models/device-order";
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
import {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
isReadonly,
|
||||||
|
isProcessing,
|
||||||
|
isFormEntryDialogOpen,
|
||||||
|
isRecordConfirmationOpen,
|
||||||
|
onResetState,
|
||||||
|
handleActionSave,
|
||||||
|
handleActionEdit,
|
||||||
|
handleActionRemove,
|
||||||
|
handleCancelForm,
|
||||||
|
} from '~/handlers/device-order.handler'
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { getList } from '~/services/device-order.service'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const title = ref('')
|
||||||
|
|
||||||
|
// const { mode, openForm, backToList } = useQueryMode()
|
||||||
|
const { mode, goToEntry, backToList } = useQueryCRUDMode()
|
||||||
|
const { recordId } = useQueryCRUDRecordId()
|
||||||
|
|
||||||
|
const {
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
paginationMeta,
|
||||||
|
searchInput,
|
||||||
|
handlePageChange,
|
||||||
|
handleSearch,
|
||||||
|
fetchData: getMyList,
|
||||||
|
} = usePaginatedList({
|
||||||
|
fetchFn: async (params: any) => {
|
||||||
|
const result = await getList({
|
||||||
|
search: params.search,
|
||||||
|
sort: 'createdAt:asc',
|
||||||
|
'page-number': params['page-number'] || 0,
|
||||||
|
'page-size': params['page-size'] || 10,
|
||||||
|
includes: 'parent,childrens',
|
||||||
|
})
|
||||||
|
return { success: result.success || false, body: result.body || {} }
|
||||||
|
},
|
||||||
|
entityName: 'device-order',
|
||||||
|
})
|
||||||
|
|
||||||
|
const headerPrep: HeaderPrep = {
|
||||||
|
title: 'Order Alkes',
|
||||||
|
icon: 'i-lucide-box',
|
||||||
|
refSearchNav: {
|
||||||
|
placeholder: 'Cari (min. 3 karakter)...',
|
||||||
|
minLength: 3,
|
||||||
|
debounceMs: 500,
|
||||||
|
showValidationFeedback: true,
|
||||||
|
onInput: (value: string) => {
|
||||||
|
searchInput.value = value
|
||||||
|
},
|
||||||
|
onClick: () => {},
|
||||||
|
onClear: () => {},
|
||||||
|
},
|
||||||
|
addNav: {
|
||||||
|
label: 'Tambah',
|
||||||
|
icon: 'i-lucide-plus',
|
||||||
|
onClick: async () => {
|
||||||
|
recItem.value = null
|
||||||
|
recId.value = 0
|
||||||
|
isReadonly.value = false
|
||||||
|
// await handleActionSave(recItem, getMyList, () => {}, () => {})
|
||||||
|
goToEntry()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
provide('rec_id', recId)
|
||||||
|
provide('rec_action', recAction)
|
||||||
|
provide('rec_item', recItem)
|
||||||
|
provide('table_data_loader', isLoading)
|
||||||
|
|
||||||
|
// Watch for row actions when recId or recAction changes
|
||||||
|
onMounted(async () => {
|
||||||
|
await getMyList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Header
|
||||||
|
v-model="searchInput"
|
||||||
|
:prep="headerPrep"
|
||||||
|
:ref-search-nav="headerPrep.refSearchNav"
|
||||||
|
@search="handleSearch"
|
||||||
|
class="mb-4 xl:mb-5"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<List
|
||||||
|
:data="data"
|
||||||
|
:pagination-meta="paginationMeta"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Record Confirmation Modal -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isRecordConfirmationOpen"
|
||||||
|
action="delete"
|
||||||
|
:record="recItem"
|
||||||
|
@confirm="() => handleActionRemove(recId, getMyList, 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>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
//
|
||||||
|
import List from './list.vue'
|
||||||
|
import Entry from './entry.vue'
|
||||||
|
|
||||||
|
const { mode } = useQueryMode()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<List v-if="mode === 'list'" />
|
||||||
|
<Entry v-else />
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Handlers
|
||||||
|
import { genCrudHandler } from '~/handlers/_handler'
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { create, update, remove } from '~/services/device-order-item.service'
|
||||||
|
|
||||||
|
export const {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
isReadonly,
|
||||||
|
isProcessing,
|
||||||
|
isFormEntryDialogOpen,
|
||||||
|
isRecordConfirmationOpen,
|
||||||
|
onResetState,
|
||||||
|
handleActionSave,
|
||||||
|
handleActionEdit,
|
||||||
|
handleActionRemove,
|
||||||
|
handleCancelForm,
|
||||||
|
} = genCrudHandler({
|
||||||
|
create,
|
||||||
|
update,
|
||||||
|
remove,
|
||||||
|
})
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Handlers
|
||||||
|
import { genCrudHandler } from '~/handlers/_handler'
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { create, update, remove } from '~/services/device-order-item.service'
|
||||||
|
|
||||||
|
export const {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
isReadonly,
|
||||||
|
isProcessing,
|
||||||
|
isFormEntryDialogOpen,
|
||||||
|
isRecordConfirmationOpen,
|
||||||
|
onResetState,
|
||||||
|
handleActionSave,
|
||||||
|
handleActionEdit,
|
||||||
|
handleActionRemove,
|
||||||
|
handleCancelForm,
|
||||||
|
} = genCrudHandler({
|
||||||
|
create,
|
||||||
|
update,
|
||||||
|
remove,
|
||||||
|
})
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
import type { DeviceOrder } from '~/models/device-order'
|
||||||
|
|
||||||
|
const DeviceOrderSchema = z.object({
|
||||||
|
encounter_id: z.number({ required_error: 'Kode harus diisi' }),
|
||||||
|
doctor_id: z.number({ required_error: 'Kode harus diisi' }),
|
||||||
|
})
|
||||||
|
|
||||||
|
type DeviceOrderFormData = z.infer<typeof DeviceOrderSchema> & Partial<DeviceOrder>
|
||||||
|
|
||||||
|
export { DeviceOrderSchema }
|
||||||
|
export type { DeviceOrderFormData }
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// Base
|
||||||
|
import * as base from './_crud-base'
|
||||||
|
|
||||||
|
const path = '/api/v1/device-order-item'
|
||||||
|
const name = 'device-order-item'
|
||||||
|
|
||||||
|
export function create(data: any) {
|
||||||
|
console.log('service create', data)
|
||||||
|
return base.create(path, data, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 update(id: number | string, data: any) {
|
||||||
|
return base.update(path, id, data, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove(id: number | string) {
|
||||||
|
return base.remove(path, id, name)
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// Base
|
||||||
|
import * as base from './_crud-base'
|
||||||
|
|
||||||
|
const path = '/api/v1/device-order'
|
||||||
|
const name = 'device-order'
|
||||||
|
|
||||||
|
export function create(data: any) {
|
||||||
|
console.log('service create', data)
|
||||||
|
return base.create(path, data, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 update(id: number | string, data: any) {
|
||||||
|
return base.update(path, id, data, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove(id: number | string) {
|
||||||
|
return base.remove(path, id, name)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user