提交 | 用户 | age
|
2407b3
|
1 |
import type { VNodeChild } from 'vue'; |
V |
2 |
import type { PaginationProps } from './pagination'; |
ecfb70
|
3 |
import type { FormProps } from '/@/components/Form'; |
69af37
|
4 |
import type { |
V |
5 |
ColumnProps, |
|
6 |
TableRowSelection as ITableRowSelection, |
|
7 |
} from 'ant-design-vue/lib/table/interface'; |
faf3f4
|
8 |
import { ComponentType } from './componentType'; |
69af37
|
9 |
// import { ColumnProps } from './column'; |
faf3f4
|
10 |
export declare type SortOrder = 'ascend' | 'descend'; |
2407b3
|
11 |
export interface TableCurrentDataSource<T = any> { |
V |
12 |
currentDataSource: T[]; |
|
13 |
} |
|
14 |
|
|
15 |
export interface TableRowSelection<T = any> extends ITableRowSelection { |
|
16 |
/** |
|
17 |
* Callback executed when selected rows change |
|
18 |
* @type Function |
|
19 |
*/ |
|
20 |
onChange?: (selectedRowKeys: string[] | number[], selectedRows: T[]) => any; |
|
21 |
|
|
22 |
/** |
|
23 |
* Callback executed when select/deselect one row |
|
24 |
* @type FunctionT |
|
25 |
*/ |
|
26 |
onSelect?: (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any; |
|
27 |
|
|
28 |
/** |
|
29 |
* Callback executed when select/deselect all rows |
|
30 |
* @type Function |
|
31 |
*/ |
|
32 |
onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => any; |
|
33 |
|
|
34 |
/** |
|
35 |
* Callback executed when row selection is inverted |
|
36 |
* @type Function |
|
37 |
*/ |
|
38 |
onSelectInvert?: (selectedRows: string[] | number[]) => any; |
|
39 |
} |
|
40 |
|
|
41 |
export interface TableCustomRecord<T> { |
|
42 |
record?: T; |
|
43 |
index?: number; |
|
44 |
} |
|
45 |
|
|
46 |
export interface ExpandedRowRenderRecord<T> extends TableCustomRecord<T> { |
|
47 |
indent?: number; |
|
48 |
expanded?: boolean; |
|
49 |
} |
faf3f4
|
50 |
export interface ColumnFilterItem { |
陈 |
51 |
text?: string; |
|
52 |
value?: string; |
|
53 |
children?: any; |
2407b3
|
54 |
} |
V |
55 |
|
|
56 |
export interface TableCustomRecord<T = any> { |
|
57 |
record?: T; |
|
58 |
index?: number; |
|
59 |
} |
|
60 |
|
69af37
|
61 |
export interface SorterResult { |
V |
62 |
column: ColumnProps; |
2407b3
|
63 |
order: SortOrder; |
V |
64 |
field: string; |
|
65 |
columnKey: string; |
faf3f4
|
66 |
} |
陈 |
67 |
|
|
68 |
export interface RenderEditableCellParams { |
|
69 |
dataIndex: string; |
|
70 |
component?: ComponentType; |
|
71 |
componentOn?: { [key: string]: Fn }; |
|
72 |
componentProps?: any; |
|
73 |
} |
|
74 |
|
|
75 |
export interface FetchParams { |
|
76 |
searchInfo?: any; |
|
77 |
page?: number; |
491ba9
|
78 |
sortInfo?: any; |
V |
79 |
filterInfo?: any; |
faf3f4
|
80 |
} |
陈 |
81 |
|
|
82 |
export interface GetColumnsParams { |
|
83 |
ignoreIndex?: boolean; |
8b3a4d
|
84 |
ignoreAction?: boolean; |
faf3f4
|
85 |
} |
8b3a4d
|
86 |
|
V |
87 |
export type SizeType = 'default' | 'middle' | 'small' | 'large'; |
|
88 |
|
faf3f4
|
89 |
export interface TableActionType { |
261936
|
90 |
reload: (opt?: FetchParams) => Promise<void>; |
faf3f4
|
91 |
getSelectRows: () => any[]; |
陈 |
92 |
clearSelectedRowKeys: () => void; |
|
93 |
getSelectRowKeys: () => string[]; |
|
94 |
deleteSelectRowByKey: (key: string) => void; |
|
95 |
setPagination: (info: Partial<PaginationProps>) => void; |
|
96 |
setTableData: (values: any[]) => void; |
8b3a4d
|
97 |
getColumns: (opt?: GetColumnsParams) => BasicColumn[]; |
faf3f4
|
98 |
setColumns: (columns: BasicColumn[] | string[]) => void; |
陈 |
99 |
getDataSource: () => any[]; |
|
100 |
setLoading: (loading: boolean) => void; |
|
101 |
setProps: (props: Partial<BasicTableProps>) => void; |
|
102 |
redoHeight: () => void; |
|
103 |
setSelectedRowKeys: (rowKeys: string[] | number[]) => void; |
|
104 |
getPaginationRef: () => PaginationProps | boolean; |
8b3a4d
|
105 |
getSize: () => SizeType; |
faf3f4
|
106 |
} |
陈 |
107 |
|
|
108 |
export interface FetchSetting { |
|
109 |
// 请求接口当前页数 |
|
110 |
pageField: string; |
|
111 |
// 每页显示多少条 |
|
112 |
sizeField: string; |
|
113 |
// 请求结果列表字段 支持 a.b.c |
|
114 |
listField: string; |
|
115 |
// 请求结果总数字段 支持 a.b.c |
|
116 |
totalField: string; |
|
117 |
} |
8b3a4d
|
118 |
|
V |
119 |
export interface TableSetting { |
|
120 |
redo?: boolean; |
|
121 |
size?: boolean; |
|
122 |
setting?: boolean; |
|
123 |
fullScreen?: boolean; |
|
124 |
} |
|
125 |
|
faf3f4
|
126 |
export interface BasicTableProps<T = any> { |
491ba9
|
127 |
// 自定义排序方法 |
ecfb70
|
128 |
sortFn?: (sortInfo: SorterResult) => any; |
8b3a4d
|
129 |
// 显示表格设置 |
V |
130 |
showTableSetting?: boolean; |
|
131 |
tableSetting?: TableSetting; |
faf3f4
|
132 |
// 斑马纹 |
陈 |
133 |
striped?: boolean; |
|
134 |
// 是否自动生成key |
|
135 |
autoCreateKey?: boolean; |
|
136 |
// 计算合计行的方法 |
|
137 |
summaryFunc?: (...arg: any) => any[]; |
|
138 |
// 是否显示合计行 |
|
139 |
showSummary?: boolean; |
|
140 |
// 是否可拖拽列 |
|
141 |
canColDrag?: boolean; |
|
142 |
// 是否树表 |
|
143 |
isTreeTable?: boolean; |
|
144 |
// 接口请求对象 |
|
145 |
api?: (...arg: any) => Promise<any>; |
|
146 |
// 请求之前处理参数 |
|
147 |
beforeFetch?: Fn; |
|
148 |
// 自定义处理接口返回参数 |
|
149 |
afterFetch?: Fn; |
|
150 |
// 查询条件请求之前处理 |
|
151 |
handleSearchInfoFn?: Fn; |
|
152 |
// 请求接口配置 |
|
153 |
fetchSetting?: FetchSetting; |
|
154 |
// 立即请求接口 |
|
155 |
immediate?: boolean; |
|
156 |
// 在开起搜索表单的时候,如果没有数据是否显示表格 |
|
157 |
emptyDataIsShowTable?: boolean; |
|
158 |
// 额外的请求参数 |
|
159 |
searchInfo?: any; |
|
160 |
// 使用搜索表单 |
|
161 |
useSearchForm?: boolean; |
|
162 |
// 表单配置 |
5a6db8
|
163 |
formConfig?: Partial<FormProps>; |
faf3f4
|
164 |
// 列配置 |
陈 |
165 |
columns: BasicColumn[]; |
|
166 |
// 是否显示序号列 |
|
167 |
showIndexColumn?: boolean; |
|
168 |
// 序号列配置 |
|
169 |
indexColumnProps?: BasicColumn; |
|
170 |
actionColumn?: BasicColumn; |
|
171 |
// 文本超过宽度是否显示。。。 |
|
172 |
ellipsis?: boolean; |
|
173 |
// 是否可以自适应高度 |
|
174 |
canResize?: boolean; |
|
175 |
// 自适应高度偏移, 计算结果-偏移量 |
|
176 |
resizeHeightOffset?: number; |
|
177 |
|
|
178 |
// 在分页改变的时候清空选项 |
|
179 |
clearSelectOnPageChange?: boolean; |
|
180 |
// |
|
181 |
rowKey?: string | ((record: any) => string); |
|
182 |
// 数据 |
|
183 |
dataSource?: any[]; |
|
184 |
// 标题右侧提示 |
|
185 |
titleHelpMessage?: string | string[]; |
|
186 |
// 表格滚动最大高度 |
|
187 |
maxHeight?: number; |
|
188 |
// 是否显示边框 |
|
189 |
bordered?: boolean; |
|
190 |
// 分页配置 |
|
191 |
pagination?: PaginationProps | boolean; |
|
192 |
// loading加载 |
|
193 |
loading?: boolean; |
|
194 |
|
|
195 |
/** |
|
196 |
* The column contains children to display |
|
197 |
* @default 'children' |
|
198 |
* @type string | string[] |
|
199 |
*/ |
|
200 |
childrenColumnName?: string | string[]; |
|
201 |
|
|
202 |
/** |
|
203 |
* Override default table elements |
|
204 |
* @type object |
|
205 |
*/ |
|
206 |
components?: object; |
|
207 |
|
|
208 |
/** |
|
209 |
* Expand all rows initially |
|
210 |
* @default false |
|
211 |
* @type boolean |
|
212 |
*/ |
|
213 |
defaultExpandAllRows?: boolean; |
|
214 |
|
|
215 |
/** |
|
216 |
* Initial expanded row keys |
|
217 |
* @type string[] |
|
218 |
*/ |
|
219 |
defaultExpandedRowKeys?: string[]; |
|
220 |
|
|
221 |
/** |
|
222 |
* Current expanded row keys |
|
223 |
* @type string[] |
|
224 |
*/ |
|
225 |
expandedRowKeys?: string[]; |
|
226 |
|
|
227 |
/** |
|
228 |
* Expanded container render for each row |
|
229 |
* @type Function |
|
230 |
*/ |
|
231 |
expandedRowRender?: (record?: ExpandedRowRenderRecord<T>) => VNodeChild | JSX.Element; |
|
232 |
|
|
233 |
/** |
|
234 |
* Customize row expand Icon. |
|
235 |
* @type Function | VNodeChild |
|
236 |
*/ |
|
237 |
expandIcon?: Function | VNodeChild | JSX.Element; |
|
238 |
|
|
239 |
/** |
|
240 |
* Whether to expand row by clicking anywhere in the whole row |
|
241 |
* @default false |
|
242 |
* @type boolean |
|
243 |
*/ |
|
244 |
expandRowByClick?: boolean; |
|
245 |
|
|
246 |
/** |
|
247 |
* The index of `expandIcon` which column will be inserted when `expandIconAsCell` is false. default 0 |
|
248 |
*/ |
|
249 |
expandIconColumnIndex?: number; |
|
250 |
|
|
251 |
/** |
|
252 |
* Table footer renderer |
|
253 |
* @type Function | VNodeChild |
|
254 |
*/ |
|
255 |
footer?: Function | VNodeChild | JSX.Element; |
|
256 |
|
|
257 |
/** |
|
258 |
* Indent size in pixels of tree data |
|
259 |
* @default 15 |
|
260 |
* @type number |
|
261 |
*/ |
|
262 |
indentSize?: number; |
|
263 |
|
|
264 |
/** |
|
265 |
* i18n text including filter, sort, empty text, etc |
|
266 |
* @default { filterConfirm: 'Ok', filterReset: 'Reset', emptyText: 'No Data' } |
|
267 |
* @type object |
|
268 |
*/ |
|
269 |
locale?: object; |
|
270 |
|
|
271 |
/** |
|
272 |
* Row's className |
|
273 |
* @type Function |
|
274 |
*/ |
|
275 |
rowClassName?: (record: TableCustomRecord<T>) => string; |
|
276 |
|
|
277 |
/** |
|
278 |
* Row selection config |
|
279 |
* @type object |
|
280 |
*/ |
2407b3
|
281 |
rowSelection?: TableRowSelection; |
faf3f4
|
282 |
|
陈 |
283 |
/** |
|
284 |
* Set horizontal or vertical scrolling, can also be used to specify the width and height of the scroll area. |
|
285 |
* It is recommended to set a number for x, if you want to set it to true, |
|
286 |
* you need to add style .ant-table td { white-space: nowrap; }. |
|
287 |
* @type object |
|
288 |
*/ |
|
289 |
scroll?: { x?: number | true; y?: number }; |
|
290 |
|
|
291 |
/** |
|
292 |
* Whether to show table header |
|
293 |
* @default true |
|
294 |
* @type boolean |
|
295 |
*/ |
|
296 |
showHeader?: boolean; |
|
297 |
|
|
298 |
/** |
|
299 |
* Size of table |
|
300 |
* @default 'default' |
|
301 |
* @type string |
|
302 |
*/ |
8b3a4d
|
303 |
size?: SizeType; |
faf3f4
|
304 |
|
陈 |
305 |
/** |
|
306 |
* Table title renderer |
|
307 |
* @type Function | ScopedSlot |
|
308 |
*/ |
|
309 |
title?: VNodeChild | JSX.Element; |
|
310 |
|
|
311 |
/** |
|
312 |
* Set props on per header row |
|
313 |
* @type Function |
|
314 |
*/ |
69af37
|
315 |
customHeaderRow?: (column: ColumnProps, index: number) => object; |
faf3f4
|
316 |
|
陈 |
317 |
/** |
|
318 |
* Set props on per row |
|
319 |
* @type Function |
|
320 |
*/ |
|
321 |
customRow?: (record: T, index: number) => object; |
|
322 |
|
|
323 |
/** |
|
324 |
* `table-layout` attribute of table element |
|
325 |
* `fixed` when header/columns are fixed, or using `column.ellipsis` |
|
326 |
* |
|
327 |
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout |
|
328 |
* @version 1.5.0 |
|
329 |
*/ |
|
330 |
tableLayout?: 'auto' | 'fixed' | string; |
|
331 |
|
|
332 |
/** |
|
333 |
* the render container of dropdowns in table |
|
334 |
* @param triggerNode |
|
335 |
* @version 1.5.0 |
|
336 |
*/ |
|
337 |
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement; |
|
338 |
|
|
339 |
/** |
|
340 |
* Data can be changed again before rendering. |
|
341 |
* The default configuration of general user empty data. |
|
342 |
* You can configured globally through [ConfigProvider](https://antdv.com/components/config-provider-cn/) |
|
343 |
* |
|
344 |
* @version 1.5.4 |
|
345 |
*/ |
|
346 |
transformCellText?: Function; |
|
347 |
|
|
348 |
/** |
|
349 |
* Callback executed when pagination, filters or sorter is changed |
|
350 |
* @param pagination |
|
351 |
* @param filters |
|
352 |
* @param sorter |
|
353 |
* @param currentDataSource |
|
354 |
*/ |
2407b3
|
355 |
onChange?: (pagination: any, filters: any, sorter: any, extra: any) => void; |
faf3f4
|
356 |
|
陈 |
357 |
/** |
|
358 |
* Callback executed when the row expand icon is clicked |
|
359 |
* |
|
360 |
* @param expanded |
|
361 |
* @param record |
|
362 |
*/ |
|
363 |
onExpand?: (expande: boolean, record: T) => void; |
|
364 |
|
|
365 |
/** |
|
366 |
* Callback executed when the expanded rows change |
|
367 |
* @param expandedRows |
|
368 |
*/ |
|
369 |
onExpandedRowsChange?: (expandedRows: string[] | number[]) => void; |
|
370 |
} |
|
371 |
|
69af37
|
372 |
export interface BasicColumn extends ColumnProps { |
faf3f4
|
373 |
children?: BasicColumn[]; |
69af37
|
374 |
|
faf3f4
|
375 |
// |
陈 |
376 |
flag?: 'INDEX' | 'DEFAULT' | 'CHECKBOX' | 'RADIO' | 'ACTION'; |
05980a
|
377 |
|
V |
378 |
slots?: Indexable; |
faf3f4
|
379 |
} |