UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

147 lines (146 loc) 4.46 kB
import { ICustomer } from "../AccountList/types"; export declare enum CustomerHooks { OnCustomerListUpdate = "customer:onCustomerListUpdate", OnCustomerListError = "customer:onError", OnCustomerSelected = "customer:onCustomerSelected", OnPaginationChange = "customer:onPaginationChange", OnScrollLoadMore = "customer:onScrollLoadMore", OnScrollLoadComplete = "customer:onScrollLoadComplete" } /** * 客户数据 */ export interface ShopCustomer extends ICustomer { /** 客户ID */ id: string | number; /** 客户姓名 */ name: string; /** 客户电话 */ phone?: string; /** 客户邮箱 */ email?: string; /** 客户创建时间 */ created_at?: string; /** 客户更新时间 */ updated_at?: string; /** 其他客户信息 */ [key: string]: any; } /** * 客户列表关联查询参数 * * formRecord: 用户表单记录 * walletDetails.wallet: 用户所有wallet * latestWalletDetail.wallet: 用户最新wallet */ type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet'; /** * 获取客户列表参数 */ export interface ShopGetCustomerListParams { /** 页码 */ skip?: number; /** 每页数量 */ num?: number; /** 搜索关键词 */ search?: string; /** 关联查询参数 */ with?: CustomerWith[]; /** wallet搜索标识 */ search_wallet_flag?: 0 | 1; /** wallet pass搜索标识 */ search_wallet_pass_flag?: 0 | 1; /** 其他筛选参数 */ [key: string]: any; } /** * 分页信息 */ export interface IPaginationInfo { /** 当前页码 */ page: number; /** 每页数量 */ pageSize: number; /** 总数 */ total: number; /** 总页数 */ totalPages: number; } /** * 客户列表响应 */ export interface ICustomerListResponse { /** 客户列表 */ list: ShopCustomer[]; /** 总数 */ total: number; /** 当前页 */ page?: number; /** 每页数量 */ pageSize?: number; } /** * 客户列表状态 */ export interface CustomerState { /** 客户列表 */ customerList: ShopCustomer[]; /** 当前选择的客户 */ selectedCustomer: ShopCustomer | null; /** 列表总数 */ total: number; /** 当前页码 */ currentPage: number; /** 每页数量 */ pageSize: number; /** 加载状态 */ loading: boolean; /** 错误信息 */ error: string | null; /** 是否支持滚动加载更多 */ hasMore: boolean; /** 滚动加载状态 */ loadingMore: boolean; /** 当前搜索条件 */ searchParams: Omit<ShopGetCustomerListParams, 'skip' | 'num'>; } /** * 客户模块 API */ export interface CustomerModuleAPI { /** 获取客户列表 */ getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>; /** 设置客户列表 */ setCustomerList: (customers: ShopCustomer[], total?: number) => void; /** 设置当前选择的客户 */ setSelectedCustomer: (customer: ShopCustomer | null) => void; /** 获取当前选择的客户 */ getSelectedCustomer: () => ShopCustomer | null; /** 获取客户列表 */ getCustomers: () => ShopCustomer[]; /** 根据ID查找客户 */ getCustomerById: (id: string | number) => ShopCustomer | null; /** 清空客户列表 */ clearCustomers: () => void; /** 添加客户到列表第一位 */ addCustomerToFirst: (customer: ShopCustomer) => void; /** 获取当前状态 */ getState: () => CustomerState; /** 获取分页信息 */ getPaginationInfo: () => IPaginationInfo; /** 触发分页变化事件 */ triggerPaginationChange: (pagination: IPaginationInfo) => void; /** 设置分页信息 */ setPaginationInfo: (page: number, pageSize: number) => void; /** 便捷方法:切换分页并自动获取数据 */ changeCustomerPage: (page: number, pageSize?: number) => Promise<ICustomerListResponse>; /** 滚动加载更多客户数据 */ loadMoreCustomers: () => Promise<ICustomerListResponse>; /** 重置并重新开始滚动加载 */ resetAndLoadCustomers: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>; /** 检查是否还有更多数据可以加载 */ hasMoreCustomers: () => boolean; /** 获取当前的搜索条件 */ getCurrentSearchParams: () => Omit<ShopGetCustomerListParams, 'skip' | 'num'>; } export {};