Merge pull request #176 from dikstub-rssa/feat/device-order
Feat/device order
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Pubs
|
||||||
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||||
|
import * as CB from '~/components/pub/my-ui/combobox'
|
||||||
|
import Nav from '~/components/pub/my-ui/nav-footer/cl-sa.vue'
|
||||||
|
|
||||||
|
// This scope
|
||||||
|
import type { DeviceOrderItem } from '~/models/device-order-item';
|
||||||
|
import type { Device } from '~/models/device';
|
||||||
|
|
||||||
|
// Props
|
||||||
|
const props = defineProps<{
|
||||||
|
data: DeviceOrderItem
|
||||||
|
devices: Device[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// Refs
|
||||||
|
const { devices } = toRefs(props)
|
||||||
|
const deviceItems = ref<CB.Item[]>([])
|
||||||
|
|
||||||
|
// Nav actions
|
||||||
|
type ClickType = 'close' | 'save'
|
||||||
|
|
||||||
|
// Emits
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: [],
|
||||||
|
save: [data: DeviceOrderItem],
|
||||||
|
'update:searchText': [value: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// Reactivities
|
||||||
|
watch(devices, (data) => {
|
||||||
|
deviceItems.value = CB.objectsToItems(data, 'code', 'name')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
function searchDeviceText(value: string) {
|
||||||
|
emit('update:searchText', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function navClick(type: ClickType) {
|
||||||
|
if (type === 'close') {
|
||||||
|
emit('close')
|
||||||
|
} else if (type === 'save') {
|
||||||
|
emit('save', props.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<DE.Block :colCount="4" :cellFlex="false">
|
||||||
|
<DE.Cell :colSpan="4">
|
||||||
|
<DE.Label>Nama</DE.Label>
|
||||||
|
<DE.Field>
|
||||||
|
<CB.Combobox
|
||||||
|
v-model="data.device_code"
|
||||||
|
:items="deviceItems"
|
||||||
|
@update:searchText="searchDeviceText"
|
||||||
|
/>
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>Jumlah</DE.Label>
|
||||||
|
<DE.Field>
|
||||||
|
<Input v-model="data.quantity" type="number" />
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
</DE.Block>
|
||||||
|
<Separator class="my-5" />
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<Nav @click="navClick" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,36 +1,35 @@
|
|||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import type { Config } from '~/components/pub/my-ui/data-table'
|
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
|
||||||
|
|
||||||
|
|
||||||
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
||||||
|
|
||||||
export const config: Config = {
|
export const config: Config = {
|
||||||
cols: [{}, {}, { width: 50 }],
|
cols: [{}, { width: 200 }, { width: 100 }],
|
||||||
headers: [[{ label: 'Nama' }, { label: 'Jumlah' }, { label: '' }]],
|
headers: [[{ label: 'Nama' }, { label: 'Jumlah' }, { label: '' }]],
|
||||||
keys: ['name', 'count', 'action'],
|
keys: ['device.name', 'quantity', 'action'],
|
||||||
delKeyNames: [
|
delKeyNames: [
|
||||||
{ key: 'name', label: 'Nama' },
|
{ key: 'name', label: 'Nama' },
|
||||||
{ key: 'count', label: 'Jumlah' },
|
{ key: 'count', label: 'Jumlah' },
|
||||||
],
|
],
|
||||||
skeletonSize: 10
|
skeletonSize: 10,
|
||||||
// funcParsed: {
|
// funcParsed: {
|
||||||
// parent: (rec: unknown): unknown => {
|
// parent: (rec: unknown): unknown => {
|
||||||
// const recX = rec as SmallDetailDto
|
// const recX = rec as SmallDetailDto
|
||||||
// return recX.parent?.name || '-'
|
// return recX.parent?.name || '-'
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// funcComponent: {
|
components: {
|
||||||
// action(rec: object, idx: any) {
|
action(rec, idx) {
|
||||||
// const res: RecComponent = {
|
const res: RecComponent = {
|
||||||
// idx,
|
idx,
|
||||||
// rec: rec as object,
|
rec: rec as object,
|
||||||
// component: action,
|
component: action,
|
||||||
// props: {
|
props: {
|
||||||
// size: 'sm',
|
size: 'sm',
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// return res
|
return res
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import DataTable from '~/components/pub/my-ui/data-table/data-table.vue'
|
import DataTable from '~/components/pub/my-ui/data-table/data-table.vue'
|
||||||
import { config } from './list-entry.config'
|
import { config } from './list-entry.config'
|
||||||
|
import type { DeviceOrderItem } from '~/models/device-order-item';
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
data: DeviceOrderItem[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
add: []
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DataTable v-bind="config" :rows="[]" class="border mb-3 2xl:mb-4" />
|
<DataTable v-bind="config" :rows="data" class="border mb-3 2xl:mb-4" />
|
||||||
<div>
|
<div>
|
||||||
<Button>
|
<Button @click="emit('add')">
|
||||||
Tambah
|
<Icon name="i-lucide-plus" />
|
||||||
|
Tambah Item
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { DeviceOrder } from '~/models/device-order'
|
||||||
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
data: DeviceOrder | null | undefined
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<DE.Block mode="preview" label-size="small" class="!mb-0">
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>Tgl. Order</DE.Label>
|
||||||
|
<DE.Colon />
|
||||||
|
<DE.Field>
|
||||||
|
{{ data?.createdAt?.substring(0, 10) }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>DPJP</DE.Label>
|
||||||
|
<DE.Colon />
|
||||||
|
<DE.Field>
|
||||||
|
{{ data?.doctor?.employee?.person?.name }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
</DE.Block>
|
||||||
|
</template>
|
||||||
@@ -1,6 +1,25 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||||
|
import type { DeviceOrder } from '~/models/device-order';
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
data: DeviceOrder
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
Test
|
<DE.Block :col-count="2" mode="preview">
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>Tanggal</DE.Label>
|
||||||
|
<DE.Field>
|
||||||
|
{{ data?.createdAt?.substring(0, 10) }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>DPJP</DE.Label>
|
||||||
|
<DE.Field>
|
||||||
|
{{ data?.doctor?.employee?.person?.name }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
</DE.Block>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import type { Config } from '~/components/pub/my-ui/data-table'
|
import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
|
||||||
import type { DeviceOrder } from '~/models/device-order'
|
import type { DeviceOrder } from '~/models/device-order'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import type { DeviceOrderItem } from '~/models/device-order-item'
|
||||||
|
|
||||||
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-dsd.vue'))
|
||||||
|
|
||||||
export const config: Config = {
|
export const config: Config = {
|
||||||
cols: [{ width: 120 }, { }, { }, { width: 50 }],
|
cols: [{ width: 120 }, { }, { }, { }, { width: 50 }],
|
||||||
headers: [[{ label: 'Tanggal' }, { label: 'DPJP' }, { label: 'Alat Kesehatan' }, { label: '' }]],
|
headers: [[
|
||||||
keys: ['createdAt', 'encounter.doctor.person.name', 'items', 'action'],
|
{ label: 'Tanggal' },
|
||||||
|
{ label: 'DPJP' },
|
||||||
|
{ label: 'Alat Kesehatan' },
|
||||||
|
{ label: 'Status' },
|
||||||
|
{ label: '' }]],
|
||||||
|
keys: ['createdAt', 'doctor.employee.person.name', 'items', 'status_code', 'action'],
|
||||||
delKeyNames: [
|
delKeyNames: [
|
||||||
{ key: 'code', label: 'Kode' },
|
{ key: 'code', label: 'Kode' },
|
||||||
{ key: 'name', label: 'Nama' },
|
{ key: 'name', label: 'Nama' },
|
||||||
@@ -16,27 +21,45 @@ export const config: Config = {
|
|||||||
htmls: {
|
htmls: {
|
||||||
items: (rec: unknown): unknown => {
|
items: (rec: unknown): unknown => {
|
||||||
const recX = rec as DeviceOrder
|
const recX = rec as DeviceOrder
|
||||||
return recX.items?.length || 0
|
if (recX.items?.length > 0) {
|
||||||
|
let output = '<table><tbody>'
|
||||||
|
recX.items.forEach((item: DeviceOrderItem) => {
|
||||||
|
output += '' +
|
||||||
|
'<tr>'+
|
||||||
|
`<td class="pe-10">${item.device?.name}</td>` +
|
||||||
|
'<td class="w-4">:</td>' +
|
||||||
|
`<td class="w-10">${item.quantity}</td>` +
|
||||||
|
'</tr>'
|
||||||
|
})
|
||||||
|
output += '</tbody></table>'
|
||||||
|
return output
|
||||||
|
} else {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parses: {
|
||||||
|
createdAt: (rec: unknown): unknown => {
|
||||||
|
const recX = rec as DeviceOrder
|
||||||
|
return recX.createdAt ? new Date(recX.createdAt).toLocaleDateString() : '-'
|
||||||
|
},
|
||||||
|
// parent: (rec: unknown): unknown => {
|
||||||
|
// const recX = rec as SmallDetailDto
|
||||||
|
// return recX.parent?.name || '-'
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
action(rec, idx) {
|
||||||
|
const res: RecComponent = {
|
||||||
|
idx,
|
||||||
|
rec: rec as object,
|
||||||
|
component: action,
|
||||||
|
props: {
|
||||||
|
size: 'sm',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// 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
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ import type { PaginationMeta } from '~/components/pub/my-ui/pagination/paginatio
|
|||||||
// Configs
|
// Configs
|
||||||
import { config } from './list.config'
|
import { config } from './list.config'
|
||||||
|
|
||||||
interface Props {
|
defineProps<{
|
||||||
data: any[]
|
data: any[]
|
||||||
paginationMeta: PaginationMeta
|
paginationMeta: PaginationMeta
|
||||||
}
|
}>()
|
||||||
|
|
||||||
defineProps<Props>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
pageChange: [page: number]
|
pageChange: [page: number]
|
||||||
@@ -28,7 +26,7 @@ function handlePageChange(page: number) {
|
|||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<PubMyUiDataTable
|
<PubMyUiDataTable
|
||||||
v-bind="config"
|
v-bind="config"
|
||||||
:rows="[]"
|
:rows="data"
|
||||||
/>
|
/>
|
||||||
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
<PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,24 +1,177 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Nav from '~/components/pub/my-ui/nav-footer/ba-su.vue'
|
// Composables
|
||||||
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
|
||||||
|
|
||||||
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
|
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
|
||||||
|
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
|
|
||||||
|
// Pub components
|
||||||
|
import Nav from '~/components/pub/my-ui/nav-footer/ba-de-su.vue'
|
||||||
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||||
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
||||||
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||||
|
|
||||||
|
// Refs / src
|
||||||
|
import { type Device } from '~/models/device'
|
||||||
|
import { getList as getDeviceList } from '~/services/device.service'
|
||||||
|
|
||||||
|
// Device order things
|
||||||
|
import { getDetail, remove, submit } from '~/services/device-order.service'
|
||||||
|
import EntryForm from '~/components/app/device-order/entry-form.vue'
|
||||||
|
|
||||||
|
// Items
|
||||||
|
import {
|
||||||
|
getList as getItemList,
|
||||||
|
create as createItem,
|
||||||
|
update as updateItem,
|
||||||
|
} from '~/services/device-order-item.service'
|
||||||
|
import {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
handleActionRemove,
|
||||||
|
} from '~/handlers/device-order-item.handler'
|
||||||
|
import { genDeviceOrderItem, type DeviceOrderItem } from '~/models/device-order-item'
|
||||||
import ItemListEntry from '~/components/app/device-order-item/list-entry.vue'
|
import ItemListEntry from '~/components/app/device-order-item/list-entry.vue'
|
||||||
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
|
import ItemEntry from '~/components/app/device-order-item/entry-form.vue'
|
||||||
|
|
||||||
const { backToList } = useQueryCRUDMode()
|
|
||||||
|
|
||||||
|
// Header
|
||||||
const headerPrep: HeaderPrep = {
|
const headerPrep: HeaderPrep = {
|
||||||
title: 'Tambah Order Alkes',
|
title: 'Tambah Order Alkes',
|
||||||
icon: 'i-lucide-box',
|
icon: 'i-lucide-box',
|
||||||
}
|
}
|
||||||
|
|
||||||
function navClick(type: 'cancel' | 'submit') {
|
// Device order things
|
||||||
if (type === 'cancel') {
|
const { getQueryParam } = useQueryParam()
|
||||||
backToList()
|
const rawId = getQueryParam('id')
|
||||||
}
|
const id = typeof rawId === 'string' ? parseInt(rawId) : 0
|
||||||
|
const dataRes = await getDetail(id, { includes: 'doctor,doctor-employee,doctor-employee-person' })
|
||||||
|
const data = ref(dataRes.body?.data || null)
|
||||||
|
const devices = ref<Device[]>([])
|
||||||
|
|
||||||
|
const isSubmitConfirmationOpen = ref(false)
|
||||||
|
const isDeleteConfirmationOpen = ref(false)
|
||||||
|
|
||||||
|
// Items
|
||||||
|
const {
|
||||||
|
data: items,
|
||||||
|
isLoading,
|
||||||
|
fetchData: getDeviceOrderItems,
|
||||||
|
} = usePaginatedList({
|
||||||
|
fetchFn: async (params: any) => {
|
||||||
|
const result = await getItemList({
|
||||||
|
'device-order-id': id,
|
||||||
|
includes: 'device',
|
||||||
|
search: params.search,
|
||||||
|
sort: 'createdAt:asc',
|
||||||
|
'page-number': params['page-number'] || 0,
|
||||||
|
'page-size': params['page-size'] || 10,
|
||||||
|
})
|
||||||
|
return { success: result.success || false, body: result.body || {} }
|
||||||
|
},
|
||||||
|
entityName: 'division',
|
||||||
|
})
|
||||||
|
const selectedItem = ref<DeviceOrderItem>(genDeviceOrderItem())
|
||||||
|
const isItemDetailDialogOpen = ref(false)
|
||||||
|
const isItemEntryDialogOpen = ref(false)
|
||||||
|
const isItemDelConfirmDialogOpen = ref(false)
|
||||||
|
|
||||||
|
selectedItem.value.deviceOrder_id = id
|
||||||
|
|
||||||
|
// Last navs
|
||||||
|
const { backToList } = useQueryCRUDMode()
|
||||||
|
|
||||||
|
// Reactivities
|
||||||
|
provide('rec_id', recId)
|
||||||
|
provide('rec_action', recAction)
|
||||||
|
provide('rec_item', recItem)
|
||||||
|
provide('table_data_loader', isLoading)
|
||||||
|
|
||||||
|
watch([recId, recAction], () => {
|
||||||
|
let item: DeviceOrderItem | null
|
||||||
|
switch (recAction.value) {
|
||||||
|
case ActionEvents.showDetail:
|
||||||
|
item = pickItem()
|
||||||
|
if (item) {
|
||||||
|
isItemDetailDialogOpen.value = true
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case ActionEvents.showEdit:
|
||||||
|
item = pickItem()
|
||||||
|
if (item) {
|
||||||
|
isItemEntryDialogOpen.value = true
|
||||||
|
getDevices('', item.device_code)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case ActionEvents.showConfirmDelete:
|
||||||
|
isItemDelConfirmDialogOpen.value = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await getDeviceOrderItems()
|
||||||
|
})
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
function navClick(type: 'back' | 'delete' | 'draft' | 'submit') {
|
||||||
|
if (type === 'back') {
|
||||||
|
backToList()
|
||||||
|
} else if (type === 'delete') {
|
||||||
|
isDeleteConfirmationOpen.value = true
|
||||||
|
} else if (type === 'submit') {
|
||||||
|
isSubmitConfirmationOpen.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeOrder() {
|
||||||
|
const res = await remove(id)
|
||||||
|
if (res.success) {
|
||||||
|
backToList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitOrder() {
|
||||||
|
const res = await submit(id)
|
||||||
|
if (res.success) {
|
||||||
|
backToList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem() {
|
||||||
|
isItemEntryDialogOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getDevices(value: string, code?: string) {
|
||||||
|
const res = await getDeviceList({ 'search': value, 'code': code })
|
||||||
|
if (res.success) {
|
||||||
|
devices.value = res.body.data
|
||||||
|
} else {
|
||||||
|
devices.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickItem(): DeviceOrderItem | null {
|
||||||
|
const item = items.value.find(item => item.id === recId.value)
|
||||||
|
selectedItem.value = item
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveItem() {
|
||||||
|
let res: any;
|
||||||
|
if(!selectedItem.value.id) {
|
||||||
|
res = await createItem(selectedItem.value)
|
||||||
|
} else {
|
||||||
|
res = await updateItem(selectedItem.value.id, selectedItem.value)
|
||||||
|
}
|
||||||
|
if (res.success) {
|
||||||
|
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
|
||||||
|
getDeviceOrderItems()
|
||||||
|
isItemEntryDialogOpen.value = false
|
||||||
|
selectedItem.value = genDeviceOrderItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -28,10 +181,74 @@ const headerPrep: HeaderPrep = {
|
|||||||
class="mb-4 xl:mb-5"
|
class="mb-4 xl:mb-5"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ItemListEntry />
|
<EntryForm :data="data" @add="addItem" />
|
||||||
|
|
||||||
|
<ItemListEntry :data="items" @add="addItem" />
|
||||||
|
|
||||||
<Separator class="my-5" />
|
<Separator class="my-5" />
|
||||||
|
|
||||||
<div class="w-full flex justify-center">
|
<div class="w-full flex justify-center">
|
||||||
<Nav @click="navClick" />
|
<Nav @click="navClick" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Confirm delete -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isDeleteConfirmationOpen"
|
||||||
|
action="delete"
|
||||||
|
:record="data"
|
||||||
|
@confirm="removeOrder()"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Confirm submit -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isSubmitConfirmationOpen"
|
||||||
|
customTitle="Ajukan Order"
|
||||||
|
customMessage="Akan dilakukan pengajuan order alat kesehatan"
|
||||||
|
customConfirmText="Ajukan"
|
||||||
|
:record="data"
|
||||||
|
@confirm="submitOrder"
|
||||||
|
@cancel=""
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Item entry -->
|
||||||
|
<Dialog
|
||||||
|
v-model:open="isItemEntryDialogOpen"
|
||||||
|
title="Item Order"
|
||||||
|
size="lg"
|
||||||
|
prevent-outside
|
||||||
|
>
|
||||||
|
<ItemEntry
|
||||||
|
:data="selectedItem"
|
||||||
|
:devices="devices"
|
||||||
|
@close="isItemEntryDialogOpen = false"
|
||||||
|
@save="saveItem"
|
||||||
|
@update:searchText="getDevices"
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isItemDelConfirmDialogOpen"
|
||||||
|
action="delete"
|
||||||
|
size="md"
|
||||||
|
:record="recItem"
|
||||||
|
@confirm="() => handleActionRemove(recId, getDeviceOrderItems, toast)"
|
||||||
|
@cancel=""
|
||||||
|
>
|
||||||
|
<DE.Block mode="preview" label-size="small">
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>Nama</DE.Label>
|
||||||
|
<DE.Colon />
|
||||||
|
<DE.Field>
|
||||||
|
{{ recItem.device.name }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
<DE.Cell>
|
||||||
|
<DE.Label>Dosis</DE.Label>
|
||||||
|
<DE.Colon />
|
||||||
|
<DE.Field>
|
||||||
|
{{ recItem.quantity }}
|
||||||
|
</DE.Field>
|
||||||
|
</DE.Cell>
|
||||||
|
</DE.Block>
|
||||||
|
</RecordConfirmation>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,69 +1,39 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// Helpers
|
||||||
|
import { usePaginatedList } from '~/composables/usePaginatedList'
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
|
||||||
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
||||||
import List from '~/components/app/device-order/list.vue'
|
import List from '~/components/app/device-order/list.vue'
|
||||||
|
|
||||||
// Helpers
|
|
||||||
import { usePaginatedList } from '~/composables/usePaginatedList'
|
|
||||||
import { toast } from '~/components/pub/ui/toast'
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
// import { useQueryMode } from '~/composables/useQueryMode'
|
|
||||||
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/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
|
// Device order things
|
||||||
import {
|
import {
|
||||||
recId,
|
recId,
|
||||||
recAction,
|
recAction,
|
||||||
recItem,
|
recItem,
|
||||||
isReadonly,
|
isReadonly,
|
||||||
isProcessing,
|
|
||||||
isFormEntryDialogOpen,
|
|
||||||
isRecordConfirmationOpen,
|
|
||||||
onResetState,
|
|
||||||
handleActionSave,
|
handleActionSave,
|
||||||
handleActionEdit,
|
|
||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
|
||||||
} from '~/handlers/device-order.handler'
|
} from '~/handlers/device-order.handler'
|
||||||
|
import { getList, submit } from '~/services/device-order.service'
|
||||||
|
import type { ToastFn } from '~/handlers/_handler'
|
||||||
|
import { type DeviceOrder } from "~/models/device-order";
|
||||||
|
import ConfirmationInfo from '~/components/app/device-order/confirmation-info.vue'
|
||||||
|
|
||||||
// Services
|
// Props
|
||||||
import { getList } from '~/services/device-order.service'
|
const props = defineProps<{
|
||||||
|
encounter_id: number
|
||||||
|
}>()
|
||||||
|
|
||||||
const route = useRoute()
|
const encounter_id = props.encounter_id
|
||||||
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',
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Header
|
||||||
|
const voidFn = () => {}
|
||||||
const headerPrep: HeaderPrep = {
|
const headerPrep: HeaderPrep = {
|
||||||
title: 'Order Alkes',
|
title: 'Order Alkes',
|
||||||
icon: 'i-lucide-box',
|
icon: 'i-lucide-box',
|
||||||
@@ -85,21 +55,88 @@ const headerPrep: HeaderPrep = {
|
|||||||
recItem.value = null
|
recItem.value = null
|
||||||
recId.value = 0
|
recId.value = 0
|
||||||
isReadonly.value = false
|
isReadonly.value = false
|
||||||
// await handleActionSave(recItem, getMyList, () => {}, () => {})
|
const saveResp = await handleActionSave({ encounter_id }, voidFn, voidFn, voidFn)
|
||||||
goToEntry()
|
if (saveResp.success) {
|
||||||
|
setQueryParams({
|
||||||
|
'mode': 'entry',
|
||||||
|
'id': saveResp.body?.data?.id.toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
const {
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
paginationMeta,
|
||||||
|
searchInput,
|
||||||
|
handlePageChange,
|
||||||
|
handleSearch,
|
||||||
|
fetchData: getMyList,
|
||||||
|
} = usePaginatedList({
|
||||||
|
fetchFn: async (params: any) => {
|
||||||
|
const result = await getList({
|
||||||
|
'encounter-id': encounter_id,
|
||||||
|
search: params.search,
|
||||||
|
includes: 'doctor,doctor-employee,doctor-employee-person,items,items-device',
|
||||||
|
page: params.page,
|
||||||
|
'page-number': params['page-number'] || 0,
|
||||||
|
'page-size': params['page-size'] || 10,
|
||||||
|
})
|
||||||
|
return { success: result.success || false, body: result.body || {} }
|
||||||
|
},
|
||||||
|
entityName: 'device-order',
|
||||||
|
})
|
||||||
|
|
||||||
|
// Selected item
|
||||||
|
const selectedItem = ref<DeviceOrder | null>()
|
||||||
|
const isSubmitConfirmationOpen = ref(false)
|
||||||
|
const isDeleteConfirmationOpen = ref(false)
|
||||||
|
const { setQueryParams } = useQueryParam()
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
// Watch for row actions when recId or recAction changes
|
watch([recId, recAction], () => {
|
||||||
onMounted(async () => {
|
let item: DeviceOrder | null
|
||||||
await getMyList()
|
switch (recAction.value) {
|
||||||
|
case ActionEvents.showDetail:
|
||||||
|
setQueryParams({
|
||||||
|
'mode': 'entry',
|
||||||
|
'id': recId.value.toString()
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case ActionEvents.showConfirmSubmit:
|
||||||
|
selectedItem.value = pickItem()
|
||||||
|
isSubmitConfirmationOpen.value = true
|
||||||
|
break
|
||||||
|
case ActionEvents.showConfirmDelete:
|
||||||
|
selectedItem.value = pickItem()
|
||||||
|
isDeleteConfirmationOpen.value = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
recAction.value = '';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function handleActionSubmit(id: number, refresh: () => void, toast: ToastFn) {
|
||||||
|
const result = await submit(id)
|
||||||
|
if (result.success) {
|
||||||
|
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
|
||||||
|
setTimeout(refresh, 300)
|
||||||
|
} else {
|
||||||
|
toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickItem(): DeviceOrder | null {
|
||||||
|
const item = data.value.find(item => item.id === recId.value)
|
||||||
|
selectedItem.value = item
|
||||||
|
return item
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -108,38 +145,39 @@ onMounted(async () => {
|
|||||||
:prep="headerPrep"
|
:prep="headerPrep"
|
||||||
:ref-search-nav="headerPrep.refSearchNav"
|
:ref-search-nav="headerPrep.refSearchNav"
|
||||||
@search="handleSearch"
|
@search="handleSearch"
|
||||||
class="mb-4 xl:mb-5"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<List
|
<List
|
||||||
|
v-if="!isLoading.dataListLoading"
|
||||||
:data="data"
|
:data="data"
|
||||||
:pagination-meta="paginationMeta"
|
:pagination-meta="paginationMeta"
|
||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
/>
|
/>
|
||||||
|
<!--
|
||||||
|
@cancel="cancel"
|
||||||
|
@edit="edit"
|
||||||
|
@submit="submit"
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Record Confirmation Modal -->
|
<!-- Submit Record Confirmation Modal -->
|
||||||
<RecordConfirmation
|
<RecordConfirmation
|
||||||
v-model:open="isRecordConfirmationOpen"
|
v-model:open="isSubmitConfirmationOpen"
|
||||||
|
customTitle="Ajukan Order"
|
||||||
|
customMessage="Akan dilakukan pengajuan order alat kesehatan"
|
||||||
|
customConfirmText="Ajukan"
|
||||||
|
:record="recItem"
|
||||||
|
@confirm="() => handleActionSubmit(recId, getMyList, toast)"
|
||||||
|
>
|
||||||
|
<ConfirmationInfo :data="selectedItem" />
|
||||||
|
</RecordConfirmation>
|
||||||
|
|
||||||
|
<!-- Del Record Confirmation Modal -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isDeleteConfirmationOpen"
|
||||||
action="delete"
|
action="delete"
|
||||||
:record="recItem"
|
:record="recItem"
|
||||||
@confirm="() => handleActionRemove(recId, getMyList, toast)"
|
@confirm="() => handleActionRemove(recId, getMyList, toast)"
|
||||||
@cancel=""
|
|
||||||
>
|
>
|
||||||
<template #default="{ record }">
|
<ConfirmationInfo :data="selectedItem" />
|
||||||
<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>
|
</RecordConfirmation>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
import List from './list.vue'
|
import List from './list.vue'
|
||||||
import Entry from './entry.vue'
|
import Entry from './entry.vue'
|
||||||
|
|
||||||
const { mode } = useQueryMode()
|
defineProps<{
|
||||||
|
encounter_id: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { mode } = useQueryCRUDMode()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<List v-if="mode === 'list'" />
|
<List v-if="mode === 'list'" :encounter_id="encounter_id" />
|
||||||
<Entry v-else />
|
<Entry v-else :encounter_id="encounter_id" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import Status from '~/components/content/encounter/status.vue'
|
|||||||
import AssesmentFunctionList from '~/components/content/soapi/entry.vue'
|
import AssesmentFunctionList from '~/components/content/soapi/entry.vue'
|
||||||
import EarlyMedicalAssesmentList from '~/components/content/soapi/entry.vue'
|
import EarlyMedicalAssesmentList from '~/components/content/soapi/entry.vue'
|
||||||
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
|
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
|
||||||
|
import DeviceOrder from '~/components/content/device-order/main.vue'
|
||||||
import Prescription from '~/components/content/prescription/main.vue'
|
import Prescription from '~/components/content/prescription/main.vue'
|
||||||
import CpLabOrder from '~/components/content/cp-lab-order/main.vue'
|
import CpLabOrder from '~/components/content/cp-lab-order/main.vue'
|
||||||
import Radiology from '~/components/content/radiology-order/main.vue'
|
import Radiology from '~/components/content/radiology-order/main.vue'
|
||||||
@@ -75,7 +76,7 @@ const tabs: TabItem[] = [
|
|||||||
{ value: 'consent', label: 'General Consent', component: GeneralConsentList, props: { encounter: data } },
|
{ value: 'consent', label: 'General Consent', component: GeneralConsentList, props: { encounter: data } },
|
||||||
{ value: 'patient-note', label: 'CPRJ' },
|
{ value: 'patient-note', label: 'CPRJ' },
|
||||||
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.value.id } },
|
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.value.id } },
|
||||||
{ value: 'device', label: 'Order Alkes' },
|
{ value: 'device-order', label: 'Order Alkes', component: DeviceOrder, props: { encounter_id: data.value.id } },
|
||||||
{ value: 'mcu-radiology', label: 'Order Radiologi', component: Radiology, props: { encounter_id: data.value.id } },
|
{ value: 'mcu-radiology', label: 'Order Radiologi', component: Radiology, props: { encounter_id: data.value.id } },
|
||||||
{ value: 'mcu-lab-cp', label: 'Order Lab PK', component: CpLabOrder, props: { encounter_id: data.value.id } },
|
{ value: 'mcu-lab-cp', label: 'Order Lab PK', component: CpLabOrder, props: { encounter_id: data.value.id } },
|
||||||
{ value: 'mcu-lab-micro', label: 'Order Lab Mikro' },
|
{ value: 'mcu-lab-micro', label: 'Order Lab Mikro' },
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
// Handlers
|
// Handlers
|
||||||
import { genCrudHandler } from '~/handlers/_handler'
|
import { genCrudHandler } from '~/handlers/_handler'
|
||||||
|
import type { DeviceOrder } from '~/models/device-order'
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { create, update, remove } from '~/services/device-order-item.service'
|
import { create, update, remove } from '~/services/device-order.service'
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
recId,
|
recId,
|
||||||
@@ -17,7 +18,7 @@ export const {
|
|||||||
handleActionEdit,
|
handleActionEdit,
|
||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
handleCancelForm,
|
||||||
} = genCrudHandler({
|
} = genCrudHandler<DeviceOrder>({
|
||||||
create,
|
create,
|
||||||
update,
|
update,
|
||||||
remove,
|
remove,
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
import { type Base, genBase } from "./_base"
|
import { type Base, genBase } from "./_base"
|
||||||
|
import { genDevice, type Device } from "./device"
|
||||||
|
|
||||||
export interface DeviceOrderItem extends Base {
|
export interface DeviceOrderItem extends Base {
|
||||||
deviceOrder_id: number
|
deviceOrder_id: number
|
||||||
device_id: number
|
device_code: string
|
||||||
count: number
|
device: Device
|
||||||
|
quantity: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genDeviceOrderItem(): DeviceOrderItem {
|
export function genDeviceOrderItem(): DeviceOrderItem {
|
||||||
return {
|
return {
|
||||||
...genBase(),
|
...genBase(),
|
||||||
deviceOrder_id: 0,
|
deviceOrder_id: 0,
|
||||||
device_id: 0,
|
device_code: '',
|
||||||
count: 0,
|
device: genDevice(),
|
||||||
|
quantity: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
import { type Base, genBase } from "./_base"
|
import { type Base, genBase } from "./_base"
|
||||||
|
import type { DeviceOrderItem } from "./device-order-item"
|
||||||
|
import { genDoctor, type Doctor } from "./doctor"
|
||||||
|
|
||||||
export interface DeviceOrder extends Base {
|
export interface DeviceOrder extends Base {
|
||||||
encounter_id: number
|
encounter_id: number
|
||||||
doctor_id: number
|
doctor_code: number
|
||||||
|
doctor: Doctor
|
||||||
status_code?: string
|
status_code?: string
|
||||||
|
items: DeviceOrderItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genDeviceOrder(): DeviceOrder {
|
export function genDeviceOrder(): DeviceOrder {
|
||||||
return {
|
return {
|
||||||
...genBase(),
|
...genBase(),
|
||||||
encounter_id: 0,
|
encounter_id: 0,
|
||||||
doctor_id: 0,
|
doctor_code: 0,
|
||||||
|
doctor: genDoctor(),
|
||||||
|
items: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const path = '/api/v1/device-order-item'
|
|||||||
const name = 'device-order-item'
|
const name = 'device-order-item'
|
||||||
|
|
||||||
export function create(data: any) {
|
export function create(data: any) {
|
||||||
console.log('service create', data)
|
|
||||||
return base.create(path, data, name)
|
return base.create(path, data, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ export function getList(params: any = null) {
|
|||||||
return base.getList(path, params, name)
|
return base.getList(path, params, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDetail(id: number | string) {
|
export function getDetail(id: number | string, params?: any) {
|
||||||
return base.getDetail(path, id, name)
|
return base.getDetail(path, id, name, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update(id: number | string, data: any) {
|
export function update(id: number | string, data: any) {
|
||||||
@@ -24,3 +24,16 @@ export function update(id: number | string, data: any) {
|
|||||||
export function remove(id: number | string) {
|
export function remove(id: number | string) {
|
||||||
return base.remove(path, id, name)
|
return base.remove(path, id, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function submit(id: number) {
|
||||||
|
try {
|
||||||
|
const resp = await xfetch(`${path}/${id}/submit`, 'PATCH')
|
||||||
|
const result: any = {}
|
||||||
|
result.success = resp.success
|
||||||
|
result.body = (resp.body as Record<string, any>) || {}
|
||||||
|
return result
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error putting ${name}:`, error)
|
||||||
|
throw new Error(`Failed to put ${name}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user