feat(material): modify handlers and service of material
This commit is contained in:
No files matched your search
@@ -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')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user