@ttkj/avue 2.11.2 → 2.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
+ import { ResponsiveColumn } from 'element-ui/types/col';
1
2
  import { PopoverPlacement } from 'element-ui/types/popover';
2
- import { AvueComponentSize, Obj, DicProps as BaseDicProps, DicHttpProps } from '../global';
3
+ import { AvueComponentSize, Obj } from '../global';
4
+ import { DicProps as BaseDicProps, DicHttpProps } from '../variable';
3
5
  import { DynamicFormColumn } from './components/dynamic';
4
6
 
5
7
  /** 表单项字典Props配置 */
@@ -64,18 +66,14 @@ export type ColumnMock =
64
66
  type: 'dic';
65
67
  };
66
68
 
67
- /**
68
- * 表单项事件参数,适用于click|blur|focus
69
- */
70
- export interface FormColumnEventParams<T = Obj, U = Obj> {
69
+ /** 表单事件通用参数 */
70
+ export interface FormColumnEventBaseParams<T = Obj, U = Obj> {
71
71
  /** 表单项值 */
72
72
  value: any;
73
- /** 鼠标点击事件$event */
74
- event: MouseEvent;
75
73
  /** 表单项列配置 */
76
- column: AvueFormColumn;
74
+ column: AvueFormColumn<T>;
77
75
  /** 表单项列配置索引 */
78
- columnIndex: Record<string, AvueFormColumn>;
76
+ columnIndex: Record<string, AvueFormColumn<T>>;
79
77
  /** 表单值 */
80
78
  row: T;
81
79
  /** dic */
@@ -90,6 +88,14 @@ export interface FormColumnEventParams<T = Obj, U = Obj> {
90
88
  index?: number;
91
89
  }
92
90
 
91
+ /**
92
+ * 表单项事件参数,适用于click|blur|focus
93
+ */
94
+ export interface FormColumnEventParams<T = Obj, U = Obj> extends FormColumnEventBaseParams<T, U> {
95
+ /** 鼠标点击事件$event */
96
+ event: MouseEvent;
97
+ }
98
+
93
99
  /** 表单项校验规则 */
94
100
  export interface ColumnRule {
95
101
  /** 值的类型 */
@@ -107,7 +113,7 @@ export interface ColumnRule {
107
113
  /** 最大值 */
108
114
  max?: number;
109
115
  /** 自定义校验 */
110
- validator?: (rule: ColumnRule, value: any, callback: (error?: unknown) => void, tableData: Omit<FormColumnEventParams<T>, 'event'>) => void;
116
+ validator?: (rule: ColumnRule, value: any, callback: (error?: unknown) => void, tableData: FormColumnEventBaseParams) => void;
111
117
  /**
112
118
  * 触发规则
113
119
  * @description blur: 失焦时触发,change: 值改变时触发
@@ -119,8 +125,38 @@ export interface ColumnRule {
119
125
  export interface FormBaseColumn {
120
126
  /** 列类型, 默认: 'input' */
121
127
  type?: string;
128
+ /**
129
+ * 新增时列类型, 默认: 'input'
130
+ * @since 2.11.3
131
+ */
132
+ addType?: string;
133
+ /**
134
+ * 编辑时列类型, 默认: 'input'
135
+ * @since 2.11.3
136
+ */
137
+ editType?: string;
138
+ /**
139
+ * 详情时列类型, 默认: 'input'
140
+ * @since 2.11.3
141
+ */
142
+ viewType?: string;
122
143
  /** 组件 */
123
144
  component?: string;
145
+ /**
146
+ * 新增时组件
147
+ * @since 2.11.3
148
+ */
149
+ addComponent?: string;
150
+ /**
151
+ * 编辑时组件
152
+ * @since 2.11.3
153
+ */
154
+ editComponent?: string;
155
+ /**
156
+ * 详情时组件
157
+ * @since 2.11.3
158
+ */
159
+ viewComponent?: string;
124
160
  /**
125
161
  * 组件类型
126
162
  * @description 自定义属性
@@ -212,22 +248,125 @@ export interface FormBaseColumn {
212
248
  export interface FormColumnColOption {
213
249
  /** 栅列, 默认: 12 */
214
250
  span: number;
251
+ /**
252
+ * 新增时栅列, 默认: 同span
253
+ * @since 2.11.3
254
+ */
255
+ addSpan?: string;
256
+ /**
257
+ * 编辑时栅列, 默认: 同span
258
+ * @since 2.11.3
259
+ */
260
+ editSpan?: string;
261
+ /**
262
+ * 详情时栅列, 默认: 同span
263
+ * @since 2.11.3
264
+ */
265
+ viewSpan?: string;
215
266
  /**
216
267
  * ≥768px 响应式栅格数或者栅格属性对象, 默认: 12
217
268
  * @since 2.8.12
218
269
  */
219
270
  smSpan: ResponsiveColumn;
271
+ /**
272
+ * 新增时响应式栅格数或者栅格属性对象, 默认: 同span
273
+ * @since 2.11.3
274
+ */
275
+ addSmSpan?: string;
276
+ /**
277
+ * 编辑时响应式栅格数或者栅格属性对象, 默认: 同smSpan
278
+ * @since 2.11.3
279
+ */
280
+ editSmSpan?: string;
281
+ /**
282
+ * 详情时响应式栅格数或者栅格属性对象, 默认: 同smSpan
283
+ * @since 2.11.3
284
+ */
285
+ viewSmSpan?: string;
220
286
  /**
221
287
  * <768px 响应式栅格数或者栅格属性对象, 默认: 24
222
288
  * @since 2.8.12
223
289
  */
224
290
  xsSpan: ResponsiveColumn;
291
+ /**
292
+ * 新增时响应式栅格数或者栅格属性对象, 默认: 同xsSpan
293
+ * @since 2.11.3
294
+ */
295
+ addXsSpan?: string;
296
+ /**
297
+ * 编辑时响应式栅格数或者栅格属性对象, 默认: 同xsSpan
298
+ * @since 2.11.3
299
+ */
300
+ editXsSpan?: string;
301
+ /**
302
+ * 详情时响应式栅格数或者栅格属性对象, 默认: 同xsSpan
303
+ * @since 2.11.3
304
+ */
305
+ viewXsSpan?: string;
225
306
  /**
226
307
  * 栅格左侧的间隔格数, 默认: 0
227
308
  * @since 2.8.12
228
309
  */
229
310
  offset: number;
230
- /** 表单项是否单独成行, 默认: false */
311
+ /**
312
+ * 新增时栅格左侧的间隔格数, 默认: 同xsSpan
313
+ * @since 2.11.3
314
+ */
315
+ addOffset?: string;
316
+ /**
317
+ * 编辑时栅格左侧的间隔格数, 默认: 同xsSpan
318
+ * @since 2.11.3
319
+ */
320
+ editOffset?: string;
321
+ /**
322
+ * 详情时栅格左侧的间隔格数, 默认: 同xsSpan
323
+ * @since 2.11.3
324
+ */
325
+ viewOffset?: string;
326
+ /**
327
+ * 栅格向右移动格数, 默认: 0
328
+ * @since 2.8.12
329
+ */
330
+ push: number;
331
+ /**
332
+ * 新增时栅格向右移动格数, 默认: 同xsSpan
333
+ * @since 2.11.3
334
+ */
335
+ addPush?: string;
336
+ /**
337
+ * 编辑时栅格向右移动格数, 默认: 同xsSpan
338
+ * @since 2.11.3
339
+ */
340
+ editPush?: string;
341
+ /**
342
+ * 详情时栅格向右移动格数, 默认: 同xsSpan
343
+ * @since 2.11.3
344
+ */
345
+ viewPush?: string;
346
+ /**
347
+ * 栅格向左移动格数, 默认: 0
348
+ * @since 2.8.12
349
+ */
350
+ pull: number;
351
+ /**
352
+ * 新增时栅格向左移动格数, 默认: 同xsSpan
353
+ * @since 2.11.3
354
+ */
355
+ addPull?: string;
356
+ /**
357
+ * 编辑时栅格向左移动格数, 默认: 同xsSpan
358
+ * @since 2.11.3
359
+ */
360
+ editPull?: string;
361
+ /**
362
+ * 详情时栅格向左移动格数, 默认: 同xsSpan
363
+ * @since 2.11.3
364
+ */
365
+ viewPull?: string;
366
+ /**
367
+ * 表单项是否单独成行, 默认: false
368
+ * @description 暂未实现
369
+ */
231
370
  row: boolean;
232
371
  }
233
372
 
@@ -262,7 +401,7 @@ export interface FormColumnEvent<T = Obj> {
262
401
  * @example https://avuejs.com/form/form-control.html
263
402
  * @since 2.8.6
264
403
  */
265
- control: (value: any, form: T, tableData: Omit<FormColumnEventParams<T>, 'event'>) => Record<string, Partial<AvueFormColumn>>;
404
+ control: (value: any, form: T, tableData: FormColumnEventBaseParams<T>) => Record<string, Partial<AvueFormColumn<T>>>;
266
405
  /**
267
406
  * 点击事件
268
407
  * @since 2.9.6
@@ -272,7 +411,7 @@ export interface FormColumnEvent<T = Obj> {
272
411
  * 值改变事件
273
412
  * @since 2.9.6
274
413
  */
275
- change: (params: Omit<FormColumnEventParams<T>, 'event'>) => void;
414
+ change: (params: FormColumnEventBaseParams<T>) => void;
276
415
  /**
277
416
  * 聚焦事件
278
417
  * @since 2.9.6
@@ -286,14 +425,14 @@ export interface FormColumnEvent<T = Obj> {
286
425
  /**
287
426
  * 回车事件
288
427
  */
289
- enter: (params: Pick<FormColumnEventParams<T>, 'value' | 'column'>) => void;
428
+ enter: (params: FormColumnEventBaseParams<T>) => void;
290
429
  /**
291
430
  * 事件源码
292
431
  * @since 2.9.12(伪)
293
432
  */
294
433
  _event?: Record<string, string>;
295
434
  /** 事件 */
296
- event: Partial<Omit<FormColumnEvent<T>, 'control' | 'event' | 'enter'>>;
435
+ event: Partial<Pick<FormColumnEvent<T>, 'click' | 'change' | 'focus' | 'blur' | 'enter'>>;
297
436
  }
298
437
 
299
438
  /** 表单项通用参数 */
@@ -1,7 +1,8 @@
1
1
  // 引入定义
2
2
  import { VNode } from 'vue';
3
3
  import { ElForm } from 'element-ui/types/form';
4
- import { AvueComponent, DicHttpProps, Obj } from '../global';
4
+ import { AvueComponent, Obj } from '../global';
5
+ import { DicHttpProps } from '../variable';
5
6
  import { FormOption } from './option';
6
7
  import { DicProps } from './column';
7
8
 
@@ -1,5 +1,6 @@
1
1
  import { ResponsiveColumn } from 'element-ui/types/col';
2
- import { AvueAlignment, AvueComponentSize, DicHttpProps, Obj } from '../global';
2
+ import { AvueAlignment, AvueComponentSize, Obj } from '../global';
3
+ import { DicHttpProps } from '../variable';
3
4
  import { AvueFormColumn } from './column';
4
5
 
5
6
  /** 表单组件基本配置属性 */
@@ -164,4 +165,4 @@ export interface FormEvents {
164
165
  }
165
166
 
166
167
  /** 表单组件配置属性 */
167
- export type FormOption<T = Obj> = Partial<FormBaseOption> & Partial<FormMenuOption> & FormColumnOption<T> & FormEvents;
168
+ export type FormOption<T = Obj> = Partial<FormBaseOption> & Partial<FormMenuOption> & FormColumnOption<T> & FormEvents & Obj;
package/types/global.d.ts CHANGED
@@ -32,54 +32,6 @@ export declare type Obj<T = any> = Record<string, T> & Object;
32
32
  /** log日志类型 */
33
33
  type LogType = 'primary' | 'success' | 'warning' | 'danger' | 'text';
34
34
 
35
- /** 字典Props配置 */
36
- export interface DicProps {
37
- /** 行主键, 默认: 'id' */
38
- rowKey: string;
39
- /** 行上级主键, 默认: 'parentId' */
40
- rowParentKey: string;
41
- /** 节点主键, 默认: 'id' */
42
- nodeKey: string;
43
- /** 名称属性值, 默认: 'label' */
44
- label: string;
45
- /** 值属性值, 默认: 'value' */
46
- value: string;
47
- /** , 默认: 'type' */
48
- type: string;
49
- /** 降序, 默认: 'desc' */
50
- desc: string;
51
- /** 分组, 默认: 'groups' */
52
- groups: string;
53
- /** 标题, 默认: 'title' */
54
- title: string;
55
- /** 是否为叶子节点, 默认: 'leaf' */
56
- leaf: string;
57
- /** 子属性值, 默认: 'children' */
58
- children: string;
59
- /** 是否有子节点, 默认: 'hasChildren' */
60
- hasChildren: string;
61
- /** label文字, 默认: '名称' */
62
- labelText: string;
63
- /** 禁用, 默认: 'disabled' */
64
- disabled: string;
65
- }
66
-
67
- /** 接口请求Props配置 */
68
- export interface DicHttpProps {
69
- /** 文件名Key, 默认: 'name' */
70
- name: string;
71
- /** 文件路径Key, 默认: 'url' */
72
- url: string;
73
- /** 文件类型, 默认: 'type' */
74
- fileType: string;
75
- /** 文件上传时的文件字段名Key, 默认: 'file' */
76
- fileName: string;
77
- /** 返回的数据格式, 默认: '' */
78
- res: string;
79
- /** 文件路径前缀, 默认: '' */
80
- home: string;
81
- }
82
-
83
35
  // window属性扩展
84
36
  declare global {
85
37
  interface Window {
@@ -0,0 +1,78 @@
1
+ /** 字典Props配置 */
2
+ export interface DicProps {
3
+ /** 行主键, 默认: 'id' */
4
+ rowKey: string;
5
+ /** 行上级主键, 默认: 'parentId' */
6
+ rowParentKey: string;
7
+ /** 节点主键, 默认: 'id' */
8
+ nodeKey: string;
9
+ /** 名称属性值, 默认: 'label' */
10
+ label: string;
11
+ /** 值属性值, 默认: 'value' */
12
+ value: string;
13
+ /** , 默认: 'type' */
14
+ type: string;
15
+ /** 降序, 默认: 'desc' */
16
+ desc: string;
17
+ /** 分组, 默认: 'groups' */
18
+ groups: string;
19
+ /** 标题, 默认: 'title' */
20
+ title: string;
21
+ /** 是否为叶子节点, 默认: 'leaf' */
22
+ leaf: string;
23
+ /** 子属性值, 默认: 'children' */
24
+ children: string;
25
+ /** 是否有子节点, 默认: 'hasChildren' */
26
+ hasChildren: string;
27
+ /** label文字, 默认: '名称' */
28
+ labelText: string;
29
+ /** 禁用, 默认: 'disabled' */
30
+ disabled: string;
31
+ }
32
+ /** 接口请求Props配置 */
33
+ export interface DicHttpProps {
34
+ /** 文件名Key, 默认: 'name' */
35
+ name: string;
36
+ /** 文件路径Key, 默认: 'url' */
37
+ url: string;
38
+ /** 文件类型, 默认: 'type' */
39
+ fileType: string;
40
+ /** 文件上传时的文件字段名Key, 默认: 'file' */
41
+ fileName: string;
42
+ /** 返回的数据格式, 默认: '' */
43
+ res: string;
44
+ /** 文件路径前缀, 默认: '' */
45
+ home: string;
46
+ }
47
+ export namespace Variable {
48
+ /** 字典Props配置 */
49
+ export const DIC_PROPS: DicProps;
50
+ /** 接口请求Props配置 */
51
+ export const DIC_HTTP_PROPS: Omit<DicHttpProps, 'home'>;
52
+ /** 时间单选类组件类型 */
53
+ export const SINGLE_DATE_LIST: string;
54
+ /** 时间区间类组件类型 */
55
+ export const DATE_ARRAY_LIST = string;
56
+ /** 时间类组件类型 */
57
+ export const DATE_LIST: string;
58
+ /** 含子组件的带值组件类型 */
59
+ export const CHILDREN_LIST: string;
60
+ /** input-开头的组件类型 */
61
+ export const INPUT_LIST: string;
62
+ /** 纯数组的组件类型 */
63
+ export const ARRAY_LIST: string;
64
+ /** 可单选/多选的组件类型 */
65
+ export const MULTIPLE_LIST: string;
66
+ /** 范围组件类型 */
67
+ export const RANGE_LIST: string;
68
+ /** 值为数组的组件类型 */
69
+ export const ARRAY_VALUE_LIST: string;
70
+ /** 选择类的组件类型 */
71
+ export const SELECT_LIST: string;
72
+ /** 数组转展示的分隔字符 */
73
+ export const DIC_SHOW_SPLIT: string;
74
+ /** 数组转字符串的分隔字符 */
75
+ export const DIC_SPLIT: string;
76
+ /** 媒体类型正则索引 */
77
+ export const typeList: Record<string, RegExp>;
78
+ }