1 | import { VXEComponent } from '../component'
|
2 | import { VxeTableDefines, VxeTableDataRow, VxeTableConstructor } from '../table'
|
3 | import { VxeGridConstructor } from '../grid'
|
4 | import { VxeColumnPropTypes } from '../column'
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export const VxeTableValidatorModule: VXEComponent<{ [key: string]: any }>
|
12 |
|
13 |
|
14 |
|
15 | export const Validator: VXEComponent<{ [key: string]: any }>
|
16 |
|
17 | export interface TableValidatorMethods<D = VxeTableDataRow> {
|
18 | |
19 |
|
20 |
|
21 | clearValidate(rows?: any, fieldOrColumn?: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any> | VxeColumnPropTypes.Field[] | VxeTableDefines.ColumnInfo<any>[]): Promise<void>
|
22 | |
23 |
|
24 |
|
25 |
|
26 | fullValidate(rows?: boolean | object | any[] | ((errMap: VxeTableDefines.ValidatorErrorMapParams<D>) => void), callback?: (errMap: VxeTableDefines.ValidatorErrorMapParams<D>) => void): Promise<VxeTableDefines.ValidatorErrorMapParams<D>>
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 | validate(rows?: boolean | object | any[] | ((errMap?: VxeTableDefines.ValidatorErrorMapParams<D>) => void), callback?: (errMap?: VxeTableDefines.ValidatorErrorMapParams<D>) => void): Promise<VxeTableDefines.ValidatorErrorMapParams<D>>
|
33 | }
|
34 |
|
35 | export interface TableValidatorPrivateMethods<D = VxeTableDataRow> {
|
36 | validCellRules(type: any, row: any, column: VxeTableDefines.ColumnInfo<any>, val?: any): Promise<any>
|
37 | hasCellRules(type: any, row: any, column: VxeTableDefines.ColumnInfo<any>): boolean
|
38 | triggerValidate(type: any): Promise<any>
|
39 | showValidTooltip(params: any): void
|
40 | }
|
41 |
|
42 | declare module '../grid' {
|
43 | export interface VxeGridMethods<D = VxeTableDataRow> extends TableValidatorMethods<D> { }
|
44 | }
|
45 |
|
46 | declare module '../table' {
|
47 | export interface VxeTableMethods<D = VxeTableDataRow> extends TableValidatorMethods<D> { }
|
48 | export interface VxeTablePrivateMethods<D = VxeTableDataRow> extends TableValidatorPrivateMethods<D> { }
|
49 | export namespace VxeTableDefines {
|
50 | export interface ValidatorRule<D = VxeTableDataRow> {
|
51 | |
52 |
|
53 |
|
54 | required?: boolean
|
55 | |
56 |
|
57 |
|
58 | min?: number | string
|
59 | |
60 |
|
61 |
|
62 | max?: number | string
|
63 | |
64 |
|
65 |
|
66 | type?: 'number' | 'string' | 'array' | '' | null
|
67 | |
68 |
|
69 |
|
70 | pattern?: string | RegExp
|
71 | |
72 |
|
73 |
|
74 |
|
75 | validator?: string | ((params: RuleValidatorParams<D>) => void | Error | Promise<void>)
|
76 | /**
|
77 | * 提示消息
|
78 | */
|
79 | content?: string
|
80 | trigger?: 'blur' | 'change' | 'manual' | '' | null
|
81 | maxWidth?: number
|
82 | /**
|
83 | * @deprecated 已废弃,请使用 content
|
84 | */
|
85 | message?: string
|
86 | }
|
87 | export interface RuleValidatorParams<D = VxeTableDataRow> {
|
88 | $table: VxeTableConstructor<D>
|
89 | $grid: VxeGridConstructor<D> | null
|
90 | cellValue: any
|
91 | rule: ValidatorRule<D>
|
92 | rules: ValidatorRule<D>[]
|
93 | column: VxeTableDefines.ColumnInfo<D>
|
94 | columnIndex: number
|
95 | row: D
|
96 | rowIndex: number
|
97 | field: string
|
98 | }
|
99 | export interface ValidatorErrorParams<D = VxeTableDataRow> {
|
100 | $table: VxeTableConstructor<D>
|
101 | cellValue: any
|
102 | rule: ValidatorRule<D>
|
103 | rules: ValidatorRule<D>[]
|
104 | column: VxeTableDefines.ColumnInfo<D>
|
105 | columnIndex: number
|
106 | row: D
|
107 | rowIndex: number
|
108 | field: string
|
109 | }
|
110 | export interface ValidatorErrorMapParams<D = VxeTableDataRow> {
|
111 | [key: string]: VxeTableDefines.ValidatorErrorParams<D>[]
|
112 | }
|
113 | }
|
114 | }
|
115 |
|
\ | No newline at end of file |