feat(material): finishing integration of material

This commit is contained in:
riefive
2025-09-24 17:12:01 +07:00
parent 93a5abba36
commit c3c21f28e7
7 changed files with 67 additions and 44 deletions
+16 -11
View File
@@ -16,9 +16,7 @@ export async function getSourceDevices(params: any = null) {
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
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error fetching source devices:', error)
@@ -31,9 +29,7 @@ export async function getSourceDeviceDetail(id: string | number) {
const resp = await xfetch(`/api/v1/device/${id}`, 'GET')
const result: any = {}
result.success = resp.success
if (resp.success) {
result.data = (resp.body as Record<string, any>).data
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error fetching device detail:', error)
@@ -44,17 +40,23 @@ export async function getSourceDeviceDetail(id: string | number) {
export async function postSourceDevice(data: any) {
try {
const resp = await xfetch('/api/v1/device', 'POST', data)
return resp
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error creating device:', error)
throw new Error('Failed to create device')
}
}
export async function putSourceDevice(id: string | number, data: any) {
export async function patchSourceDevice(id: string | number, data: any) {
try {
const resp = await xfetch(`/api/v1/device/${id}`, 'PUT', data)
return resp
const resp = await xfetch(`/api/v1/device/${id}`, 'PATCH', data)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error updating device:', error)
throw new Error('Failed to update device')
@@ -64,7 +66,10 @@ export async function putSourceDevice(id: string | number, data: any) {
export async function removeSourceDevice(id: string | number) {
try {
const resp = await xfetch(`/api/v1/device/${id}`, 'DELETE')
return resp
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error deleting device:', error)
throw new Error('Failed to delete device')
+2 -2
View File
@@ -50,9 +50,9 @@ export async function postSourceMaterial(record: any) {
}
}
export async function putSourceMaterial(id: number | string, record: any) {
export async function patchSourceMaterial(id: number | string, record: any) {
try {
const resp = await xfetch(`/api/v1/material/${id}`, 'PUT', record)
const resp = await xfetch(`/api/v1/material/${id}`, 'PATCH', record)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}