fix: change integrate material

This commit is contained in:
riefive
2025-09-24 16:37:03 +07:00
parent fcabbc25ff
commit 93a5abba36
4 changed files with 52 additions and 38 deletions
+22 -5
View File
@@ -21,6 +21,7 @@ import {
handleActionSave,
handleActionRemove,
handleCancelForm,
handleActionEdit,
} from '~/handlers/material.handler'
// Services
@@ -32,7 +33,8 @@ const uoms = ref<{ value: string; label: string }[]>([])
const getEquipmentDetail = async (id: number | string) => {
const result = await getSourceMaterialDetail(id)
if (result.success) {
recItem.value = result.data
const currentMaterial = result.body?.data || {}
recItem.value = currentMaterial
isFormEntryDialogOpen.value = true
}
}
@@ -40,7 +42,8 @@ const getEquipmentDetail = async (id: number | string) => {
const getUomList = async () => {
const result = await getSourceUoms()
if (result.success) {
uoms.value = result.data.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
const currentUoms = result.body?.data || []
uoms.value = currentUoms.map((uom: Uom) => ({ value: uom.code || uom.erp_id, label: uom.name }))
}
}
@@ -55,7 +58,7 @@ const {
} = usePaginatedList({
fetchFn: async ({ page }) => {
const result = await getSourceMaterials({ page })
return { success: result.success || false, body: { data: result.data || [], meta: result.meta || {} } }
return { success: result.success || false, body: result.body || {} }
},
entityName: 'equipment',
})
@@ -117,12 +120,26 @@ onMounted(async () => {
<AppEquipmentList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
</div>
<Dialog v-model:open="isFormEntryDialogOpen" title="Tambah Perlengkapan" size="lg" prevent-outside>
<Dialog
v-model:open="isFormEntryDialogOpen"
:title="!!recItem ? 'Edit Perlengkapan' : 'Tambah Perlengkapan'"
size="lg"
prevent-outside
>
<AppEquipmentEntryForm
:schema="MaterialSchema"
:values="recItem"
:uoms="uoms"
:is-loading="isProcessing"
@submit="(values: MaterialFormData, resetForm: any) => handleActionSave(values, getEquipmentList, resetForm)"
@submit="
(values: MaterialFormData, resetForm: any) => {
if (!!recId) {
handleActionEdit(recId, values, getEquipmentList, resetForm)
return
}
handleActionSave(values, getEquipmentList, resetForm)
}
"
@cancel="handleCancelForm"
/>
</Dialog>