123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import XLSX from 'xlsx';
- import { ExcelImportDialog } from "./ExcelImportDialog";
- import { Scope } from "./Scope";
- declare const XLSX_EXPORT: any;
- export { XLSX };
- export { XLSX_EXPORT };
- export declare function readExcel(file: File): Promise<any>;
- export declare interface ErrorMsgDataItem {
- /** 错误id 由allData 的__importID__字段值 + "_" + field的值 表示哪一行的哪一列出错,行校验错误时候直接为allData 的__importID__ + "" */
- errorId: string;
- /** 对应数据行 allData 的__importID__字段值 */
- importID: number;
- /** 字段 */
- dataIndex: string;
- /** 字段值 */
- header: string;
- /** 字段值 */
- value: string;
- /** 错误信息 */
- errormessage: string;
- }
- export declare interface ImportResult {
- /** 所有导入的数据,如果有字典会格式化到字典,格式化错误的保持原始值 */
- allData: any[];
- /** 导入正确的数据 */
- okData: any[];
- /** 导入错误的数据 */
- errorData: any[];
- /** 导入错误数据的错误明细 */
- errorMsgData: ErrorMsgDataItem[];
- }
- /** 定义参数列 */
- export declare interface Column {
- /** 字段 */
- dataIndex: string;
- /** 字段名 */
- header: string;
- /** 校验方法,校验通过返回true, 否则返回错误信息 会记录到错误列表里面 errorMsgData */
- validate?: ((v: ValidateObject) => true | string) | string;
- /** 格式化,表格显示 兼容默认弹出框表格的formatter */
- fix?: ((v: any) => any) | string;
- /** 导入格式化 返回null或者undefined 表示格式化错误,会记录到错误列表里面 errorMsgData */
- importFormatter?: ((v: ValidateObject) => null | undefined | string | number) | string;
- /** 字典, 参与数据校验和表格显示格式化, 校验不通过的,会记录到错误列表里面 errorMsgData 同时兼容默认弹出框表格的字典 */
- data?: any | {
- id: string | number;
- text: string;
- };
- }
- /** 格式化及校验的参数 */
- export declare interface ValidateObject {
- column: Column;
- ov: any;
- nv: any;
- rowIndex: number;
- data: any;
- rowDatas: any[];
- }
- /** 行数据校验的参数 */
- export declare interface RowValidateObject {
- columns: Column[];
- data: any;
- rowIndex: number;
- rowDatas: any[];
- }
- /**
- * 定义切口,可以在外部修改数据
- */
- export declare type AfterClientValidate = ((importResult: ImportResult, resolve: (value?: (ImportResult | PromiseLike<ImportResult> | undefined)) => void) => ImportResult) | undefined;
- export declare function readExcelWithColumnsSet(topScope: Scope, file: File, columnsSet: any[], dataStartRow?: number, titleRowNumber?: number, rowValidate?: ((rv: RowValidateObject) => true | string) | undefined, otherValidate?: AfterClientValidate, fieldValidate?: ((columns: Column[], columnTitles: string[]) => boolean) | undefined): Promise<ImportResult>;
- export declare interface ImportExcelOption {
- columns: Column[];
- fieldValidate?: ((columns: Column[], columnTitles: string[]) => boolean) | string | undefined;
- rowValidate?: ((rv: RowValidateObject) => true | string) | string | undefined;
- afterClientValidate?: AfterClientValidate | string;
- dataStartRow?: number;
- titleRowNumber?: number;
- onImportAfter?: ((result: ImportResult) => {}) | string | undefined;
- hidAllDataGrid?: boolean;
- hidOKDataGrid?: boolean;
- hidErrorDataGrid?: boolean;
- hidErrorMsgGrid?: boolean;
- dataGridPageSize?: 0 | 10 | 20 | 50 | 100 | 200 | 500 | 1000;
- errorMsgGridPageSize?: 0 | 10 | 20 | 50 | 100 | 200 | 500 | 1000;
- templateName?: string;
- dowLoadUrl?: string;
- title?: string;
- height?: string;
- width?: string;
- defaultShowData?: "allData" | "okData" | "errorData";
- errMsgGridColWidths?: number[];
- toolBar?: any[];
- onClose?: string | (() => void);
- tQButtonText?: string | null | undefined;
- }
- /**
- * 打开excel导入的方法
- * @param option 参数配置
- * @param sender
- */
- export declare function importExcel(option: ImportExcelOption, sender: any): ExcelImportDialog;
|