UNPKG

@kjts20/tool

Version:

wkj

1,481 lines (1,438 loc) 41.8 kB
/** * 是否调试模式 * @returns */ declare const globalVar: { debug: boolean; }; /** * 使用debug模式 */ declare const setDebug: (status?: boolean) => void; /** * 多语言 */ declare const i18n: { validate: { required: string; valueErr: string; formatErr: string; urlErr: string; gtZero: string; gteZero: string; isInteger: string; startDateFormatErr: string; endDateFormatErr: string; dateFormatErr: string; emailFormatErr: string; phoneFormatErr: string; telFormatErr: string; mustBeNum: string; mustBeInt: string; }; httpServer: { responseUnknown: string; systemErrTip: string; apiFormatErrTip: string; arraybufferSuccessTip: string; }; system: { success: string; fail: string; error: string; }; }; /** * 设置语言 */ declare const setI18n: (newI18n: any) => void; interface IResultProps<TData = any> { code?: number; msg?: string; data?: TData; } interface IResultData<TData = any> { code: number; msg: string; data: TData; } interface IResultParse<TData = any> extends IResultData<TData> { success: boolean; fail: boolean; error: boolean; timeout: boolean; } declare const result: { success<TData = any>(res?: IResultProps<TData>): IResultData<TData>; error<TData_1 = any>(res?: IResultProps<TData_1>): IResultData<TData_1>; parse<TData_2 = any>(res?: IResultProps<TData_2>): IResultParse<TData_2>; }; declare enum EMethodType { GET = "GET", POST = "POST", DELETE = "DELETE", PUT = "PUT" } interface IResponse<DataType = any> { msg: string; errcode?: 0 | 1; code: number; data: DataType; other?: any; } interface IStatus { success: boolean; fail: boolean; error: boolean; timeout: boolean; } type HttpResponse<DataType = any> = IResponse<DataType> & IStatus; interface IPageDataType<Item = any> { pageSize: number; current: number; total: number; pageNum: number; data: Array<Item>; extension?: any; } declare const unifiedResponse: (response?: IResponse) => IResultParse<any>; declare const successResponse: (msg: string, data?: any, other?: any) => IResultParse<any>; declare const errResponse: (msg: string, data?: any) => IResultParse<any>; interface IRequestOptions { url: string; data: object; header?: object; timeout?: number; method: EMethodType; success: (data: object) => void; error: (err: any) => void; complete: (err: any) => void; } interface IRequestFileOptions { url: string; formData: object; name: string; filePath: string; header?: object; timeout?: number; method: EMethodType; success: (data: object) => void; error: (err: any) => void; complete: (err: any) => void; } interface IHttpServerOptions { host?: string; apiPrefix?: string; setHeader?: () => object; request: (res: IRequestOptions) => any; uploadFile: (res: IRequestFileOptions) => any; responseIntercept?: (response: HttpResponse) => HttpResponse; setForm?: () => object; } declare class HttpServer { constructor(options: IHttpServerOptions); apiPrefix: string; host: string; private setHeader; private setForm; private request; private uploadFile; private responseIntercept; getRequestUrl(url: any): any; setHeaderFunc(setHeader: IHttpServerOptions['setHeader']): void; setFormFunc(setForm: IHttpServerOptions['setForm']): void; ajax(url: string, data: object | null, method: EMethodType, header?: {}, options?: any): Promise<HttpResponse<any>>; private toRequestResultFunc; /** * 上传文件 * @param url 上传的地址 * @param filePath 文件路径 * @param data 额外数据 * @param header 请求头 * @param options 请求参数 */ upload(url: string, file: any, data: object | null, header?: {}, options?: any): Promise<HttpResponse<any>>; get(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; put(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; del(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; post(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; postJson(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; file(url: any, data?: {}, options?: any, header?: {}): Promise<HttpResponse<any>>; } type TErrFunc = (errMsg: string | number, data: any) => void; interface IResultPaging<IDateItem = any> { paging: Omit<IPageDataType, 'data'> & { success: boolean; error: boolean; fail: boolean; msg: string; hasMore: boolean; init: boolean; empty: boolean; }; data: IPageDataType<IDateItem>['data']; pageExtension?: any; } interface IHttpServerFilter { error: TErrFunc; } /** * 默认分页数据 */ declare const defaultPaging: { pageSize: number; pageNum: number; total: number; current: number; hasMore: boolean; init: boolean; success: boolean; error: boolean; fail: boolean; empty: boolean; msg: string; }; /** * 请求分页数据修饰 * @param pageData * @returns */ declare const pageDecorate: <ItemType = any>(success: boolean, fail: boolean, error: boolean, msg: string, pageData: IPageDataType<ItemType>) => IResultPaging<ItemType>; declare class ResponseFilter { constructor(options: IHttpServerFilter); private error; /** * 设置错误函数 * * @param errorFunc */ setErrorFunc(errorFunc: IHttpServerFilter['error']): void; /** * 对响应数据进行过滤,得到过滤的数据 * * @param responsePromise * @param filterHanlder * @returns */ filter<TData = any, RData = TData>(responsePromise: Promise<HttpResponse<TData>>, filterHanlder?: (data: TData) => RData, showTip?: boolean): Promise<RData>; /** * 响应装饰(返回响应格式) * * @param responsePromise 响应promise * @param decorateHanlder 装饰器 * @returns */ responseDecorate<TData = any, RData = TData>(responsePromise: Promise<HttpResponse<TData>>, decorateHanlder?: (data: TData) => RData): Promise<HttpResponse<RData>>; /** * 对分页数据进行过滤 * * @param getPagingService * @param filterHanlder * @returns */ pageFilter<ItemType = any, RItemType = ItemType>(getPagingService: Promise<HttpResponse<IPageDataType<ItemType>>>, filterHanlder?: (data: IPageDataType<ItemType>) => IPageDataType<RItemType>): Promise<IResultPaging<RItemType>>; /** * 列表数据转分页数据并过滤 * * @param getListService * @param filterHanlder * @returns */ list2PageFilter<ItemType = any, RItemType = ItemType>(getListService: Promise<HttpResponse<Array<ItemType>>>, filterHanlder?: (data: IPageDataType<ItemType>) => IPageDataType<RItemType>): Promise<IResultPaging<RItemType>>; /** * 响应统一处理(对于响应的错误进行统一处理) * * @param responsePromise * @param filterHanlder * @param showTip * @returns */ unifyRemind<TData = any, RData = TData>(responsePromise: Promise<HttpResponse<TData>>, filterHanlder?: (data: TData) => RData, showTip?: boolean): Promise<RData>; } /** * 检查保存的key * @param key * @returns */ declare const checkKey: (key: string | number) => Promise<string | number>; /** * 检查保存的key(同步) * @param key * @returns */ declare const checkKeySync: (key: string | number) => boolean; interface ISetStorageOptions { key: string | number; data: any; success?: (res: { errMsg?: string; [key: string]: any; }) => void; fail?: (res: any) => void; } interface IGetStorageOptions<T = any> { key: string | number; success?: (res: { errMsg?: string; [key: string]: any; data: T; }) => void; fail?: (res: any) => void; } interface IRemoveStorageOptions { key: string | number; success?: (res: { errMsg?: string; [key: string]: any; }) => void; fail?: (res: any) => void; } interface IClearStorageOptions { success?: (res: { errMsg?: string; [key: string]: any; }) => void; fail?: (res: any) => void; } interface IStorageApi { setStorage: (options: ISetStorageOptions) => void; setStorageSync: <T = any>(key: string, data: T) => void; getStorage: <T = any>(options: IGetStorageOptions<T>) => void; getStorageSync: <T = any>(key: string) => T | null; removeStorage: (options: IRemoveStorageOptions) => void; clearStorage: (options?: IClearStorageOptions) => void; } declare class CommonStorage { constructor(api: IStorageApi, unifyErrFunc?: TErrFunc); storageApi: IStorageApi; error: TErrFunc; setStorage(key: string, data: any): Promise<any>; setStorageSync<T = any>(key: string, data: T): T; getStorage<T = any>(key: string | number): Promise<any>; getStorageSync<T = any>(key: string): T; /** * 删除一个键 * @param key 键 * @returns */ removeStorage(key: string | number): Promise<boolean>; /** * 清空仓库 * @returns */ clearStorage(): Promise<unknown>; } declare enum EMedium { PAGE = 0, CLASS = 1 } declare class Event { constructor(medium?: EMedium); private medium; private _eventListenerDict; private _broadcastChannelDict; private addBroadcastChannel; private removeBroadcastChannel; private sendBroadcastMsg; /** * 订阅事件 * @param event 事件名 * @param fn 回调函数 */ on(event: string, listener: Function): string; /** * emit 触发方法 * @param event 事件名 * @param args 所有参数 */ emit(event: any, ...args: any[]): void; protected sendMessage2Listeners(event: any, ...args: any[]): void; /** * 解除绑定 * @param event 事件名 * @param listener 监听者 */ off(event: any, ...uuidOrFuncs: any[]): void; } declare class Store { private store; event: Event; constructor(); toKey: any; set(key: any, value: any): void; sets(dataDict: object): void; get(key: any): any; gets(): {}; delete(key: any): boolean; clear(): void; has(key: any): boolean; } /** * 平台兼容性 */ declare const platformPolyfill: () => void; /** * 字符串转 ArrayBuffer * * @param str * @returns */ declare const str2ArrayBuffer: (str: any) => ArrayBufferLike; /** * ArrayBuffer转16进度字符串 * @param buffer * @returns */ declare const ab2hex: (buffer: any) => any; /** * Base64 编码 * @param str * @returns */ declare const base64Encode: (str: string) => string; /** * Base64 解码 * @param encodedStr * @returns */ declare const base64Decode: (encodedStr: any) => string; /** * base64转hex * @param base64String * @returns */ declare const base64ToHex: (base64String: any) => any; /** * hex 转 base64 * @param hexString 16进制字符串 */ declare const hex2Base64: (hexString: any) => string; /** * 16进制转ArrayBuffer * @param hex 16进制字符串 */ declare const hex2ArrayBuffer: (hex: any) => ArrayBufferLike; /** * Hex(16进制)转int * @param str */ declare const hex2Int: (hexString: string) => number; /** * Hex(16进制)转float * @param hex 16进制字符串 * @param radixPoint 保留小数点 * @returns */ declare const hex2Float: (hexString: string, radixPoint?: number) => number; /** * Hex(16进制)转ASCII * @param str */ declare const hex2Ascii: (hexString: string) => string; /** * 数字转16进制 * @param num */ declare const int2Hex: (num: number, bitNum?: number) => string; /** * Hex(16进制)转float * @param floatNum * @returns */ declare const float2Hex: (floatNum: number) => string; /** * ASCII转Hex(16进制) * @param str * @param bitNum 字节数(字节长度,不够长度进行补位) */ declare const ascii2Hex: (str: any, bitNum?: number) => string; /** * arrayBuffer 转换16进制 * @param arrayBuffer */ declare const arrayBuffer2Hex: (arrayBuffer: ArrayBuffer) => string; /** * arrayBuffer 转换 ascii * @param arrayBuffer */ declare const arrayBuffer2Ascii: (arrayBuffer: ArrayBuffer) => string; /** * ascii 转换 arrayBuffer * @param str * @returns */ declare const ascii2ArrayBuffer: (str: string) => Uint8Array; /** * 电总协议中数据的CHKSUM计算 * @param data 数据 */ declare const dataChksum: (dataFrame: any) => number; /** * [电总协议] 获取数据长度 * 在JavaScript中,我们使用`&`表示按位与操作,`>>`表示右移操作。另外,JavaScript中的字符串索引从0开始,因此在计算`length`时不需要使用切片操作。最后,JavaScript中的十六进制表示方法是使用`toString(16)`函数将数字转换为十六进制字符串。 * @param info */ declare const getDataLTH: (info: string, len?: number) => string; /** * [电总协议]获取数据的帧校验 * @param data */ declare const getDataChkSum: (data: any) => string; declare var toBool: (data: any) => boolean; declare const toFunction: (val: any, context?: {}) => any; /** * 生成全局单例 * @param generator * @param funcName * @returns */ declare const genGlobalSingleton: (storageName: string, generator: () => any) => any; /** * 深度克隆(对象) * @param obj 克隆对象 */ declare const deepCopy: (obj: any) => any; /** * json字符串转对象 * @param josnStr * @param debug * @returns */ declare const jsonParse: (josnStr: any, debug?: boolean) => any; /** * 求数组和 * @param arr * @param itemCb * @returns */ declare const arrSum: (arr: any[], itemCb?: any) => number; /** * 求数组平均数 * @param arr * @returns */ declare const arrAverage: (arr: number[]) => number; declare const getLen: (data: any) => any; /** * 根据背景颜色生成字体颜色(只有黑白色) * * @param bgColor 16进制颜色、rgb颜色 * @param luminanceCondition 亮度判断值 * @returns */ declare const getFontColorFromBgColor: (bgColor: any, luminanceCondition?: number) => "black" | "white"; /** * 将金额转换为带逗号格式 * @param num 金额 * @param decimal 小数点位数 */ declare const moneyFormt: (num: any, decimal?: number) => string; /** * 分转化为元(将金额转换为带逗号格式) * * @param num 金额 * @param decimal 小数点位数 */ declare const fee2yuan: (fee: any, decimal?: number) => string; /** * 元转分 * * @param yuan * @returns */ declare const yuan2fee: (yuan: any) => number; declare const fee2Money: (fee: any, decimal?: number) => string; /** * 过万处理 * @param num * @returns */ declare const overTenThousand: (num: any) => string | number; /** * 字符串转数字 * @param str 数字字符串 * @param maxDigit * @returns */ declare const str2Num: (str: any, maxDigit?: number) => number; /** * 切割为数字数组 * @param str * @param splitter * @returns */ declare const split2NumArr: (str: any, splitter?: string, maxDigit?: number) => Array<number>; type TMapKeyType = string | number; interface IKeyVal { [key: TMapKeyType]: any; } type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; interface ISelectOption { label: string; value: any; } /** * 获取字段的值 * @param data 值来源 * @param name 名字 * @param defaultValue 默认值 * @returns */ declare const getColumnValue: (data: any, name: any, defaultValue?: any) => any; /** * 设置值 * @param goalObj * @param keys * @param value */ declare const setColumnValue: <T extends IKeyVal>(goalObj: T, keys: Array<any>, value: any) => {}; /** * 设置字段的值 * @param data 赋值对象 * @param name 名字(可以是:user.name) * @param value 值 * @returns */ declare const setDictValue: <TData>(data: TData, name: any, value: any) => TData; declare const getColumnValueAndRenderByName: (name: any, data: any, render?: any) => any; /** * 深度克隆 * @param obj 原值 * @param debug * @returns */ declare const deepClone: <T>(obj: T, debug?: boolean) => T; /** * 字符串转json (保护转义) * @param str 格式化的正则 * @param debug 是否调试 * @returns */ declare const toJson: (str: any, debug?: boolean) => any; /** * 获取数组 * @param length 长度 * @param fillOrFillFunc 添加内容/添加内容函数 * @returns */ declare const getArray: <T = any>(length: number, fillOrFillFunc?: T | ((index: number) => T)) => T[]; /** * 对象值过滤 * @param obj * @param valHandler * @returns */ declare const objFilter: <TData>(obj: TData, valHandler?: (val: any) => boolean) => TData; /** * 对象装饰 * @param obj * @param valHandler * @returns */ declare const objDecorate: <TData>(obj: TData, valHandler?: (val: any) => any, keyHandler?: (key: any) => string | number) => TData; /** * 数组转换为对象 * @param data 列表数据 * @param column 键的字段 * @param itMapHandler * @returns */ declare const list2Dict: <TData = any>(data: TData[], column?: keyof TData | "id", valHandler?: (it: TData) => any) => any; /** * 数组转换为对象 * @param data 列表数据 * @param keyHandler 键操作 * @param valHandler 值操作 * @returns */ declare const biList2Dict: <TData = any>(data: TData[], keyHandler: (it: TData) => number | string, valHandler?: (it: TData) => any) => any; declare const biDict2List: <T = any, R = any>(data: any, itMapHandler?: (it: T, key: string) => R) => R[]; /** * 字典转数组 * @param data * @param keyColumn * @returns */ declare const dict2List: <TData = any>(data: any, keyColumn?: string) => TData[]; /** * 转换列表 * @param param * @param separator * @returns */ declare const toList: <TData = any>(param: any, separator?: string | RegExp) => TData[]; declare const objEq: (obj1: any, obj2: any) => boolean; declare const jsonEq: (o1: any, o2: any) => boolean; declare const json2Obj: (str: any) => any; declare const getListIndex: <T>(list: T[], predicate: (it: T) => boolean) => number; declare const listRemoveRepeat: <T>(data: T[], column?: "id" | keyof T, filter?: (it: T) => T) => any[]; declare const mergeObj: <T>(baseConfig: T, ...configs: any[]) => T; declare const removeObjColumns: <T>(obj: T, ...columns: (keyof T)[]) => T; declare const removeObjectUndefined: <T = any>(obj: T) => T; /** * 是否相同 * @param arg1 第一个参数 * @param arg2 第二个参数 */ declare const isSame: (arg1: any, arg2: any) => boolean; /** * 获取更新数据 * @param before 修改之前 * @param after 修改之后 */ declare const getChangeData: (before: object, after: object) => {}; /** * 分组 * @param list 需要分组的数组 * @param keyName 分组的键名 * @returns */ interface IDictArrItem<T> { [key: string]: Array<T>; [key: number]: Array<T>; } declare const listGroupBy: <T extends {}>(list: T[], keyName: keyof T) => IDictArrItem<T>; /** * 加强版的数组分组 * @param list * @param keyGen * @returns */ declare const biListGroupBy: <T extends {}>(list: T[], keyGen: (it: T) => TMapKeyType | null) => IDictArrItem<T>; /** * 获取列表和 * @param list 列表 * @param getNumFunc 获取数字 函数 */ declare const getListSum: <T>(list: T[], getNumFunc: (it: T) => number) => number; /** * 获取列表中最大值 * @param list 列表 * @param getNumFunc 获取数字函数 */ declare const getListMax: <T>(list: T[], getNumFunc: (it: T) => number) => number; /** * 数组合并 * @param list * @param itemList * @returns */ declare const listConcat: <T>(list: T[], itemList: T[]) => T[]; /** * 生成对象 * @param key * @param val * @returns */ declare const toObj: (key: any, val: any) => {}; /** * 获取数组中某个对象的位置 * @param listData * @param findHandler * @returns */ declare const getValueIndex: (listData: any, findHandler: (it: any) => boolean) => number; /** * 生成递增或者递减数组 * @param start 开始值 * @param end 结束值 * @param type 类型 add:递增 reduce:递减 * @returns */ declare const createArr: (start: number, end: number, type?: string) => number[]; /** * 列表加法运算 * @param list * @param addNum * @returns */ declare const listAddition: (list: Array<number>, addNum: Array<number> | number) => number[]; interface IList2TreeOptions { idColumn?: string; pidColumn?: string; childrenColumn?: string; startIndex?: string | number; childCanNull?: boolean; } /** * 列表转树 * @param list * @param options * @returns */ declare const list2Tree: <T = any>(list: T[], options?: IList2TreeOptions) => any; /** * 查找索引 * @param list * @param findHandler * @param defaultValue * @returns 索引值 */ declare const findIndex: <T = any>(list: T[], findHandler: (item: T) => boolean, defaultValue?: number) => number; /** * 替换空格 * @param str * @param replaceText * @returns */ declare const replaceSpace: (str: any, replaceText?: string) => any; /** * 替换前后空格获取特定的字符串 * @param str * @param patternStr * @param replaceStr * @returns */ declare const trim: (str: any, patternStr?: string, replaceStr?: string) => any; declare const md5: (str: any) => string; /** * 获取随机字符串 * @param len 长度 * @param seed * @returns */ declare const generateRandomStr: (len?: number, seed?: string[]) => string; /** * 生成命名 * @param len * @param firstSeed 首字母生成种子 * @param otherSeed 其他字母生成种子 * @returns */ declare const genName: (len?: number, firstSeed?: string[], otherSeed?: any) => string; /** * 获取UUID * @returns */ declare const generateUUID: () => string; /** * 通过种子与编码位数获取UUID * @param seed * @param codingBits * @returns */ declare const generateUnique: (seed?: number | string, codingBits?: number) => string; declare const camelToKebab: (camelStr: string) => string; declare const firstUpperCase: (str: any) => any; declare const firstLowerCase: (str: any) => any; declare const lineToCamel: (str: any) => any; declare const lineToUpCamel: (str: any) => any; declare const camelToLine: (str: any) => any; declare const toUrlParams: (obj: IKeyVal) => IKeyVal; declare const toStyleStr: (styleObj: any, unit?: string) => any; declare const toStyleObj: (styleStr: any) => {}; declare const fixContainer: (parentWidth: any, parentHeight: any, childWidth: any, childHeight: any) => any; declare const toDate: (date: any) => Date; declare const toDateTime: (date: any, time?: any, format?: string) => string; declare const date2str: (date: any, format?: string) => string; declare const now: (format?: string) => string; declare const getCurrentTimeStr: (format?: string) => string; declare const getCurrentStamp: () => number; declare const timestamp2str: (timestamp: any, format: any) => string; declare const timestamp2dateStr: (timestamp: any) => string; declare const timestamp2datetimeStr: (timestamp: any) => string; /** * 时间字符串转日期 * @param timeStr * @returns */ declare const timeStr2dateStr: (timeStr: any) => string; /** * 字符串转时间戳 * @param timeStr 任意格式(字符串、时间格式) */ declare const toTimestamp: (timeStr: string | number | Date) => number; /** * 字符串转时间戳 * @param timeStr 任意格式(字符串、时间格式) * @deprecated 请使用toTimestamp替换 */ declare const dateStr2Timestamp: (timeStr: any) => number; declare const timeStr2datetimeStr: (time2str: any) => string; declare const personalize2DateStr: (timeStr: any, format?: string) => string; declare const toCurrentSeconds: (timeStr: any) => number; declare const getDayRange: (day?: number, startDate?: Date) => string[]; /** * 生成日范围 * @param startTime 开始日期 * @param endTime 开始日期 */ declare const genDayRange: (startYmd: any, endYmd: any) => string[]; declare const isFunction: (func: any) => boolean; declare const isUndefined: (...args: any[]) => boolean; declare const isUndefinedOrNull: (...args: any[]) => boolean; declare const isObj: (obj: any) => boolean; declare const isStr: (str: any) => boolean; declare const isNum: (num: any) => boolean; declare const isNumStr: (num: any) => boolean; declare const isInitStr: (num: any) => boolean; declare const isFunc: (func: any) => boolean; declare const isArr: (arr: any) => boolean; declare const isBool: (bool: any) => boolean; declare const requestStr2Obj: (requestUrl: any, valAutoDecode?: boolean, autoChangeVal?: boolean) => { [key: string]: any; }; declare const urlEncode: (str: any) => string | ((encodeStr: any) => any); declare const urlDecode: (str: any) => any; declare const obj2RequestUrl: (obj: any) => string; /** * URL合并 * @param mainUrl 主url(可以包含域名部分) * @param param 参数 */ declare const mergeUrl: (mainUrl: any, ...param: object[]) => string; declare const isEmail: (str: any) => boolean; /** * 语言+地区 */ declare const languageAndRegion: ({ short: string; lText: string; regionText: string; region: string; text?: undefined; } | { short: string; text: string; regionText: string; region: string; lText?: undefined; })[]; declare const isPhone: (str: any) => boolean; declare const isTwPhone: (str: any) => boolean; declare const isMoPhone: (str: any) => boolean; declare const isHkPhone: (str: any) => boolean; declare const isTel: (str: any) => boolean; declare const isUrl: (str: any) => boolean; declare const isPublicUrl: (str: any) => boolean; declare const isDate: (value: any) => boolean; declare const isDateStr: (str: any) => boolean; declare const isDateISO: (value: any) => boolean; declare const isIdcard: (value: any) => boolean; interface IObject { [key: string]: any; [key: number]: any; } type TValidate = (val: any, row: IObject, column: IColumn) => string | null; interface IColumn { title: string; column: string; validate?: Array<TValidate> | TValidate; } /** * 表单校验 * @param columns 字段 * @param formData * @deprecated 请使用formValidator替换 */ declare const validateForm: (columns: Array<IColumn>, formData: any) => {}; /** * 表单校验器 * @param columns 校验的字段 * @param formData 表单的内容(一个对象) * @returns */ declare const formValidator: (columns: Array<IColumn>, formData: any) => { validateResult: boolean; fields: any; firstError: string; errDict: { [key: string]: string; }; }; declare const validateRequired: (val: any, row: IObject, column: IColumn) => string; declare const validateGtZero: (val: any, row: IObject, column: IColumn) => string; declare const validateGteZero: (val: any, row: IObject, column: IColumn) => string; declare const validateInt: (val: any, row: IObject, column: IColumn) => string; declare const validateNum: (val: any, row: IObject, column: IColumn) => string; /** * 电话号校验 * @param val 字段的值 * @param row 行的值 * @param column 字段定义 * @returns */ declare const validateTel: (val: any, row: IObject, column: IColumn) => string; /** * 手机号验证 * @param val 字段的值 * @param row 行的值 * @param column * @returns */ declare const validatePhone: (val: any, row: IObject, column: IColumn) => string; declare const validateEmail: (val: any, row: IObject, column: IColumn) => string; declare const validateDate: (val: any, row: IObject, column: IColumn) => string; declare const validateDateRange: (val: any, row: IObject, column: IColumn) => string; declare const validateIntArr: (val: any, row: IObject, column: IColumn) => string; declare const validateArrRequired: (val: any, row: IObject, column: IColumn) => string; declare const validateUrl: (val: any, row: IObject, column: IColumn) => string; declare const validateIdCard: (val: any, row: IObject, column: IColumn) => string; /** * 对promise进行过滤 * @param responsePromise promise对象 * @param filterHanlder 过滤函数 * @returns */ declare const promiseFilter: <T = any, R = any>(responsePromise: Promise<T>, filterHanlder?: (data: T) => R) => Promise<R>; /** * 统一为成功返回 * @param responsePromise * @param filterHanlder * @returns */ interface Ipromise2ResolveData<D> { data: D; err: any; } declare const promise2Resolve: <T = any, R = any>(responsePromise: Promise<T>, filterHanlder: (data: Ipromise2ResolveData<T>) => R) => Promise<R>; declare const Assert: { isTrue(expression: any, msg: any, err?: any, ...args: any[]): void; isFalse(expression: any, msg: any, ...args: any[]): void; error(msg: any, ...args: any[]): void; notNull(expression: any, msg: any, ...args: any[]): void; isNull(expression: any, msg: any, ...args: any[]): void; isObj(obj: any, msg: any, ...args: any[]): void; try(sandbox: () => any, msg: any): Promise<any>; }; declare const sleep: (ms: any) => Promise<unknown>; /** * 多级转一级 * 用法:一般对象转form表单 * {user: {name: "wkj"}, test: {status: true}} => {"user.name": "wkj", "test.status": true} * @params obj 一般对象 */ declare const toFormData: (obj: any) => {}; /** * 一级转多级 * 用法: form表单转对象 * {"user.name": "wkj", "test.status": true} => {user: {name: "wkj"}, test: {status: true}} * @params formData 表单数据 */ declare const formData2Obj: (souceFormData: any) => { [key: string]: any; }; /** * 生成className * @param classNames 使用的class * @returns */ declare const toClassName: (...classNames: any[]) => string; /** * @author: wkj * @description: 忽略工具类 */ declare class IgnoreTool { constructor(...rules: Array<string>); /** * 添加规则 * @param {Array<string>} rules 规则 * @returns this */ addRules(...rules: Array<string>): this; /** * 过滤规则 * @param {Function} filter 过滤函数 * @returns this */ filiterRules(filter: (rules: Array<string>) => Array<string>): this; private _rules; private rulePatterns; private set rules(value); private debug; /** * 设置调试模式 * @param {boolean} debug 调试 * @returns boolean */ setDebug(debug: boolean): this; /** * 规则解析 * @param {Array<string>} rules 元素规则 */ private rulesParseToPatterns; /** * 是否忽略 * @param {string} str 判断字符串 * @returns boolean */ isIgnore(str: string): boolean; } /** * 响应工具类(规则定义) */ declare class ResponseTool { private response; constructor(res: HttpResponse); /** * 成功code列表 */ successCodeList: { code: number; message: string; }[]; /** * 客户端错误列表 */ clientErrCodeList: { code: number; message: string; }[]; /** * 重新定向code列表 */ redirectCodeList: { code: number; message: string; }[]; /** * 是否重定向 * @returns boolean */ isRedirect(): boolean; /** * 是否成功 * @returns boolean */ isSuccess(): boolean; /** * 是否客户端错误 * @returns boolean */ isClientErr(): boolean; } /** * 响应是否重定向 * * @param response 响应 * @returns boolean */ declare const responseIsRedirect: (response: HttpResponse) => boolean; /** * 请求工具类 */ declare class RequestTool { /** * 请求任务 */ private requestTask; /** * 中断请求任务 */ abortRequestTask(): void; /** * 添加请求任务 * @param task 任务 */ addRequestTask(task: any): this; /** * 清空请求任务 */ clearRequestTask(): this; } declare const strConst: { AMPERSAND: string; AND: string; AT: string; ASTERISK: string; STAR: string; BACK_SLASH: string; COLON: string; COLON_CN: string; COMMA: string; COMMA_CN: string; DASH: string; DOLLAR: string; DOT: string; DOTDOT: string; DOT_CLASS: string; DOT_JAVA: string; DOT_XML: string; FILE: string; EMPTY: string; EQUALS: string; FALSE: string; SLASH: string; HASH: string; HAT: string; LEFT_BRACE: string; LEFT_BRACKET: string; LEFT_CHEV: string; DOT_NEWLINE: string; NEWLINE: string; N: string; NO: string; NULL: string; OFF: string; ON: string; PERCENT: string; PIPE: string; PLUS: string; QUESTION_MARK: string; EXCLAMATION_MARK: string; QUOTE: string; RETURN: string; TAB: string; RIGHT_BRACE: string; RIGHT_BRACKET: string; RIGHT_CHEV: string; SEMICOLON: string; SINGLE_QUOTE: string; BACKTICK: string; SPACE: string; FULL_SPACE: string; TILDA: string; LEFT_SQ_BRACKET: string; RIGHT_SQ_BRACKET: string; TRUE: string; UNDERSCORE: string; UTF_8: string; US_ASCII: string; ISO_8859_1: string; Y: string; YES: string; ONE: string; ZERO: string; DOLLAR_LEFT_BRACE: string; HASH_LEFT_BRACE: string; CRLF: string; HTML_NBSP: string; HTML_AMP: string; HTML_QUOTE: string; HTML_LT: string; HTML_GT: string; GET: string; IS: string; }; /** * 0-9的字符串数组 */ declare const numList: string[]; /** * A-Z字符串数组 */ declare const letterUpperList: string[]; /** * a-z字符串数组 */ declare const letterLowerList: string[]; /** * 日期格式化 * @param date * @param formatStr * @param defaultFill * @returns */ declare const dateFormat: (date: any, formatStr?: string, defaultFill?: string) => string; /** * 时间格式化 * @param date * @param formatStr * @param defaultFill * @returns */ declare const timeFormat: (date: any, formatStr?: string, defaultFill?: string) => string; declare class Notifier { private _listenerList; addListener(callback: any, options?: any): string; removeListener(uuid: any): void; notify(...args: any[]): void; } interface INotifyer { uuid?: string; callback: Function; options?: Object; } declare class RestrictorMode { private time; private notifyers; private messages; private timer; constructor(callback?: any); addNotifyer(it: INotifyer): string; removeNotifyer(uuid: string): void; start(time: any): void; stop(isSendData?: boolean): void; private trySendMessage; push(...args: any[]): void; } interface IWaiter { uuid?: string; callback: Function; options?: Object; } declare class WaiterMode { private time; private Waiters; private timer; constructor(callback?: Function, waitTime?: number); /** * 等待执行任务中 */ isWaitExecTask(): boolean; /** * 停止任务(有任务返回状态true,否则false) */ stopTask(): Promise<boolean>; addWaiter(it: IWaiter): string; removeWaiter(uuid: string): void; send(...messages: any[]): void; } declare class WatcherMode { private notifyer; private watchTime; constructor(cb: any, time?: number); private watcherTimer; private watcherLongpressTimer; start(...args: any[]): this; stop(): this; startLongpress(...args: any[]): this; stopLongPress(): this; private notifyLongPress; } interface IConsumerProps { channel: string; target?: string; [key: string]: any; } type TConsumerCallback = (options: IConsumerProps, ...args: any[]) => void; interface IConsumer { uuid?: string; callback: TConsumerCallback; options: IConsumerProps; } declare class QueueManager { private time; private consumers; private messages; private timer; addConsumer(it: IConsumer): string; removeConsumer(uuid: string): void; start(time?: number): void; stop(): void; private sendMessage; push(presetOptions: IConsumerProps, ...args: any[]): void; } /** * 基础用户 */ interface IBaseUser { id: number | string; username: string; } interface ICommonAuthOptions<TUser extends IBaseUser> { storage: CommonStorage; checkTokenFunc: (getRequestTask: (task: any) => void, token: string, user: TUser) => Promise<any>; logoutFunc: (token: string, user: TUser) => Promise<any>; } /** * 公共鉴权 */ declare class CommonAuth<TUser extends IBaseUser> { constructor(options: ICommonAuthOptions<TUser>); /** * 保存登录的键 */ private keepLoginKey; /** * checkToken函数 */ private checkTokenFunc; /** * logout函数 */ private logoutFunc; /** * 使用的存储 */ private storage; /** * 登录的用户 */ private token; /** * 登录的用户 */ private user; /** * 更新鉴权信息 * * @param token token * @param user 登录用户 * @returns */ updateAuthStatus(token: string, user: TUser): this; /** * 更新token * @param token */ updateToken(token: string): void; /** * 更新token * @param token */ updateUser(user: TUser): void; /** * 获取登录信息 * @returns */ protected getLoginInfo(): { token: string | null; user: TUser | null; }; /** * 是否登录 * * @returns boolean */ isLogin(): boolean; /** * 登录状态清除 */ clear(): void; /** * 注销登录 */ logout(): Promise<any>; /** * 获取用户 * @returns 用户 */ getUser(): TUser; /** * 获取token * @returns string */ getToken(): string; /** * checkToken请求工具 */ private checkTokenRequestTool; /** * 检查token * * @param unifiedTask 统一任务 * @returns */ checkToken(unifiedTask?: boolean): Promise<any>; /** * 生成保存的key * @param key * @returns */ protected genKey(key: string): string; /** * 设置其他值 * @param key 保存的键 * @param val 值 */ setOther(key: string, val: any): any; /** * 获取其他值 * @param key 保存的键 * @param defaultVal 默认值 * @returns */ getOther(key: string, defaultVal?: any): any; } export { Assert, CommonAuth, CommonStorage, EMedium, Event, HttpResponse, HttpServer, IBaseUser, IClearStorageOptions, IColumn, ICommonAuthOptions, IConsumerProps, IGetStorageOptions, IHttpServerFilter, IHttpServerOptions, IKeyVal, IList2TreeOptions, IObject, IPageDataType, IRemoveStorageOptions, IRequestFileOptions, IRequestOptions, IResponse, IResultData, IResultPaging, IResultParse, IResultProps, ISelectOption, ISetStorageOptions, IStatus, IStorageApi, IgnoreTool, Ipromise2ResolveData, Notifier, Optional, QueueManager, RequestTool, ResponseFilter, ResponseTool, RestrictorMode, Store, TValidate, WaiterMode, WatcherMode, ab2hex, arrAverage, arrSum, arrayBuffer2Ascii, arrayBuffer2Hex, ascii2ArrayBuffer, ascii2Hex, base64Decode, base64Encode, base64ToHex, biDict2List, biList2Dict, biListGroupBy, camelToKebab, camelToLine, checkKey, checkKeySync, createArr, dataChksum, date2str, dateFormat, dateStr2Timestamp, deepClone, deepCopy, defaultPaging, dict2List, errResponse, fee2Money, fee2yuan, findIndex, firstLowerCase, firstUpperCase, fixContainer, float2Hex, formData2Obj, formValidator, genDayRange, genGlobalSingleton, genName, generateRandomStr, generateUUID, generateUnique, getArray, getChangeData, getColumnValue, getColumnValueAndRenderByName, getCurrentStamp, getCurrentTimeStr, getDataChkSum, getDataLTH, getDayRange, getFontColorFromBgColor, getLen, getListIndex, getListMax, getListSum, getValueIndex, globalVar, hex2ArrayBuffer, hex2Ascii, hex2Base64, hex2Float, hex2Int, i18n, int2Hex, isArr, isBool, isDate, isDateISO, isDateStr, isEmail, isFunc, isFunction, isHkPhone, isIdcard, isInitStr, isMoPhone, isNum, isNumStr, isObj, isPhone, isPublicUrl, isSame, isStr, isTel, isTwPhone, isUndefined, isUndefinedOrNull, isUrl, json2Obj, jsonEq, jsonParse, languageAndRegion, letterLowerList, letterUpperList, lineToCamel, lineToUpCamel, list2Dict, list2Tree, listAddition, listConcat, listGroupBy, listRemoveRepeat, md5, mergeObj, mergeUrl, moneyFormt, now, numList, obj2RequestUrl, objDecorate, objEq, objFilter, overTenThousand, pageDecorate, personalize2DateStr, platformPolyfill, promise2Resolve, promiseFilter, removeObjColumns, removeObjectUndefined, replaceSpace, requestStr2Obj, responseIsRedirect, result, setColumnValue, setDebug, setDictValue, setI18n, sleep, split2NumArr, str2ArrayBuffer, str2Num, strConst, successResponse, timeFormat, timeStr2dateStr, timeStr2datetimeStr, timestamp2dateStr, timestamp2datetimeStr, timestamp2str, toBool, toClassName, toCurrentSeconds, toDate, toDateTime, toFormData, toFunction, toJson, toList, toObj, toStyleObj, toStyleStr, toTimestamp, toUrlParams, trim, unifiedResponse, urlDecode, urlEncode, validateArrRequired, validateDate, validateDateRange, validateEmail, validateForm, validateGtZero, validateGteZero, validateIdCard, validateInt, validateIntArr, validateNum, validatePhone, validateRequired, validateTel, validateUrl, yuan2fee };