1 | import { VXEComponent, SlotVNodeType } from './component'
|
2 | import { VxeTableConstructor, VxeTableDataRow, VxeTableDefines, VxeTablePropTypes } from './table'
|
3 | import { VxeGlobalRendererHandles } from './v-x-e-table'
|
4 | import { VxeFilterPanel } from './module/filter'
|
5 | import { VxeTooltipPropTypes } from './tooltip'
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export const VxeColumn: VXEComponent<VxeColumnProps<any>, VxeColumnEventProps, VxeColumnSlots<any>>
|
14 |
|
15 |
|
16 |
|
17 | export const Column: typeof VxeColumn
|
18 |
|
19 | export namespace VxeColumnPropTypes {
|
20 | export type ColId = string | number
|
21 | export type Type = 'seq' | 'radio' | 'checkbox' | 'expand' | 'html' | null
|
22 | export type Field = string
|
23 | export type Title = string
|
24 | export type Width = number | string
|
25 | export type MinWidth = number | string
|
26 | export type MaxWidth = number | string
|
27 | export type Resizable = boolean
|
28 | export type Fixed = 'left' | 'right' | '' | null
|
29 | export type Align = 'left' | 'center' | 'right' | '' | null
|
30 | export type HeaderAlign = Align
|
31 | export type FooterAlign = Align
|
32 | export type ShowOverflow = VxeTablePropTypes.ShowOverflow
|
33 | export type ShowHeaderOverflow = ShowOverflow
|
34 | export type ShowFooterOverflow = ShowOverflow
|
35 | export type ClassName<D = VxeTableDataRow> = string | ((params: VxeGlobalRendererHandles.RenderCellParams<D>) => string | any[] | { [key: string]: boolean })
|
36 | export type HeaderClassName<D = VxeTableDataRow> = string | ((params: VxeGlobalRendererHandles.RenderHeaderParams<D>) => string | any[] | { [key: string]: boolean })
|
37 | export type FooterClassName<D = VxeTableDataRow> = string | ((params: VxeGlobalRendererHandles.RenderFooterParams<D>) => string | any[] | { [key: string]: boolean })
|
38 |
|
39 | export type Formatter<D = VxeTableDataRow> = ((params: {
|
40 | cellValue: any
|
41 | column: VxeTableDefines.ColumnInfo<D>
|
42 | row: D
|
43 | }) => string | number) | any[] | string
|
44 |
|
45 | export type Sortable = boolean
|
46 | export type SortBy<D = VxeTableDataRow> = string | ((params: {
|
47 | row: D
|
48 | column: VxeTableDefines.ColumnInfo<D>
|
49 | }) => string | number)
|
50 | export type SortType = 'auto' | 'string' | 'number' | null
|
51 |
|
52 | export interface Filter {
|
53 | label?: string | number
|
54 | value?: any
|
55 | data?: any
|
56 | resetValue?: any
|
57 | checked?: boolean
|
58 | }
|
59 | export type Filters = Filter[]
|
60 |
|
61 | export type FilterMultiple = boolean
|
62 |
|
63 | interface FilterMethodParams<D = VxeTableDataRow> {
|
64 | $table: VxeTableConstructor<D>,
|
65 | value: any
|
66 | option: VxeTableDefines.FilterOption
|
67 | cellValue: any
|
68 | row: D
|
69 | column: VxeTableDefines.ColumnInfo<D>
|
70 | }
|
71 | export type FilterMethod<D = VxeTableDataRow> = (params: FilterMethodParams<D>) => boolean
|
72 |
|
73 | interface FilterResetMethodParams<D = VxeTableDataRow> {
|
74 | options: VxeTableDefines.FilterOption[]
|
75 | column: VxeTableDefines.ColumnInfo<D>
|
76 | }
|
77 | export type FilterResetMethod = (params: FilterResetMethodParams) => void
|
78 |
|
79 | interface FilterRecoverMethodParams<D = VxeTableDataRow> {
|
80 | option: VxeTableDefines.FilterOption
|
81 | column: VxeTableDefines.ColumnInfo<D>
|
82 | }
|
83 | export type FilterRecoverMethod<D = VxeTableDataRow> = (params: FilterRecoverMethodParams<D>) => void
|
84 |
|
85 | |
86 |
|
87 |
|
88 | export interface FilterRender extends VxeGlobalRendererHandles.RenderOptions {
|
89 | options?: any[]
|
90 | optionProps?: VxeGlobalRendererHandles.RenderOptionProps
|
91 | optionGroups?: any[]
|
92 | optionGroupProps?: VxeGlobalRendererHandles.RenderOptionGroupProps
|
93 | content?: string
|
94 | }
|
95 |
|
96 | export type TreeNode = boolean
|
97 | export type Visible = boolean
|
98 |
|
99 | interface ExportMethodParams<D = VxeTableDataRow> {
|
100 | $table: VxeTableConstructor<D>,
|
101 | row: D
|
102 | column: VxeTableDefines.ColumnInfo<D>
|
103 | }
|
104 | export type ExportMethod<D = VxeTableDataRow> = (params: ExportMethodParams<D>) => string | number
|
105 |
|
106 | interface HeaderExportParams<D = VxeTableDataRow> {
|
107 | $table: VxeTableConstructor<D>,
|
108 | options: VxeTablePropTypes.ExportConfig
|
109 | column: VxeTableDefines.ColumnInfo<D>
|
110 | }
|
111 | export type HeaderExportMethod<D = VxeTableDataRow> = (params: HeaderExportParams<D>) => string | number
|
112 |
|
113 | interface FooterExportParams<D = VxeTableDataRow> {
|
114 | $table: VxeTableConstructor<D>,
|
115 | items: any[]
|
116 | row: any
|
117 | column: VxeTableDefines.ColumnInfo<D>
|
118 | _columnIndex: number
|
119 | }
|
120 | export type FooterExportMethod<D = VxeTableDataRow> = (params: FooterExportParams<D>) => string | number
|
121 |
|
122 | export interface TitlePrefix {
|
123 | useHTML?: VxeTooltipPropTypes.UseHTML
|
124 | content?: VxeTooltipPropTypes.Content
|
125 | enterable?: VxeTooltipPropTypes.Enterable
|
126 | theme?: VxeTooltipPropTypes.Theme
|
127 | icon?: string
|
128 | |
129 |
|
130 |
|
131 | message?: string
|
132 | }
|
133 |
|
134 | export interface TitleHelp extends TitlePrefix { }
|
135 |
|
136 | export interface TitleSuffix {
|
137 | useHTML?: VxeTooltipPropTypes.UseHTML
|
138 | content?: VxeTooltipPropTypes.Content
|
139 | enterable?: VxeTooltipPropTypes.Enterable
|
140 | theme?: VxeTooltipPropTypes.Theme
|
141 | icon?: string
|
142 | }
|
143 |
|
144 | export type CellType = 'auto' | 'number' | 'string'
|
145 |
|
146 | export interface CellRender<D = VxeTableDataRow> extends VxeGlobalRendererHandles.RenderOptions {
|
147 | events?: { [key: string]: (cellParams: VxeColumnSlotTypes.DefaultSlotParams<D>, ...args: any[]) => any }
|
148 | options?: any[]
|
149 | optionProps?: VxeGlobalRendererHandles.RenderOptionProps
|
150 | optionGroups?: any[]
|
151 | optionGroupProps?: VxeGlobalRendererHandles.RenderOptionGroupProps
|
152 | content?: string
|
153 | }
|
154 |
|
155 | |
156 |
|
157 |
|
158 | export interface EditRender<D = VxeTableDataRow> extends VxeGlobalRendererHandles.RenderOptions {
|
159 | events?: { [key: string]: (cellParams: VxeColumnSlotTypes.EditSlotParams, ...args: any[]) => any }
|
160 | enabled?: boolean
|
161 | options?: any[]
|
162 | optionProps?: VxeGlobalRendererHandles.RenderOptionProps
|
163 | optionGroups?: any[]
|
164 | optionGroupProps?: VxeGlobalRendererHandles.RenderOptionGroupProps
|
165 | autofocus?: string
|
166 | autoselect?: boolean
|
167 | defaultValue?: ((params: { column: VxeTableDefines.ColumnInfo<D> }) => any) | null | undefined | string | number | RegExp | object | any[] | Date
|
168 | immediate?: boolean
|
169 | content?: string
|
170 | placeholder?: string
|
171 | }
|
172 |
|
173 | /**
|
174 | * 内容渲染配置项
|
175 | */
|
176 | export interface ContentRender extends VxeGlobalRendererHandles.RenderOptions {
|
177 | options?: any[]
|
178 | optionProps?: VxeGlobalRendererHandles.RenderOptionProps
|
179 | optionGroups?: any[]
|
180 | optionGroupProps?: VxeGlobalRendererHandles.RenderOptionGroupProps
|
181 | }
|
182 |
|
183 | export type Params = any
|
184 |
|
185 | export type Slots<D = VxeTableDataRow> = {
|
186 | /**
|
187 | * 只对 type=checkbox,radio 有效,自定义标题模板
|
188 | */
|
189 | title?: string | ((params: VxeColumnSlotTypes.HeaderSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
190 | /**
|
191 | * 只对 type=radio 有效,自定义单选框模板
|
192 | */
|
193 | radio?: string | ((params: VxeColumnSlotTypes.RadioSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
194 | /**
|
195 | * 只对 type=checkbox 有效,自定义复选框模板
|
196 | */
|
197 | checkbox?: string | ((params: VxeColumnSlotTypes.CheckboxSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
198 | /**
|
199 | * 自定义显示内容模板
|
200 | */
|
201 | default?: string | ((params: VxeColumnSlotTypes.DefaultSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
202 | /**
|
203 | * 自定义表头内容的模板
|
204 | */
|
205 | header?: string | ((params: VxeColumnSlotTypes.HeaderSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
206 | /**
|
207 | * 自定义表尾内容的模板
|
208 | */
|
209 | footer?: string | ((params: VxeColumnSlotTypes.FooterSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
210 | /**
|
211 | * 只对 type=expand 有效,自定义展开后的内容模板
|
212 | */
|
213 | content?: string | ((params: VxeColumnSlotTypes.ContentSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
214 | /**
|
215 | * 只对 filter-render 启用时有效,自定义筛选模板
|
216 | */
|
217 | filter?: string | ((params: VxeColumnSlotTypes.FilterSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
218 | /**
|
219 | * 只对 edit-render 启用时有效,自定义可编辑组件模板
|
220 | */
|
221 | edit?: string | ((params: VxeColumnSlotTypes.EditSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
222 | /**
|
223 | * 只对 edit-render 启用时有效,自定义可编辑组件模板
|
224 | */
|
225 | valid?: string | ((params: VxeColumnSlotTypes.ValidSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
226 |
|
227 | /**
|
228 | * 已废弃
|
229 | * @deprecated
|
230 | */
|
231 | icon?: string | ((params: VxeColumnSlotTypes.IconSlotParams<D>) => SlotVNodeType[] | SlotVNodeType) | null
|
232 | }
|
233 | }
|
234 |
|
235 | export type VxeColumnProps<D = VxeTableDataRow> = {
|
236 | colId?: VxeColumnPropTypes.ColId
|
237 | /**
|
238 | * 渲染类型
|
239 | */
|
240 | type?: VxeColumnPropTypes.Type
|
241 | /**
|
242 | * 列字段名
|
243 | */
|
244 | field?: VxeColumnPropTypes.Field
|
245 | /**
|
246 | * 列标题
|
247 | */
|
248 | title?: VxeColumnPropTypes.Title
|
249 | /**
|
250 | * 列宽度
|
251 | */
|
252 | width?: VxeColumnPropTypes.Width
|
253 | /**
|
254 | * 列最小宽度,把剩余宽度按比例分配
|
255 | */
|
256 | minWidth?: VxeColumnPropTypes.MinWidth
|
257 | /**
|
258 | * 列最大宽度
|
259 | */
|
260 | maxWidth?: VxeColumnPropTypes.MaxWidth
|
261 | /**
|
262 | * 是否允许拖动列宽调整大小
|
263 | */
|
264 | resizable?: VxeColumnPropTypes.Resizable
|
265 | /**
|
266 | * 将列固定在左侧或者右侧
|
267 | */
|
268 | fixed?: VxeColumnPropTypes.Fixed
|
269 | /**
|
270 | * 列对其方式
|
271 | */
|
272 | align?: VxeColumnPropTypes.Align
|
273 | /**
|
274 | * 表头对齐方式
|
275 | */
|
276 | headerAlign?: VxeColumnPropTypes.HeaderAlign
|
277 | /**
|
278 | * 表尾列的对齐方式
|
279 | */
|
280 | footerAlign?: VxeColumnPropTypes.FooterAlign
|
281 | /**
|
282 | * 当内容过长时显示为省略号
|
283 | */
|
284 | showOverflow?: VxeColumnPropTypes.ShowOverflow
|
285 | /**
|
286 | * 当表头内容过长时显示为省略号
|
287 | */
|
288 | showHeaderOverflow?: VxeColumnPropTypes.ShowHeaderOverflow
|
289 | /**
|
290 | * 当表尾内容过长时显示为省略号
|
291 | */
|
292 | showFooterOverflow?: VxeColumnPropTypes.ShowFooterOverflow
|
293 | /**
|
294 | * 给单元格附加 className
|
295 | */
|
296 | className?: VxeColumnPropTypes.ClassName<D>
|
297 | /**
|
298 | * 给表头单元格附加 className
|
299 | */
|
300 | headerClassName?: VxeColumnPropTypes.HeaderClassName<D>
|
301 | /**
|
302 | * 给表尾单元格附加 className
|
303 | */
|
304 | footerClassName?: VxeColumnPropTypes.FooterClassName<D>
|
305 | /**
|
306 | * 格式化显示内容
|
307 | */
|
308 | formatter?: VxeColumnPropTypes.Formatter<D>
|
309 | /**
|
310 | * 是否允许排序
|
311 | */
|
312 | sortable?: VxeColumnPropTypes.Sortable
|
313 | /**
|
314 | * 自定义排序的属性
|
315 | */
|
316 | sortBy?: VxeColumnPropTypes.SortBy<D>
|
317 | /**
|
318 | * 排序的字段类型,比如字符串转数值等
|
319 | */
|
320 | sortType?: VxeColumnPropTypes.SortType
|
321 | /**
|
322 | * 配置筛选条件数组
|
323 | */
|
324 | filters?: VxeColumnPropTypes.Filter[]
|
325 | /**
|
326 | * 筛选是否允许多选
|
327 | */
|
328 | filterMultiple?: VxeColumnPropTypes.FilterMultiple
|
329 | /**
|
330 | * 自定义筛选方法
|
331 | */
|
332 | filterMethod?: VxeColumnPropTypes.FilterMethod<D>
|
333 | /**
|
334 | * 筛选模板配置项
|
335 | */
|
336 | filterRender?: VxeColumnPropTypes.FilterRender
|
337 | /**
|
338 | * 指定为树节点
|
339 | */
|
340 | treeNode?: VxeColumnPropTypes.TreeNode
|
341 | /**
|
342 | * 是否可视
|
343 | */
|
344 | visible?: VxeColumnPropTypes.Visible
|
345 | /**
|
346 | * 自定义表尾单元格数据导出方法
|
347 | */
|
348 | headerExportMethod?: VxeColumnPropTypes.HeaderExportMethod<D>
|
349 | /**
|
350 | * 自定义单元格数据导出方法
|
351 | */
|
352 | exportMethod?: VxeColumnPropTypes.ExportMethod<D>
|
353 | /**
|
354 | * 自定义表尾单元格数据导出方法
|
355 | */
|
356 | footerExportMethod?: VxeColumnPropTypes.FooterExportMethod<D>
|
357 | /**
|
358 | * 已废弃,被 titlePrefix 替换
|
359 | * @deprecated
|
360 | */
|
361 | titleHelp?: VxeColumnPropTypes.TitleHelp
|
362 | /**
|
363 | * 标题前缀图标配置项
|
364 | */
|
365 | titlePrefix?: VxeColumnPropTypes.TitlePrefix
|
366 | /**
|
367 | * 标题后缀图标配置项
|
368 | */
|
369 | titleSuffix?: VxeColumnPropTypes.TitleSuffix
|
370 | /**
|
371 | * 单元格值类型
|
372 | */
|
373 | cellType?: VxeColumnPropTypes.CellType
|
374 | /**
|
375 | * 单元格渲染配置项
|
376 | */
|
377 | cellRender?: VxeColumnPropTypes.CellRender<D>
|
378 | /**
|
379 | * 单元格编辑渲染配置项
|
380 | */
|
381 | editRender?: VxeColumnPropTypes.EditRender<D>
|
382 | /**
|
383 | * 内容渲染配置项
|
384 | */
|
385 | contentRender?: VxeColumnPropTypes.ContentRender
|
386 | /**
|
387 | * 额外的参数
|
388 | */
|
389 | params?: VxeColumnPropTypes.Params
|
390 | }
|
391 |
|
392 | export type VxeColumnEventProps = {
|
393 | //
|
394 | }
|
395 |
|
396 | export namespace VxeColumnSlotTypes {
|
397 | export interface FilterSlotParams<D = VxeTableDataRow> {
|
398 | $panel: VxeFilterPanel
|
399 | column: {
|
400 | filters: VxeTableDefines.FilterOption[]
|
401 | } & VxeTableDefines.ColumnInfo<D>
|
402 | columnIndex: number
|
403 | $columnIndex: number
|
404 | $rowIndex: number
|
405 | }
|
406 |
|
407 | export interface EditSlotParams<D = VxeTableDataRow> {
|
408 | column: VxeTableDefines.ColumnInfo<D>
|
409 | columnIndex: number
|
410 | $columnIndex: number
|
411 | row: D
|
412 | rowIndex: number
|
413 | $rowIndex: number
|
414 | }
|
415 |
|
416 | export interface FooterSlotParams<D = VxeTableDataRow> {
|
417 | row: D
|
418 | rowIndex: number
|
419 | column: VxeTableDefines.ColumnInfo<D>
|
420 | columnIndex: number
|
421 | _columnIndex: number
|
422 | $columnIndex: number
|
423 | $rowIndex: number
|
424 | items: any[]
|
425 | data: D[][]
|
426 | }
|
427 |
|
428 | export interface HeaderSlotParams<D = VxeTableDataRow> extends VxeTableDefines.CellRenderHeaderParams<D> { }
|
429 |
|
430 | export interface ContentSlotParams<D = VxeTableDataRow> {
|
431 | column: VxeTableDefines.ColumnInfo<D>
|
432 | columnIndex: number
|
433 | $columnIndex: number
|
434 | row: D
|
435 | rowIndex: number
|
436 | $rowIndex: number
|
437 | isHidden: boolean
|
438 | fixed: VxeColumnPropTypes.Fixed
|
439 | type: string
|
440 | }
|
441 |
|
442 | export interface DefaultSlotParams<D = VxeTableDataRow> extends VxeTableDefines.CellRenderBodyParams<D> { }
|
443 |
|
444 | export interface CheckboxSlotParams<D = VxeTableDataRow> extends DefaultSlotParams<D> {
|
445 | checked: boolean
|
446 | indeterminate: boolean
|
447 | }
|
448 | export interface RadioSlotParams<D = VxeTableDataRow> extends DefaultSlotParams<D> {
|
449 | checked: boolean
|
450 | }
|
451 | export interface IconSlotParams<D = VxeTableDataRow> extends DefaultSlotParams<D> { }
|
452 |
|
453 | export interface ValidSlotParams<D = VxeTableDataRow> extends DefaultSlotParams<D> {
|
454 | rule: VxeTableDefines.ValidatorRule<D>
|
455 | content: string
|
456 | }
|
457 | }
|
458 |
|
459 | export interface VxeColumnSlots<D = VxeTableDataRow> {
|
460 | /**
|
461 | * 自定义显示内容模板
|
462 | */
|
463 | default: (params: VxeColumnSlotTypes.DefaultSlotParams<D>) => any
|
464 | |
465 |
|
466 |
|
467 | header: (params: VxeColumnSlotTypes.HeaderSlotParams<D>) => any
|
468 | |
469 |
|
470 |
|
471 | footer: (params: VxeColumnSlotTypes.FooterSlotParams<D>) => any
|
472 | |
473 |
|
474 |
|
475 | title: (params: VxeColumnSlotTypes.HeaderSlotParams<D>) => any
|
476 | |
477 |
|
478 |
|
479 | checkbox: (params: VxeColumnSlotTypes.CheckboxSlotParams<D>) => any
|
480 | |
481 |
|
482 |
|
483 | radio: (params: VxeColumnSlotTypes.RadioSlotParams<D>) => any
|
484 | |
485 |
|
486 |
|
487 | content: (params: VxeColumnSlotTypes.ContentSlotParams<D>) => any
|
488 | |
489 |
|
490 |
|
491 | filter: (params: VxeColumnSlotTypes.FilterSlotParams<D>) => any
|
492 | |
493 |
|
494 |
|
495 | edit: (params: VxeColumnSlotTypes.EditSlotParams<D>) => any
|
496 | |
497 |
|
498 |
|
499 | valid: (params: VxeColumnSlotTypes.ValidSlotParams<D>) => any
|
500 |
|
501 | |
502 |
|
503 |
|
504 |
|
505 | icon: (params: VxeColumnSlotTypes.IconSlotParams<D>) => any
|
506 | }
|