fix: update list division + equipment
This commit is contained in:
@@ -29,10 +29,9 @@ import {
|
||||
handleActionRemove,
|
||||
handleCancelForm,
|
||||
} from '~/handlers/division.handler'
|
||||
import { convertDivisionToTreeItems } from '~/handlers/_shared.handler'
|
||||
|
||||
// Services
|
||||
import { getDivisions, getDivisionDetail } from '~/services/division.service'
|
||||
import { getList, getDetail, getValueTreeItems } from '~/services/division.service'
|
||||
|
||||
const divisionsTrees = ref<TreeItem[]>([])
|
||||
const title = ref('')
|
||||
@@ -47,11 +46,10 @@ const {
|
||||
fetchData: getDivisionList,
|
||||
} = usePaginatedList({
|
||||
fetchFn: async (params: any) => {
|
||||
// TODO: use pagination params
|
||||
const result = await getDivisions({
|
||||
const result = await getList({
|
||||
search: params.search,
|
||||
'page-number': params['page-number'] || 0,
|
||||
'page-size': params['page-size'] || 100,
|
||||
'page-size': params['page-size'] || 10,
|
||||
includes: 'parent,childrens',
|
||||
})
|
||||
return { success: result.success || false, body: result.body || {} }
|
||||
@@ -91,7 +89,7 @@ provide('rec_item', recItem)
|
||||
provide('table_data_loader', isLoading)
|
||||
|
||||
const getCurrentDivisionDetail = async (id: number | string) => {
|
||||
const result = await getDivisionDetail(id)
|
||||
const result = await getDetail(id)
|
||||
if (result.success) {
|
||||
const currentValue = result.body?.data || {}
|
||||
recItem.value = currentValue
|
||||
@@ -122,14 +120,14 @@ watch(
|
||||
() => data.value,
|
||||
async () => {
|
||||
if (!data.value) return
|
||||
const result = await getDivisions({
|
||||
const result = await getList({
|
||||
'page-size': 100,
|
||||
'only-have-children': false,
|
||||
includes: 'parent,childrens',
|
||||
})
|
||||
if (result.success) {
|
||||
const currentData = result.body.data || []
|
||||
divisionsTrees.value = convertDivisionToTreeItems(currentData || [])
|
||||
divisionsTrees.value = getValueTreeItems(currentData || [])
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -13,7 +13,6 @@ import { toast } from '~/components/pub/ui/toast'
|
||||
// Types
|
||||
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||
import { MaterialSchema, type MaterialFormData } from '~/schemas/material.schema'
|
||||
import type { Uom } from '~/models/uom'
|
||||
|
||||
// Handlers
|
||||
import {
|
||||
@@ -29,11 +28,12 @@ import {
|
||||
handleActionRemove,
|
||||
handleCancelForm,
|
||||
} from '~/handlers/material.handler'
|
||||
import { uoms, getUomList } from '~/handlers/_shared.handler'
|
||||
|
||||
// Services
|
||||
import { getMaterials, getMaterialDetail } from '~/services/material.service'
|
||||
import { getList, getDetail } from '~/services/material.service'
|
||||
import { getValueLabelList as getUomList } from '~/services/uom.service'
|
||||
|
||||
const uoms = ref<{ value: string; label: string }[]>([])
|
||||
const title = ref('')
|
||||
|
||||
const {
|
||||
@@ -46,8 +46,11 @@ const {
|
||||
fetchData: getEquipmentList,
|
||||
} = usePaginatedList({
|
||||
fetchFn: async (params: any) => {
|
||||
// TODO: use pagination params
|
||||
const result = await getMaterials({ search: params.search, page: params['page-number'] || 0 })
|
||||
const result = await getList({
|
||||
search: params.search,
|
||||
'page-number': params['page-number'] || 0,
|
||||
'page-size': params['page-size'] || 10,
|
||||
})
|
||||
return { success: result.success || false, body: result.body || {} }
|
||||
},
|
||||
entityName: 'equipment',
|
||||
@@ -85,7 +88,7 @@ provide('rec_item', recItem)
|
||||
provide('table_data_loader', isLoading)
|
||||
|
||||
const getCurrentMaterialDetail = async (id: number | string) => {
|
||||
const result = await getMaterialDetail(id)
|
||||
const result = await getDetail(id)
|
||||
if (result.success) {
|
||||
const currentValue = result.body?.data || {}
|
||||
recItem.value = currentValue
|
||||
@@ -113,8 +116,8 @@ watch([recId, recAction], () => {
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
uoms.value = await getUomList()
|
||||
await getEquipmentList()
|
||||
await getUomList()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user