import { RhPrintMode, RhTableDisplayDto, RhSafeAny, ExportFileHeaderInfo, ExportFileStyle, WithNil } from 'rh-base/model'; import { HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; type RhMimeType = 'text/plain' | 'application/json' | string; export declare class FileHelper { /** * 通过get方法获取二进制文件流(TXT格式) */ static GetFileText(url: string, params?: HttpParams | { [param: string]: string | string[]; }): Observable; /** * 通过Post方法获取文件文本信息 * @param url 接口地址 * @param body 表体,可传入后端定义的参数 */ static PostFileText(url: string, body: any): Observable; /** * 通过get方法获取二进制文件流 */ static GetFileBlob(url: string, params?: HttpParams | { [param: string]: string | string[]; }): Observable; /** * 通过post方法获取文件 * @param url 接口地址 * @param body 表体 * @param params http表头参数 */ static PostFileBlob(url: string, body?: any, params?: HttpParams | { [param: string]: string | string[]; }): Observable; /** * 创建blob的下载地址 * @param blob blob数据 */ static CreateDownloadFileUrl(blob: Blob): string; /** * 创建blob的安全的下载地址(防止浏览器提示不安全的链接导致无法打开) * @param blob blob数据 */ static CreateDownloadTrustUrl(blob: Blob): any; /** * 通过get的方式下载文件 * @param url 后端提供,通过`get`访问该`url`可以获取blbo数据,参见`CreateDownloadFileUrl`方法 * @param fileName 文件名称,必须知道文件后缀,否则无法解析。 */ static downloadFileViaGet(url: string, fileName: string): void; /** * * @param content url:; * @param fileName */ static AutoDownloadFile(content: Blob, fileName?: string): void; /** * 通过post的方式下载文件 * @param url 转化blob获得的网址,参见`CreateDownloadFileUrl`方法 * @param fileName 文件名称,必须知道文件后缀,否则无法解析。 */ static downloadFileViaPost(url: string, body: any, fileName: string): Promise; static PrintLabelFile(labelContent: any): void; /** * 获取客户端打印软件地址 * @param userIp 用户Ip * @param openMode 打开方式(1为不打开打印确认框),(15:老模式边框过大 16:新模式,无边框) * @param suffix 后缀字符串(`FlowCardExcel`流转卡打印) * @deprecated 已弃用,请使用`getPrintLabelClientUrlNew`,唤醒字符串形如`YgLabelPrint://${userIp}-${openMode}-${suffix}` */ static getPrintLabelClientUrl(userIp: string, openMode: RhPrintMode | number, suffix?: string): string; /** * 新版客户端唤醒 * @param userIp 用户ip * @usage 使用方法 * `location.href=FileHelper.getPrintLabelClientUrlLatest(userIp)` * @description 唤醒字符串形如:`YgLabelPrint://${userIp}` */ static getPrintLabelClientUrlNew(userIp: string): string; /** 直接使用`userip`进行唤醒打印插件 * @usage 使用方法 * `location.href=FileHelper.getPrintLabelClientUrlLatest(userIp)` * @description 唤醒字符串形如:userIp */ static getPrintLabelClientUrlLatest(userIp: string): string; /** * 将网页中的table数据导出为excel * @param dataset 前端Table对应的数据源(当无数据时禁止导出) * @param tableName 要导出的table在html中的id值,必须设置 * @param fileName 设置导出文件名称 */ static exportTableData(dataset: any[], tableName: string, fileName: string): void; /** * 使用sheetjs导出excel * @param dataset 要导出的数据列表 * @param filename 文件名称 * @param sheetname excel数据表名称 * @param mappedDatas 中英文对照表 */ static exportExcelFile(dataset: any[], filename: string, sheetname: string, mappedDatas?: RhTableDisplayDto[]): Promise; /** * 使用sheetjs导出表格数据 * @param dataset 要导出的数据列表 * @param headerInfos 列信息 * @param fileStyle 样式信息 * @param sheetname sheet表名称 * @param filename 文件名 */ static exportTableDataToExcelFile(dataset: RhSafeAny[], headerInfos: ExportFileHeaderInfo[], fileStyle: WithNil, sheetname: string, filename: WithNil): void; static saveAsExcelFile({ buffer, fileName }: { buffer: any; fileName: string; }): void; static getRelatedDisplayName(name: string, mappedDatas: RhTableDisplayDto[]): string | null; /** * 使用sheetjs导出excel(可格式化数据的导出(前端导出)) * @param dataset 要导出的数据列表 * @param filename 文件名称 * @param sheetname excel数据表名称 * @param mappedDatas 中英文对照表 */ static formatExportExcelFile(dataset: any[], filename: string, sheetname: string, mappedDatas?: RhTableDisplayDto[]): Promise; static exportDataHandler(key: string, mappedDatas: RhTableDisplayDto[], ele: Record, temp: Record): Record; /** * 通过url直接下载,模拟点击 * @param url 目标base64数据 * @deprecated 该方法已废弃,请使用`downloadBase64Directly`方法 */ static downloadDirect(url: string): void; /** * 通过url直接下载,模拟点击 * @param url 目标base64数据 * @deprecated 该方法已废弃,请使用`downloadBase64Directly`方法 */ static downloadBase64Directly(url: string): void; /** * 使用后端提供的url。模拟点击超链接进行下载 * @param url 后端提供的url,需要在浏览器中直接输入就能下载文件。 * @param fileName 文件名,选填 */ static downloadUrlDirectly(url: string, fileName?: string): void; /** * * @param content 数据源,如JSON数据 * @param filename 文件名称,如:hello.json,hello.txt * @param type 文件类型(MIME 类型) */ static downloadByContent(content: RhSafeAny, filename: string, type: RhMimeType): void; static downloadByDataUrl(content: RhSafeAny, filename: string, type: RhMimeType): void; static downloadByBlob(blob: Blob, filename: string): void; static base64ToBlob(base64: string, type: RhMimeType): Blob; static base64ToFile(base64: string, filename: string): File; /** 将文件或者blob转换成base64 * @description 读取成功会返回base64信息,读取失败后会返错误信息 * @param data:blob或者file对象 */ static blobOrFileToBase64(data: Blob | File): Promise; } export {};