@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
124 lines (123 loc) • 3.82 kB
TypeScript
import { Module, PisellCore, ModuleOptions } from '../../types';
import { BaseModule } from '../BaseModule';
import { CustomerState, ShopCustomer, ShopGetCustomerListParams, CustomerModuleAPI, IPaginationInfo, ICustomerListResponse } from './types';
export declare class CustomerModule extends BaseModule implements Module, CustomerModuleAPI {
protected defaultName: string;
protected defaultVersion: string;
private store;
private request;
private cacheId;
private openCache;
private fatherModule;
private otherParams;
constructor(name?: string, version?: string);
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
/**
* 获取客户列表数据(内部方法)
* @param params 查询参数
* @returns API响应数据
*/
private fetchCustomerListData;
/**
* 处理客户列表操作的错误(内部方法)
* @param error 错误对象
* @param operation 操作名称
*/
private handleCustomerListError;
/**
* 获取客户列表
* @param params 查询参数
* @returns 客户列表响应
*/
getCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
/**
* 设置客户列表
* @param customers 客户列表
* @param total 总数
*/
setCustomerList(customers: ShopCustomer[], total?: number): void;
/**
* 设置当前选择的客户
* @param customer 选择的客户
*/
setSelectedCustomer(customer: ShopCustomer | null): void;
/**
* 获取当前选择的客户
* @returns 当前选择的客户
*/
getSelectedCustomer(): ShopCustomer | null;
/**
* 获取客户列表
* @returns 客户列表
*/
getCustomers(): ShopCustomer[];
/**
* 根据ID查找客户
* @param id 客户ID
* @returns 客户信息
*/
getCustomerById(id: string | number): ShopCustomer | null;
/**
* 清空客户列表
*/
clearCustomers(): void;
/**
* 添加客户到列表第一位
* @param customer 要添加的客户信息
*/
addCustomerToFirst(customer: ShopCustomer): void;
/**
* 获取当前状态
* @returns 当前状态
*/
getState(): CustomerState;
/**
* 获取分页信息
* @returns 分页信息
*/
getPaginationInfo(): IPaginationInfo;
/**
* 触发分页变化事件
* @param pagination 分页信息
*/
triggerPaginationChange(pagination: IPaginationInfo): void;
/**
* 设置分页信息
* @param page 页码
* @param pageSize 每页数量
*/
setPaginationInfo(page: number, pageSize: number): void;
/**
* 便捷方法:切换分页并自动获取数据
* @param page 页码
* @param pageSize 每页数量(可选,不传则使用当前pageSize)
* @returns 客户列表响应
*/
changeCustomerPage(page: number, pageSize?: number): Promise<ICustomerListResponse>;
/**
* 滚动加载更多客户数据 - 数据会追加到现有列表中
* @returns 客户列表响应
*/
loadMoreCustomers(): Promise<ICustomerListResponse>;
/**
* 重置并重新开始滚动加载
* @param params 查询参数
* @returns 客户列表响应
*/
resetAndLoadCustomers(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
/**
* 检查是否还有更多数据可以加载
* @returns 是否还有更多数据
*/
hasMoreCustomers(): boolean;
/**
* 获取当前的搜索条件
* @returns 当前搜索条件
*/
getCurrentSearchParams(): Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
/**
* 缓存状态变化
*/
private storeChange;
}
export * from './types';