47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { request } from 'umi';
|
|||
|
|
|
||
|
|
export interface WaylineItem {
|
||
|
|
id?: number;
|
||
|
|
waylineId?: string;
|
||
|
|
name?: string;
|
||
|
|
sign?: string;
|
||
|
|
workspaceId?: string;
|
||
|
|
createTime?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface DeviceItem {
|
||
|
|
deviceSn?: string;
|
||
|
|
deviceName?: string;
|
||
|
|
boundStatus?: number;
|
||
|
|
createTime?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const deviceApi = {
|
||
|
|
wayline: async (params: { current?: number; pageSize?: number; [k:string]: any }) => {
|
||
|
|
const { current, pageSize, ...rest } = params || {};
|
||
|
|
const res = await request('/api-device/wayline', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||
|
|
return { data: (res as any).data, total: (res as any).count } as { data: WaylineItem[]; total: number };
|
||
|
|
},
|
||
|
|
saveOrUpdateWayline: async (data: any) => {
|
||
|
|
const res = await request('/api-device/wayline', { method: 'POST', data });
|
||
|
|
return (res as any).data || res;
|
||
|
|
},
|
||
|
|
deleteWayline: async (id: number) => {
|
||
|
|
const res = await request(`/api-device/wayline/${id}`, { method: 'DELETE' });
|
||
|
|
return (res as any).data || res;
|
||
|
|
},
|
||
|
|
deviceList: async (params: { page?: number; limit?: number; [k:string]: any }) => {
|
||
|
|
const res = await request('/api-device/device', { method: 'GET', params });
|
||
|
|
return { data: (res as any).data, total: (res as any).count } as { data: DeviceItem[]; total: number };
|
||
|
|
},
|
||
|
|
saveOrUpdateDevice: async (data: Partial<DeviceItem>) => {
|
||
|
|
const res = await request('/api-device/device', { method: 'POST', data: { ...data, updateTime: Date.now() } });
|
||
|
|
return (res as any).data || res;
|
||
|
|
},
|
||
|
|
deleteDevice: async (deviceSn: string) => {
|
||
|
|
const res = await request(`/api-device/device/${deviceSn}`, { method: 'DELETE' });
|
||
|
|
return (res as any).data || res;
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|