feat(material): modify handlers and service of material

This commit is contained in:
riefive
2025-09-19 15:23:09 +07:00
parent 29b54b072c
commit 70378a69e9
11 changed files with 244 additions and 142 deletions

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { xfetch } from '~/composables/useXfetch'
export async function getSourceUoms(params: any = null) {
try {
let url = '/api/v1/uom'
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
const searchParams = new URLSearchParams()
for (const key in params) {
if (params[key] !== null && params[key] !== undefined && params[key] !== '') {
searchParams.append(key, params[key])
}
}
const queryString = searchParams.toString()
if (queryString) url += `?${queryString}`
}
const resp = await xfetch(url, 'GET')
const result: any = {}
result.success = resp.success
if (resp.success) {
result.data = (resp.body as Record<string, any>).data
}
return result
} catch (error) {
console.error('Error fetching source uoms:', error)
throw new Error('Failed to fetch source uoms')
}
}