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