feat(medicine-group): refactor + integrate
This commit is contained in:
@@ -36,22 +36,6 @@ import { getSourceUoms } from '~/services/uom.service'
|
||||
const uoms = ref<{ value: string; label: string }[]>([])
|
||||
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 {
|
||||
data,
|
||||
isLoading,
|
||||
@@ -103,17 +87,33 @@ provide('rec_action', recAction)
|
||||
provide('rec_item', recItem)
|
||||
provide('table_data_loader', isLoading)
|
||||
|
||||
const getCurrentToolsDetail = 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 }))
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for row actions
|
||||
watch([recId, recAction], () => {
|
||||
switch (recAction.value) {
|
||||
case ActionEvents.showDetail:
|
||||
getToolsDetail(recId.value)
|
||||
getCurrentToolsDetail(recId.value)
|
||||
title.value = 'Detail Peralatan'
|
||||
isReadonly.value = true
|
||||
isFormEntryDialogOpen.value = true
|
||||
break
|
||||
case ActionEvents.showEdit:
|
||||
getToolsDetail(recId.value)
|
||||
getCurrentToolsDetail(recId.value)
|
||||
title.value = 'Edit Peralatan'
|
||||
isReadonly.value = false
|
||||
isFormEntryDialogOpen.value = true
|
||||
|
||||
Reference in New Issue
Block a user