UNPKG

4.95 kBTypeScriptView Raw
1import { VXETableComponent, RowInfo } from './component'
2import { Table } from './table'
3import { Grid } from './grid'
4import { ColumnInfo } from './column'
5import { GridRenderParams } from './v-x-e-table'
6
7/**
8 * 导出
9 */
10export declare class Export extends VXETableComponent {}
11
12/**
13 * 导出参数
14 */
15export interface TableExportConfig {
16 /**
17 * 文件名
18 */
19 filename?: string;
20 /**
21 * 表名
22 */
23 sheetName?: string;
24 /**
25 * 文件类型
26 */
27 type?: string;
28 /**
29 * 可选文件类型列表
30 */
31 types?: string[];
32 /**
33 * 输出数据的方式
34 */
35 mode?: string;
36 /**
37 * 输出数据的方式列表
38 */
39 modes?: string[];
40 /**
41 * 是否为源数据
42 */
43 original?: boolean;
44 /**
45 * 是否显示内置的消息提示
46 */
47 message?: boolean;
48 /**
49 * 是否需要表头
50 */
51 isHeader?: boolean;
52 /**
53 * 是否需要表尾
54 */
55 isFooter?: boolean;
56 /**
57 * 是否马上下载,如果设置为 false 则通过返回结果为内容的 Promise
58 */
59 download?: boolean;
60 /**
61 * 自定义数据
62 */
63 data?: any[];
64 /**
65 * 自定义列
66 */
67 columns?: ColumnInfo[] | ColumnOption[];
68 /**
69 * 列过滤方法
70 */
71 columnFilterMethod?(params: { column: ColumnInfo, $columnIndex: number }): boolean;
72 /**
73 * 数据过滤方法
74 */
75 dataFilterMethod?(params: { row: RowInfo, $rowIndex: number }): boolean;
76 /**
77 * 表尾过滤方法
78 */
79 footerFilterMethod?(params: { items: any[], $rowIndex: number }): boolean;
80 /**
81 * 是否服务端导出
82 */
83 remote?: boolean;
84 /**
85 * 只对 remote=true 有效,用于自定义导出逻辑
86 */
87 exportMethod?(params: { $table: Table, $grid?: Grid, options: ExportParams }): Promise<any>;
88 useStyle?:boolean;
89 sheetMethod?(params: { $table: Table, $grid?: Grid, options: ExportParams, columns: ColumnOption[], workbook: any, worksheet: any }): void;
90
91 [name: string]: any;
92}
93
94export interface ExportParams extends TableExportConfig {
95 data: any[];
96 columns: ColumnOption[];
97
98 [name: string]: any;
99}
100
101/**
102 * 导入参数
103 */
104export interface TableImportConfig {
105 /**
106 * 可选文件类型列表
107 */
108 types?: string[];
109 /**
110 * 导入数据的方式
111 */
112 mode?: string;
113 /**
114 * 是否显示内置的消息提示
115 */
116 message?: boolean;
117 /**
118 * 是否服务端导出
119 */
120 remote?: boolean;
121 /**
122 * 只对 remote=true 有效,用于自定义导入逻辑
123 */
124 importMethod?(params: { $table: Table, $grid: Grid, file: File, options: TableExportConfig }): Promise<any>;
125
126 [name: string]: any;
127}
128
129/**
130 * 打印参数
131 */
132export interface TablePrintConfig {
133 /**
134 * 表名
135 */
136 sheetName?: string;
137 /**
138 * 输出数据的方式
139 */
140 mode?: string;
141 /**
142 * 输出数据的方式列表
143 */
144 modes?: string[];
145 /**
146 * 是否为源数据
147 */
148 original?: boolean;
149 /**
150 * 是否需要表头
151 */
152 isHeader?: boolean;
153 /**
154 * 是否需要表尾
155 */
156 isFooter?: boolean;
157 /**
158 * 自定义数据
159 */
160 data?: any[];
161 /**
162 * 自定义列
163 */
164 columns?: ColumnInfo[];
165 /**
166 * 打印样式
167 */
168 style?: string;
169 /**
170 * 自定义打印内容
171 */
172 content?: string;
173 /**
174 * 列过滤方法
175 */
176 columnFilterMethod?(params: { column: ColumnInfo, $columnIndex: number }): boolean;
177 /**
178 * 数据过滤方法
179 */
180 dataFilterMethod?(params: { row: RowInfo, $rowIndex: number }): boolean;
181 /**
182 * 表尾过滤方法
183 */
184 footerFilterMethod?(params: { items: any[], $rowIndex: number }): boolean;
185 /**
186 * 打印之前的方法,可以通过返回自定义打印的内容
187 */
188 beforePrintMethod?(params: { content: string, options: TablePrintConfig }): string;
189
190 [name: string]: any;
191}
192
193interface ColumnOption {
194 colid?: number;
195 type?: string;
196 field?: string;
197 [key: string]: any;
198}
199
200export interface ReadFileParams {
201 status: boolean;
202 files: FileList;
203 file: File;
204 target: HTMLInputElement & EventTarget & {
205 files: FileList;
206 };
207}
208
209export type SaveFileFunction = (options?: SaveFileOptions) => Promise<any>;
210export type ReadFileFunction =(options?: ReadFileOptions) => Promise<ReadFileParams>;
211export type PrintFunction = (options: TablePrintConfig) => any;
212
213export interface SaveFileOptions {
214 filename: string;
215 type: string;
216 content: string | Blob;
217}
218
219export interface ReadFileOptions {
220 multiple?: boolean;
221 types?: string[];
222 message?: boolean;
223}
224
225export interface ColumnExportCellRenderParams extends GridRenderParams {
226 row: RowInfo;
227 column: ColumnInfo;
228 options: ExportParams;
229}
230
231export interface ColumnExportFooterRenderParams extends GridRenderParams {
232 items: any[];
233 _columnIndex: number;
234 column: ColumnInfo;
235 options: ExportParams;
236}