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