Files
smart_grid_iot/client/src/api/customer.ts
T

103 lines
2.2 KiB
TypeScript

import request from '@/utils/request';
export interface CustomerInfo {
id: number;
customerNo: string;
customerName: string;
province?: string;
city?: string;
district?: string;
address?: string;
contactPerson?: string;
contactPhone?: string;
postalCode?: string;
fax?: string;
customerLevel?: string;
status: number;
salesmanId?: number;
createdAt: string;
updatedAt: string;
}
export interface CustomerQuery {
page?: number;
pageSize?: number;
keyword?: string;
status?: number;
salesmanId?: number;
}
export interface CustomerListResult {
list: CustomerInfo[];
total: number;
page: number;
pageSize: number;
}
export interface CustomerCreateParams {
customerName: string;
province?: string;
city?: string;
district?: string;
address?: string;
contactPerson?: string;
contactPhone?: string;
postalCode?: string;
fax?: string;
customerLevel?: string;
status?: number;
salesmanId?: number;
}
export interface CustomerUpdateParams {
customerName?: string;
province?: string;
city?: string;
district?: string;
address?: string;
contactPerson?: string;
contactPhone?: string;
postalCode?: string;
fax?: string;
customerLevel?: string;
status?: number;
salesmanId?: number;
}
export interface CustomerStatusParams {
status: number;
}
export interface CustomerStats {
total: number;
statusCounts: Record<number, number>;
levelCounts: Record<string, number>;
}
export const customerApi = {
getCustomerList: (params: CustomerQuery) =>
request.get<CustomerListResult>('/customers', { params }),
getCustomerDetail: (id: number) =>
request.get<CustomerInfo>(`/customers/${id}`),
getCustomerOptions: () =>
request.get<CustomerInfo[]>('/customers/options/all'),
getCustomerStats: () => request.get<CustomerStats>('/customers/stats'),
syncIccCustomers: () => request.post('/customers/sync/icc'),
createCustomer: (data: CustomerCreateParams) =>
request.post('/customers', data),
updateCustomer: (id: number, data: CustomerUpdateParams) =>
request.put(`/customers/${id}`, data),
deleteCustomer: (id: number) =>
request.delete(`/customers/${id}`),
updateCustomerStatus: (id: number, status: number) =>
request.put(`/customers/${id}/status`, { status }),
};