@vue-start/pro 0.4.9 → 0.4.11
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.
- package/README.md +143 -5
- package/dist/index.d.ts +16 -28
- package/dist/index.es.js +1381 -2566
- package/dist/index.js +1 -2729
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,11 +1,149 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pro 系列组件
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 基于 ant-design-vue 和 element-plus 组件库,提供更高程度的抽象,提供更上层的设计规范,并且对应提供相应的组件使得开发者可以快速搭建出高质量的页面。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> @vue-start/pro 是一个实现了 pro 模式的抽象库,具体 UI 组件需要从对应的实现库引用:@vue-start/element-pro @vue-start/antd-pro
|
|
6
6
|
|
|
7
|
+
## 通用配置
|
|
8
|
+
|
|
9
|
+
### column
|
|
10
|
+
|
|
11
|
+
基础 column 配置基于 ant-design-vue 中 table 的 column,扩展了部分字段。让其可以满足更多需求。
|
|
12
|
+
|
|
13
|
+
| 字段名称 | 类型 | 说明 |
|
|
14
|
+
| ---------------- | -------------------- | ------------------------------------------------------------- |
|
|
15
|
+
| `valueType` | `string` | 对应组件,缺省值为 text,自带了一部分,也可以自定义 valueType |
|
|
16
|
+
| `formValueType` | `string` | 同 valueType,在 form 组件中使用该类型,默认为 valueType 的值 |
|
|
17
|
+
| `title` | `string` `VNode` | 标题的内容,在 form 中是 label |
|
|
18
|
+
| `dataIndex` | `string` | 与实体映射的 key,在 form 中是 name |
|
|
19
|
+
| `formItemProps` | `formItemProps` | 传递给 FormItem 的配置 |
|
|
20
|
+
| `formFieldProps` | `fieldProps` | 传给渲染的组件的 props,自定义的时候也会传递 |
|
|
21
|
+
| `search` | `boolean` `signName` | 为 true 时,在 SearchForm 中显示 |
|
|
22
|
+
| `form` | `boolean` `signName` | 为 false 时,在 Form 中隐藏 |
|
|
23
|
+
| `table` | `boolean` `signName` | 为 false 时,在 Table 中隐藏 |
|
|
24
|
+
| `detail` | `boolean` `signName` | 为 false 时,在 Desc 中隐藏 |
|
|
25
|
+
|
|
26
|
+
注:`signName` 可以在组件中设置,上述 search、form、table、detail 都为默认值。
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
export type TColumn = {
|
|
30
|
+
title?: string | VNode;
|
|
31
|
+
dataIndex?: string | number;
|
|
32
|
+
valueType?: TValueType; //展示组件类型
|
|
33
|
+
formValueType?: TValueType; //录入组件类型 如不存在,默认取valueType的值
|
|
34
|
+
showProps?: Record<string, any>; //文字展示组件的props
|
|
35
|
+
formItemProps?: { name?: string; label?: string }; //FormItem props
|
|
36
|
+
formFieldProps?: Record<string, any>; //录入组件 props
|
|
37
|
+
search?: boolean; //同extra中的search
|
|
38
|
+
//拓展属性
|
|
39
|
+
extra?: {
|
|
40
|
+
//DescriptionsItem props
|
|
41
|
+
desc?: Record<string, any>;
|
|
42
|
+
//Col props
|
|
43
|
+
col?: Record<string, any>;
|
|
44
|
+
/**
|
|
45
|
+
* 自定义标记,对columns进行筛选 和 排序
|
|
46
|
+
* 默认支持:search、form、table、detail
|
|
47
|
+
* 比如: search:标记搜索条件;searchSort:搜索项的顺序
|
|
48
|
+
* 在Curd组件中可使用getSignColumns方法获取标记的Columns
|
|
49
|
+
* [sign]: boolean 标记
|
|
50
|
+
* [`${sign}Sort`]: 标记的columns排序
|
|
51
|
+
*/
|
|
52
|
+
} & Record<string, any>;
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### columnState
|
|
57
|
+
|
|
58
|
+
- 对 column 进行补充。在实际使用过程中,column 通常作为静态数据配置,当需要为 column 加入动态数据时候可配置.
|
|
59
|
+
- 若 column 为 hook 或者计算(computed 生成)值,则不需要使用 columnState
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
//组件会将[id]的值 merge 到对应的column中
|
|
63
|
+
type TColumnState = {
|
|
64
|
+
//优先使用formItemProps中的name属性
|
|
65
|
+
//id: column.formItemProps.name || column.dataIndex
|
|
66
|
+
[id]: object;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const columns = [
|
|
70
|
+
{
|
|
71
|
+
title: "select",
|
|
72
|
+
dataIndex: "select",
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
const columnState = {
|
|
77
|
+
select: {
|
|
78
|
+
formFieldProps: {
|
|
79
|
+
options: [{ value: "value-1", label: "label-1" }],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//比如:分别定义上述columns columnState,最终会合并成如下对象
|
|
85
|
+
|
|
86
|
+
const mergeColumns = [
|
|
87
|
+
{
|
|
88
|
+
title: "select",
|
|
89
|
+
dataIndex: "select",
|
|
90
|
+
formFieldProps: {
|
|
91
|
+
options: [{ value: "value-1", label: "label-1" }],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
7
95
|
```
|
|
8
|
-
const pro = require('pro');
|
|
9
96
|
|
|
10
|
-
|
|
97
|
+
### formElementMap
|
|
98
|
+
|
|
99
|
+
- 录入原子组件集合。
|
|
100
|
+
- 在 Form 中使用。
|
|
101
|
+
- 根据 column 中的 valueType 从 formElementMap 查找对应的组件。
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
type TFormElementMap = {
|
|
105
|
+
[valueType]: FormItemComponent;
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### elementMap
|
|
110
|
+
|
|
111
|
+
- 展示原子组件集合。
|
|
112
|
+
- 在展示的地方使用,如:Table、Desc 等
|
|
113
|
+
- 根据 column 中的 valueType 从 elementMap 查找对应的组件。
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
type TElementMap = {
|
|
117
|
+
[valueType]: Component;
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
注:formElementMap 与 elementMap 中的 valueType 应该是像对应的,即:每一类 valueType 都有相对应的录入组件与展示组件。
|
|
122
|
+
|
|
123
|
+
## 原子组件
|
|
124
|
+
|
|
125
|
+
原子信息组件,统一 ProForm、ProTable 等组件里面的字段定义。valueType 是 pro 的灵魂,会根据 valueType 来映射成不同的组件。
|
|
126
|
+
|
|
127
|
+
以下是支持的常见表单项(具体已实际注册值为准):
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
export type TDefaultValueType =
|
|
131
|
+
| "text"
|
|
132
|
+
| "textarea"
|
|
133
|
+
| "password"
|
|
134
|
+
| "digit" // 数字输入
|
|
135
|
+
| "date"
|
|
136
|
+
| "dateRange"
|
|
137
|
+
| "time"
|
|
138
|
+
| "timeRange"
|
|
139
|
+
| "select"
|
|
140
|
+
| "treeSelect"
|
|
141
|
+
| "checkbox"
|
|
142
|
+
| "radio"
|
|
143
|
+
| "slider"
|
|
144
|
+
| "switch"
|
|
145
|
+
| "rate"
|
|
146
|
+
| "cascader";
|
|
147
|
+
|
|
148
|
+
export type TValueType = TDefaultValueType | string;
|
|
11
149
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,8 @@ declare type TColumn = {
|
|
|
51
51
|
formFieldProps?: Record<string, any>;
|
|
52
52
|
search?: boolean;
|
|
53
53
|
extra?: {
|
|
54
|
-
desc?: any
|
|
54
|
+
desc?: Record<string, any>;
|
|
55
|
+
col?: Record<string, any>;
|
|
55
56
|
} & Record<string, any>;
|
|
56
57
|
};
|
|
57
58
|
declare type TColumns = TColumn[];
|
|
@@ -295,11 +296,10 @@ declare const useModuleEvent: (cb: (action: TActionEvent) => void) => void;
|
|
|
295
296
|
declare const useDoneRequestActor: (actors: (IRequestActor | string)[], callback: (actor: IRequestActor) => void) => void;
|
|
296
297
|
declare const useFailedRequestActor: (actors: (IRequestActor | string)[], callback: (actor: IRequestActor) => void) => void;
|
|
297
298
|
declare const useComposeRequestActor: (actors: (IRequestActor | string)[], options: {
|
|
298
|
-
onStart?: ((actor: IRequestActor) => void) | undefined;
|
|
299
299
|
onSuccess?: ((actor: IRequestActor) => void) | undefined;
|
|
300
300
|
onFailed?: ((actor: IRequestActor) => void) | undefined;
|
|
301
301
|
onFinish?: ((actor: IRequestActor) => void) | undefined;
|
|
302
|
-
}, cancelWhileUnmount?: boolean
|
|
302
|
+
}, cancelWhileUnmount?: boolean) => void;
|
|
303
303
|
|
|
304
304
|
interface IProTableProvideExtra extends Record<string, any> {
|
|
305
305
|
}
|
|
@@ -389,7 +389,7 @@ declare const proTableProps: () => {
|
|
|
389
389
|
};
|
|
390
390
|
};
|
|
391
391
|
declare type ProTableProps = Partial<ExtractPropTypes<ReturnType<typeof proTableProps>>>;
|
|
392
|
-
declare const createTable: (Table: any, Props?: any, tableMethods?: string[]
|
|
392
|
+
declare const createTable: (Table: any, Props?: any, tableMethods?: string[]) => any;
|
|
393
393
|
|
|
394
394
|
declare type TPageState = {
|
|
395
395
|
page: number;
|
|
@@ -415,6 +415,7 @@ interface ICurdState extends Record<string, any> {
|
|
|
415
415
|
interface ICurdOperateOpts extends Omit<IRequestOpts, "actor" | "action">, Omit<IOperateItem, "value"> {
|
|
416
416
|
action: ICurdAction;
|
|
417
417
|
actor?: IRequestActor;
|
|
418
|
+
tableOperate?: boolean;
|
|
418
419
|
}
|
|
419
420
|
declare type TCurdActionEvent = {
|
|
420
421
|
action: ICurdAction;
|
|
@@ -491,6 +492,7 @@ interface IProCurdProvide {
|
|
|
491
492
|
tableColumns: Ref<TColumns>;
|
|
492
493
|
searchColumns: Ref<TColumns>;
|
|
493
494
|
sendCurdEvent: (event: TCurdActionEvent) => void;
|
|
495
|
+
operates: ICurdOperateOpts[];
|
|
494
496
|
getOperate: (action: ICurdAction) => ICurdOperateOpts | undefined;
|
|
495
497
|
refreshList: (extra?: Record<string, any>) => void;
|
|
496
498
|
/******************子组件参数*******************/
|
|
@@ -503,7 +505,7 @@ declare const useProCurd: <T extends IProCurdProvide>() => T;
|
|
|
503
505
|
declare const provideProCurd: (ctx: IProCurdProvide) => void;
|
|
504
506
|
/************************************ 常量 *************************************/
|
|
505
507
|
/**
|
|
506
|
-
* curd 5
|
|
508
|
+
* curd 5种基础Action
|
|
507
509
|
*/
|
|
508
510
|
declare enum CurdAction {
|
|
509
511
|
LIST = "LIST",
|
|
@@ -512,9 +514,9 @@ declare enum CurdAction {
|
|
|
512
514
|
EDIT = "EDIT",
|
|
513
515
|
DELETE = "DELETE"
|
|
514
516
|
}
|
|
515
|
-
declare type ICurdAction = keyof typeof CurdAction;
|
|
517
|
+
declare type ICurdAction = keyof typeof CurdAction | string;
|
|
516
518
|
/**
|
|
517
|
-
*
|
|
519
|
+
* CurdAction 的子事件
|
|
518
520
|
*/
|
|
519
521
|
declare enum CurdSubAction {
|
|
520
522
|
EMIT = "EMIT",
|
|
@@ -532,7 +534,7 @@ declare enum CurdCurrentMode {
|
|
|
532
534
|
EDIT = "EDIT",
|
|
533
535
|
DETAIL = "DETAIL"
|
|
534
536
|
}
|
|
535
|
-
declare type ICurdCurrentMode = keyof typeof CurdCurrentMode;
|
|
537
|
+
declare type ICurdCurrentMode = keyof typeof CurdCurrentMode | string;
|
|
536
538
|
/**
|
|
537
539
|
* curd add 模式下 标记 "确定" "确定并继续" 触发
|
|
538
540
|
*/
|
|
@@ -597,7 +599,7 @@ declare const proCurdAddOrEditProps: () => {
|
|
|
597
599
|
};
|
|
598
600
|
};
|
|
599
601
|
declare type ProCurdAddOrEditProps = Partial<ExtractPropTypes<ReturnType<typeof proCurdAddOrEditProps>>>;
|
|
600
|
-
declare const createCurdForm: (Form: any, Button: any, convertFormProps?: ((curdState: ICurdState) => Record<string, any>) | undefined, formMethods?: string[]
|
|
602
|
+
declare const createCurdForm: (Form: any, Button: any, convertFormProps?: ((curdState: ICurdState) => Record<string, any>) | undefined, formMethods?: string[]) => any;
|
|
601
603
|
|
|
602
604
|
declare const proCurdListProps: () => {
|
|
603
605
|
/**
|
|
@@ -874,9 +876,7 @@ declare const createFormItemCompFn: <T extends FormItemProps>(FormItem: any, con
|
|
|
874
876
|
slots: {
|
|
875
877
|
type: ObjectConstructor;
|
|
876
878
|
};
|
|
877
|
-
}>> & Record<string, any> extends
|
|
878
|
-
[x: string]: unknown;
|
|
879
|
-
}> ? ExtractPropTypes<T & Partial<ExtractPropTypes<{
|
|
879
|
+
}>> & Record<string, any> extends infer T_1 ? T_1 extends T & Partial<ExtractPropTypes<{
|
|
880
880
|
readonly: {
|
|
881
881
|
type: BooleanConstructor;
|
|
882
882
|
default: undefined;
|
|
@@ -890,21 +890,9 @@ declare const createFormItemCompFn: <T extends FormItemProps>(FormItem: any, con
|
|
|
890
890
|
slots: {
|
|
891
891
|
type: ObjectConstructor;
|
|
892
892
|
};
|
|
893
|
-
}>> & Record<string, any
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
default: undefined;
|
|
897
|
-
};
|
|
898
|
-
fieldProps: {
|
|
899
|
-
type: ObjectConstructor;
|
|
900
|
-
};
|
|
901
|
-
showProps: {
|
|
902
|
-
type: ObjectConstructor;
|
|
903
|
-
};
|
|
904
|
-
slots: {
|
|
905
|
-
type: ObjectConstructor;
|
|
906
|
-
};
|
|
907
|
-
}>> & Record<string, any>>, vue.ExtractDefaultPropTypes<T & Partial<ExtractPropTypes<{
|
|
893
|
+
}>> & Record<string, any> ? T_1 extends vue.ComponentPropsOptions<{
|
|
894
|
+
[x: string]: unknown;
|
|
895
|
+
}> ? ExtractPropTypes<T_1> : T_1 : never : never>, vue.ExtractDefaultPropTypes<T & Partial<ExtractPropTypes<{
|
|
908
896
|
readonly: {
|
|
909
897
|
type: BooleanConstructor;
|
|
910
898
|
default: undefined;
|
|
@@ -944,7 +932,7 @@ declare const createFormList: (FormItem: any) => any;
|
|
|
944
932
|
* @param showState
|
|
945
933
|
* @param showStateRules
|
|
946
934
|
*/
|
|
947
|
-
declare const getValidValues: (values: Record<string, any>, showState?: BooleanObjType
|
|
935
|
+
declare const getValidValues: (values: Record<string, any>, showState?: BooleanObjType, showStateRules?: BooleanRulesObjType) => Record<string, any>;
|
|
948
936
|
/**
|
|
949
937
|
* string类型的path转为arr
|
|
950
938
|
* @param path
|