Files
smart_grid_iot/client/src/api/customer.ts
T
andyesfly c60caa4770 refactor(客户管理): 完成客户管理模块UI与架构全面调整
1.  调整菜单与路由:重命名客户信息/客户账号为客户档案管理/客户小程序授权管理,移除客户建筑/房间路由,新增空间拓扑路由
2.  后端新增客户统计接口`/customers/stats`,前端同步API与类型定义
3.  重构客户档案与小程序授权页面,仅保留数据库支持字段,移除无支撑功能
4.  新增空间拓扑页面,合并建筑与房间管理为树形拓扑视图
5.  更新数据库种子数据与权限配置,清理废弃菜单与绑定关系
6.  补充UI设计文档与规范说明
2026-09-09 17:31:24 +08:00

101 lines
2.1 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'),
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 }),
};