@vue-start/pro 0.4.9 → 0.4.10

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 CHANGED
@@ -1,11 +1,149 @@
1
- # `pro`
1
+ # pro 系列组件
2
2
 
3
- > TODO: description
3
+ > 基于 ant-design-vue 和 element-plus 组件库,提供更高程度的抽象,提供更上层的设计规范,并且对应提供相应的组件使得开发者可以快速搭建出高质量的页面。
4
4
 
5
- ## Usage
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
- // TODO: DEMONSTRATE API
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[];
@@ -415,6 +416,7 @@ interface ICurdState extends Record<string, any> {
415
416
  interface ICurdOperateOpts extends Omit<IRequestOpts, "actor" | "action">, Omit<IOperateItem, "value"> {
416
417
  action: ICurdAction;
417
418
  actor?: IRequestActor;
419
+ tableOperate?: boolean;
418
420
  }
419
421
  declare type TCurdActionEvent = {
420
422
  action: ICurdAction;
@@ -491,6 +493,7 @@ interface IProCurdProvide {
491
493
  tableColumns: Ref<TColumns>;
492
494
  searchColumns: Ref<TColumns>;
493
495
  sendCurdEvent: (event: TCurdActionEvent) => void;
496
+ operates: ICurdOperateOpts[];
494
497
  getOperate: (action: ICurdAction) => ICurdOperateOpts | undefined;
495
498
  refreshList: (extra?: Record<string, any>) => void;
496
499
  /******************子组件参数*******************/
@@ -503,7 +506,7 @@ declare const useProCurd: <T extends IProCurdProvide>() => T;
503
506
  declare const provideProCurd: (ctx: IProCurdProvide) => void;
504
507
  /************************************ 常量 *************************************/
505
508
  /**
506
- * curd 5Action
509
+ * curd 5种基础Action
507
510
  */
508
511
  declare enum CurdAction {
509
512
  LIST = "LIST",
@@ -512,9 +515,9 @@ declare enum CurdAction {
512
515
  EDIT = "EDIT",
513
516
  DELETE = "DELETE"
514
517
  }
515
- declare type ICurdAction = keyof typeof CurdAction;
518
+ declare type ICurdAction = keyof typeof CurdAction | string;
516
519
  /**
517
- * 5种Action 的子事件
520
+ * CurdAction 的子事件
518
521
  */
519
522
  declare enum CurdSubAction {
520
523
  EMIT = "EMIT",
@@ -532,7 +535,7 @@ declare enum CurdCurrentMode {
532
535
  EDIT = "EDIT",
533
536
  DETAIL = "DETAIL"
534
537
  }
535
- declare type ICurdCurrentMode = keyof typeof CurdCurrentMode;
538
+ declare type ICurdCurrentMode = keyof typeof CurdCurrentMode | string;
536
539
  /**
537
540
  * curd add 模式下 标记 "确定" "确定并继续" 触发
538
541
  */
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, createVNode, mergeProps, isVNode, computed, h, inject, reactive, Fragment, provide, ref } from 'vue';
2
- import { map, isString, forEach, reduce, size, get, set, pick, omit, isArray, some, keys, isFunction, head, isObject, filter as filter$1, split, isEmpty, mergeWith, sortBy, concat, isUndefined, debounce, clone, isBoolean } from 'lodash';
2
+ import { map, isString, forEach, reduce, size, get, set, pick, omit, isArray, some, keys, isFunction, head, isObject, filter as filter$1, split, isEmpty, mergeWith, sortBy, isUndefined, concat, debounce, clone, isBoolean } from 'lodash';
3
3
  import { filter, tap, merge, Subject } from 'rxjs';
4
4
  import { useEffect, setReactiveValue, useWatch } from '@vue-start/hooks';
5
5
  import { useRequestProvide, isFailedRequestActor, isPreRequestActor, isDoneRequestActor } from '@vue-start/request';
@@ -707,7 +707,7 @@ var provideProCurd = function provideProCurd(ctx) {
707
707
  /************************************ 常量 *************************************/
708
708
 
709
709
  /**
710
- * curd 5Action
710
+ * curd 5种基础Action
711
711
  */
712
712
 
713
713
  var CurdAction;
@@ -721,7 +721,7 @@ var CurdAction;
721
721
  })(CurdAction || (CurdAction = {}));
722
722
 
723
723
  /**
724
- * 5种Action 的子事件
724
+ * CurdAction 的子事件
725
725
  */
726
726
  var CurdSubAction;
727
727
 
@@ -999,21 +999,32 @@ var Curd = defineComponent({
999
999
  }; //事件订阅
1000
1000
 
1001
1001
 
1002
- useModuleEvent(function (event) {
1002
+ useModuleEvent(function (_ref3) {
1003
+ var type = _ref3.type,
1004
+ payload = _ref3.payload,
1005
+ source = _ref3.source;
1006
+
1003
1007
  //如果当前event存在source 不处理
1004
- if (event.source) {
1008
+ if (source) {
1005
1009
  return;
1006
1010
  }
1007
1011
 
1008
- var action = event.type;
1009
- var _ref3 = event.payload,
1010
- type = _ref3.type,
1011
- values = _ref3.values,
1012
- record = _ref3.record;
1012
+ var action = type;
1013
+ var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
1014
+
1015
+ if (action === RequestAction.Success) {
1016
+ //覆盖
1017
+ action = get(payload, ["requestOpts", "action"]);
1018
+ subAction = CurdSubAction.SUCCESS;
1019
+ }
1020
+
1021
+ var _ref4 = payload,
1022
+ values = _ref4.values,
1023
+ record = _ref4.record;
1013
1024
 
1014
1025
  switch (action) {
1015
1026
  case CurdAction.LIST:
1016
- if (type === CurdSubAction.EMIT) {
1027
+ if (subAction === CurdSubAction.EMIT) {
1017
1028
  prevListParams = values;
1018
1029
  handleSearch();
1019
1030
  }
@@ -1021,22 +1032,24 @@ var Curd = defineComponent({
1021
1032
  return;
1022
1033
 
1023
1034
  case CurdAction.ADD:
1024
- if (type === CurdSubAction.EXECUTE) {
1035
+ if (subAction === CurdSubAction.EXECUTE) {
1025
1036
  sendRequest(CurdAction.ADD, values, state.detailData);
1026
1037
  }
1027
1038
 
1028
1039
  return;
1029
1040
 
1030
1041
  case CurdAction.EDIT:
1031
- if (type === CurdSubAction.EXECUTE) {
1042
+ if (subAction === CurdSubAction.EXECUTE) {
1032
1043
  sendRequest(CurdAction.EDIT, values, state.detailData);
1033
1044
  }
1034
1045
 
1035
1046
  return;
1036
1047
 
1037
1048
  case CurdAction.DELETE:
1038
- if (type === CurdSubAction.EMIT) {
1049
+ if (subAction === CurdSubAction.EMIT) {
1039
1050
  sendRequest(CurdAction.DELETE, record, props.rowKey);
1051
+ } else if (subAction === CurdSubAction.SUCCESS) {
1052
+ handleSearch();
1040
1053
  }
1041
1054
 
1042
1055
  return;
@@ -1084,6 +1097,7 @@ var Curd = defineComponent({
1084
1097
  //
1085
1098
  sendCurdEvent: sendCurdEvent,
1086
1099
  //
1100
+ operates: props.operates,
1087
1101
  getOperate: getOperate,
1088
1102
  //
1089
1103
  refreshList: handleSearch,
@@ -1110,11 +1124,11 @@ var ProCurd = defineComponent({
1110
1124
  type: Object
1111
1125
  }
1112
1126
  }),
1113
- setup: function setup(props, _ref4) {
1127
+ setup: function setup(props, _ref5) {
1114
1128
  var _curdOperateOpts;
1115
1129
 
1116
- var slots = _ref4.slots,
1117
- expose = _ref4.expose;
1130
+ var slots = _ref5.slots,
1131
+ expose = _ref5.expose;
1118
1132
  var moduleRef = ref();
1119
1133
  var curdRef = ref();
1120
1134
  var curdState = props.curdState || reactive({
@@ -1251,7 +1265,7 @@ var ModalCurd = defineComponent({
1251
1265
  getOperate = _useProCurd.getOperate,
1252
1266
  refreshList = _useProCurd.refreshList;
1253
1267
 
1254
- var pageState = (listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState) || reactive(_objectSpread2({}, defaultPage)); //发送详情接口
1268
+ var pageState = listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState; //发送详情接口
1255
1269
 
1256
1270
  var sendDetailRequest = function sendDetailRequest(record) {
1257
1271
  var operateOpts = getOperate(CurdAction.DETAIL);
@@ -1292,12 +1306,12 @@ var ModalCurd = defineComponent({
1292
1306
  });
1293
1307
  } else if (subAction === CurdSubAction.SUCCESS) {
1294
1308
  //添加成功
1295
- pageState.page = 1; //重置当前页数
1296
- //刷新List
1309
+ if (pageState) {
1310
+ pageState.page = 1; //重置当前页数
1311
+ } //刷新List
1297
1312
 
1298
- refreshList({
1299
- page: 1
1300
- });
1313
+
1314
+ refreshList();
1301
1315
 
1302
1316
  if (curdState.addAction === CurdAddAction.CONTINUE) {
1303
1317
  dispatch({
@@ -1333,13 +1347,6 @@ var ModalCurd = defineComponent({
1333
1347
  }
1334
1348
  };
1335
1349
 
1336
- var dealDelete = function dealDelete(subAction) {
1337
- if (subAction === CurdSubAction.SUCCESS) {
1338
- //刷新列表
1339
- refreshList();
1340
- }
1341
- };
1342
-
1343
1350
  useModuleEvent(function (_ref3) {
1344
1351
  var type = _ref3.type,
1345
1352
  payload = _ref3.payload,
@@ -1375,10 +1382,6 @@ var ModalCurd = defineComponent({
1375
1382
  record: record
1376
1383
  });
1377
1384
  break;
1378
-
1379
- case CurdAction.DELETE:
1380
- dealDelete(subAction);
1381
- break;
1382
1385
  }
1383
1386
  });
1384
1387
  return function () {
@@ -1431,8 +1434,7 @@ var PageCurd = defineComponent({
1431
1434
 
1432
1435
  var _useProCurd = useProCurd(),
1433
1436
  rowKey = _useProCurd.rowKey,
1434
- curdState = _useProCurd.curdState,
1435
- refreshList = _useProCurd.refreshList;
1437
+ curdState = _useProCurd.curdState;
1436
1438
 
1437
1439
  var dealList = function dealList(subAction) {
1438
1440
  if (subAction === CurdSubAction.PAGE) {
@@ -1518,13 +1520,6 @@ var PageCurd = defineComponent({
1518
1520
  }
1519
1521
  };
1520
1522
 
1521
- var dealDelete = function dealDelete(subAction) {
1522
- if (subAction === CurdSubAction.SUCCESS) {
1523
- //刷新列表
1524
- refreshList();
1525
- }
1526
- };
1527
-
1528
1523
  useModuleEvent(function (_ref3) {
1529
1524
  var type = _ref3.type,
1530
1525
  payload = _ref3.payload,
@@ -1564,10 +1559,6 @@ var PageCurd = defineComponent({
1564
1559
  record: record
1565
1560
  });
1566
1561
  break;
1567
-
1568
- case CurdAction.DELETE:
1569
- dealDelete(subAction);
1570
- break;
1571
1562
  }
1572
1563
  });
1573
1564
  return function () {
@@ -1847,8 +1838,8 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1847
1838
  curdState = _useProCurd.curdState,
1848
1839
  searchColumns = _useProCurd.searchColumns,
1849
1840
  tableColumns = _useProCurd.tableColumns,
1850
- getOperate = _useProCurd.getOperate,
1851
- sendCurdEvent = _useProCurd.sendCurdEvent;
1841
+ sendCurdEvent = _useProCurd.sendCurdEvent,
1842
+ operates = _useProCurd.operates;
1852
1843
  /******************* search pagination ********************/
1853
1844
 
1854
1845
 
@@ -1871,32 +1862,27 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1871
1862
  /******************* table ********************/
1872
1863
 
1873
1864
 
1874
- var createTableItem = function createTableItem(action) {
1875
- var operate = getOperate(action);
1876
-
1865
+ var tableOperateItems = map(filter$1(operates, function (item) {
1866
+ var action = item.action;
1867
+ return action === CurdAction.DETAIL || action === CurdAction.EDIT || action === CurdAction.DELETE || item.tableOperate;
1868
+ }), function (operate) {
1877
1869
  var item = _objectSpread2(_objectSpread2({}, pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
1878
1870
  show: !isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
1879
- value: action
1871
+ value: operate.action
1880
1872
  });
1881
1873
 
1882
1874
  if (!item.onClick) {
1883
- return _objectSpread2(_objectSpread2({}, item), {}, {
1884
- onClick: function onClick(record) {
1885
- //默认发送事件
1886
- sendCurdEvent({
1887
- action: action,
1888
- type: CurdSubAction.EMIT,
1889
- record: record
1890
- });
1891
- }
1892
- });
1875
+ item.onClick = function (record) {
1876
+ sendCurdEvent({
1877
+ action: operate.action,
1878
+ type: CurdSubAction.EMIT,
1879
+ record: record
1880
+ });
1881
+ };
1893
1882
  }
1894
1883
 
1895
1884
  return item;
1896
- }; //table操作栏 items
1897
-
1898
-
1899
- var tableOperateItems = [createTableItem(CurdAction.DETAIL), createTableItem(CurdAction.EDIT), createTableItem(CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
1885
+ }); //新配置的operate item,添加默认发送事件方法
1900
1886
 
1901
1887
  var convertOperateItems = function convertOperateItems(list) {
1902
1888
  return map(list, function (item) {
@@ -2081,24 +2067,24 @@ var provideProForm = function provideProForm(ctx) {
2081
2067
 
2082
2068
  var proFormProps = function proFormProps() {
2083
2069
  return {
2084
- /**
2085
- * 同 antd 或 element form中的model
2070
+ /**
2071
+ * 同 antd 或 element form中的model
2086
2072
  */
2087
2073
  model: {
2088
2074
  type: Object
2089
2075
  },
2090
2076
 
2091
- /**
2092
- * 子组件是否只读样式
2077
+ /**
2078
+ * 子组件是否只读样式
2093
2079
  */
2094
2080
  readonly: {
2095
2081
  type: Boolean,
2096
2082
  "default": undefined
2097
2083
  },
2098
2084
 
2099
- /**
2100
- * FormComponent 根据此项来确定组件是否显示
2101
- * rules 根据rules中方法生成showState对象
2085
+ /**
2086
+ * FormComponent 根据此项来确定组件是否显示
2087
+ * rules 根据rules中方法生成showState对象
2102
2088
  */
2103
2089
  showState: {
2104
2090
  type: Object
@@ -2107,8 +2093,8 @@ var proFormProps = function proFormProps() {
2107
2093
  type: Object
2108
2094
  },
2109
2095
 
2110
- /**
2111
- * 是否只读
2096
+ /**
2097
+ * 是否只读
2112
2098
  */
2113
2099
  readonlyState: {
2114
2100
  type: Object
@@ -2117,8 +2103,8 @@ var proFormProps = function proFormProps() {
2117
2103
  type: Object
2118
2104
  },
2119
2105
 
2120
- /**
2121
- * 是否disabled
2106
+ /**
2107
+ * 是否disabled
2122
2108
  */
2123
2109
  disableState: {
2124
2110
  type: Object
@@ -2127,8 +2113,8 @@ var proFormProps = function proFormProps() {
2127
2113
  type: Object
2128
2114
  },
2129
2115
 
2130
- /**
2131
- *
2116
+ /**
2117
+ *
2132
2118
  */
2133
2119
  columns: {
2134
2120
  type: Array
@@ -2137,30 +2123,30 @@ var proFormProps = function proFormProps() {
2137
2123
  type: Object
2138
2124
  },
2139
2125
 
2140
- /**
2141
- * 展示控件集合,readonly模式下使用这些组件渲染
2126
+ /**
2127
+ * 展示控件集合,readonly模式下使用这些组件渲染
2142
2128
  */
2143
2129
  elementMap: {
2144
2130
  type: Object
2145
2131
  },
2146
2132
 
2147
- /**
2148
- * 录入控件集合
2133
+ /**
2134
+ * 录入控件集合
2149
2135
  */
2150
2136
  formElementMap: {
2151
2137
  type: Object
2152
2138
  },
2153
2139
 
2154
- /**
2155
- * 是否启用rules验证
2140
+ /**
2141
+ * 是否启用rules验证
2156
2142
  */
2157
2143
  needRules: {
2158
2144
  type: Boolean,
2159
2145
  "default": true
2160
2146
  },
2161
2147
 
2162
- /**
2163
- * provide传递
2148
+ /**
2149
+ * provide传递
2164
2150
  */
2165
2151
  provideExtra: {
2166
2152
  type: Object
@@ -2506,8 +2492,8 @@ var proTableProps = function proTableProps() {
2506
2492
  type: String
2507
2493
  },
2508
2494
 
2509
- /**
2510
- * 公共column,会merge到columns item中
2495
+ /**
2496
+ * 公共column,会merge到columns item中
2511
2497
  */
2512
2498
  column: {
2513
2499
  type: Object
@@ -2520,29 +2506,29 @@ var proTableProps = function proTableProps() {
2520
2506
  type: Object
2521
2507
  },
2522
2508
 
2523
- /**
2524
- * 展示控件集合,readonly模式下使用这些组件渲染
2509
+ /**
2510
+ * 展示控件集合,readonly模式下使用这些组件渲染
2525
2511
  */
2526
2512
  elementMap: {
2527
2513
  type: Object
2528
2514
  },
2529
2515
 
2530
- /**
2531
- * 序号
2516
+ /**
2517
+ * 序号
2532
2518
  */
2533
2519
  serialNumber: {
2534
2520
  type: Boolean
2535
2521
  },
2536
2522
 
2537
- /**
2538
- * 分页
2523
+ /**
2524
+ * 分页
2539
2525
  */
2540
2526
  paginationState: {
2541
2527
  type: Object
2542
2528
  },
2543
2529
 
2544
- /**
2545
- * provide传递
2530
+ /**
2531
+ * provide传递
2546
2532
  */
2547
2533
  provideExtra: {
2548
2534
  type: Object
package/dist/index.js CHANGED
@@ -711,7 +711,7 @@ var provideProCurd = function provideProCurd(ctx) {
711
711
  /************************************ 常量 *************************************/
712
712
 
713
713
  /**
714
- * curd 5Action
714
+ * curd 5种基础Action
715
715
  */
716
716
 
717
717
  exports.CurdAction = void 0;
@@ -725,7 +725,7 @@ exports.CurdAction = void 0;
725
725
  })(exports.CurdAction || (exports.CurdAction = {}));
726
726
 
727
727
  /**
728
- * 5种Action 的子事件
728
+ * CurdAction 的子事件
729
729
  */
730
730
  exports.CurdSubAction = void 0;
731
731
 
@@ -1003,21 +1003,32 @@ var Curd = vue.defineComponent({
1003
1003
  }; //事件订阅
1004
1004
 
1005
1005
 
1006
- useModuleEvent(function (event) {
1006
+ useModuleEvent(function (_ref3) {
1007
+ var type = _ref3.type,
1008
+ payload = _ref3.payload,
1009
+ source = _ref3.source;
1010
+
1007
1011
  //如果当前event存在source 不处理
1008
- if (event.source) {
1012
+ if (source) {
1009
1013
  return;
1010
1014
  }
1011
1015
 
1012
- var action = event.type;
1013
- var _ref3 = event.payload,
1014
- type = _ref3.type,
1015
- values = _ref3.values,
1016
- record = _ref3.record;
1016
+ var action = type;
1017
+ var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
1018
+
1019
+ if (action === RequestAction.Success) {
1020
+ //覆盖
1021
+ action = lodash.get(payload, ["requestOpts", "action"]);
1022
+ subAction = exports.CurdSubAction.SUCCESS;
1023
+ }
1024
+
1025
+ var _ref4 = payload,
1026
+ values = _ref4.values,
1027
+ record = _ref4.record;
1017
1028
 
1018
1029
  switch (action) {
1019
1030
  case exports.CurdAction.LIST:
1020
- if (type === exports.CurdSubAction.EMIT) {
1031
+ if (subAction === exports.CurdSubAction.EMIT) {
1021
1032
  prevListParams = values;
1022
1033
  handleSearch();
1023
1034
  }
@@ -1025,22 +1036,24 @@ var Curd = vue.defineComponent({
1025
1036
  return;
1026
1037
 
1027
1038
  case exports.CurdAction.ADD:
1028
- if (type === exports.CurdSubAction.EXECUTE) {
1039
+ if (subAction === exports.CurdSubAction.EXECUTE) {
1029
1040
  sendRequest(exports.CurdAction.ADD, values, state.detailData);
1030
1041
  }
1031
1042
 
1032
1043
  return;
1033
1044
 
1034
1045
  case exports.CurdAction.EDIT:
1035
- if (type === exports.CurdSubAction.EXECUTE) {
1046
+ if (subAction === exports.CurdSubAction.EXECUTE) {
1036
1047
  sendRequest(exports.CurdAction.EDIT, values, state.detailData);
1037
1048
  }
1038
1049
 
1039
1050
  return;
1040
1051
 
1041
1052
  case exports.CurdAction.DELETE:
1042
- if (type === exports.CurdSubAction.EMIT) {
1053
+ if (subAction === exports.CurdSubAction.EMIT) {
1043
1054
  sendRequest(exports.CurdAction.DELETE, record, props.rowKey);
1055
+ } else if (subAction === exports.CurdSubAction.SUCCESS) {
1056
+ handleSearch();
1044
1057
  }
1045
1058
 
1046
1059
  return;
@@ -1088,6 +1101,7 @@ var Curd = vue.defineComponent({
1088
1101
  //
1089
1102
  sendCurdEvent: sendCurdEvent,
1090
1103
  //
1104
+ operates: props.operates,
1091
1105
  getOperate: getOperate,
1092
1106
  //
1093
1107
  refreshList: handleSearch,
@@ -1114,11 +1128,11 @@ var ProCurd = vue.defineComponent({
1114
1128
  type: Object
1115
1129
  }
1116
1130
  }),
1117
- setup: function setup(props, _ref4) {
1131
+ setup: function setup(props, _ref5) {
1118
1132
  var _curdOperateOpts;
1119
1133
 
1120
- var slots = _ref4.slots,
1121
- expose = _ref4.expose;
1134
+ var slots = _ref5.slots,
1135
+ expose = _ref5.expose;
1122
1136
  var moduleRef = vue.ref();
1123
1137
  var curdRef = vue.ref();
1124
1138
  var curdState = props.curdState || vue.reactive({
@@ -1255,7 +1269,7 @@ var ModalCurd = vue.defineComponent({
1255
1269
  getOperate = _useProCurd.getOperate,
1256
1270
  refreshList = _useProCurd.refreshList;
1257
1271
 
1258
- var pageState = (listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState) || vue.reactive(_objectSpread2({}, defaultPage)); //发送详情接口
1272
+ var pageState = listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState; //发送详情接口
1259
1273
 
1260
1274
  var sendDetailRequest = function sendDetailRequest(record) {
1261
1275
  var operateOpts = getOperate(exports.CurdAction.DETAIL);
@@ -1296,12 +1310,12 @@ var ModalCurd = vue.defineComponent({
1296
1310
  });
1297
1311
  } else if (subAction === exports.CurdSubAction.SUCCESS) {
1298
1312
  //添加成功
1299
- pageState.page = 1; //重置当前页数
1300
- //刷新List
1313
+ if (pageState) {
1314
+ pageState.page = 1; //重置当前页数
1315
+ } //刷新List
1301
1316
 
1302
- refreshList({
1303
- page: 1
1304
- });
1317
+
1318
+ refreshList();
1305
1319
 
1306
1320
  if (curdState.addAction === exports.CurdAddAction.CONTINUE) {
1307
1321
  dispatch({
@@ -1337,13 +1351,6 @@ var ModalCurd = vue.defineComponent({
1337
1351
  }
1338
1352
  };
1339
1353
 
1340
- var dealDelete = function dealDelete(subAction) {
1341
- if (subAction === exports.CurdSubAction.SUCCESS) {
1342
- //刷新列表
1343
- refreshList();
1344
- }
1345
- };
1346
-
1347
1354
  useModuleEvent(function (_ref3) {
1348
1355
  var type = _ref3.type,
1349
1356
  payload = _ref3.payload,
@@ -1379,10 +1386,6 @@ var ModalCurd = vue.defineComponent({
1379
1386
  record: record
1380
1387
  });
1381
1388
  break;
1382
-
1383
- case exports.CurdAction.DELETE:
1384
- dealDelete(subAction);
1385
- break;
1386
1389
  }
1387
1390
  });
1388
1391
  return function () {
@@ -1435,8 +1438,7 @@ var PageCurd = vue.defineComponent({
1435
1438
 
1436
1439
  var _useProCurd = useProCurd(),
1437
1440
  rowKey = _useProCurd.rowKey,
1438
- curdState = _useProCurd.curdState,
1439
- refreshList = _useProCurd.refreshList;
1441
+ curdState = _useProCurd.curdState;
1440
1442
 
1441
1443
  var dealList = function dealList(subAction) {
1442
1444
  if (subAction === exports.CurdSubAction.PAGE) {
@@ -1522,13 +1524,6 @@ var PageCurd = vue.defineComponent({
1522
1524
  }
1523
1525
  };
1524
1526
 
1525
- var dealDelete = function dealDelete(subAction) {
1526
- if (subAction === exports.CurdSubAction.SUCCESS) {
1527
- //刷新列表
1528
- refreshList();
1529
- }
1530
- };
1531
-
1532
1527
  useModuleEvent(function (_ref3) {
1533
1528
  var type = _ref3.type,
1534
1529
  payload = _ref3.payload,
@@ -1568,10 +1563,6 @@ var PageCurd = vue.defineComponent({
1568
1563
  record: record
1569
1564
  });
1570
1565
  break;
1571
-
1572
- case exports.CurdAction.DELETE:
1573
- dealDelete(subAction);
1574
- break;
1575
1566
  }
1576
1567
  });
1577
1568
  return function () {
@@ -1851,8 +1842,8 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1851
1842
  curdState = _useProCurd.curdState,
1852
1843
  searchColumns = _useProCurd.searchColumns,
1853
1844
  tableColumns = _useProCurd.tableColumns,
1854
- getOperate = _useProCurd.getOperate,
1855
- sendCurdEvent = _useProCurd.sendCurdEvent;
1845
+ sendCurdEvent = _useProCurd.sendCurdEvent,
1846
+ operates = _useProCurd.operates;
1856
1847
  /******************* search pagination ********************/
1857
1848
 
1858
1849
 
@@ -1875,32 +1866,27 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1875
1866
  /******************* table ********************/
1876
1867
 
1877
1868
 
1878
- var createTableItem = function createTableItem(action) {
1879
- var operate = getOperate(action);
1880
-
1869
+ var tableOperateItems = lodash.map(lodash.filter(operates, function (item) {
1870
+ var action = item.action;
1871
+ return action === exports.CurdAction.DETAIL || action === exports.CurdAction.EDIT || action === exports.CurdAction.DELETE || item.tableOperate;
1872
+ }), function (operate) {
1881
1873
  var item = _objectSpread2(_objectSpread2({}, lodash.pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
1882
1874
  show: !lodash.isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
1883
- value: action
1875
+ value: operate.action
1884
1876
  });
1885
1877
 
1886
1878
  if (!item.onClick) {
1887
- return _objectSpread2(_objectSpread2({}, item), {}, {
1888
- onClick: function onClick(record) {
1889
- //默认发送事件
1890
- sendCurdEvent({
1891
- action: action,
1892
- type: exports.CurdSubAction.EMIT,
1893
- record: record
1894
- });
1895
- }
1896
- });
1879
+ item.onClick = function (record) {
1880
+ sendCurdEvent({
1881
+ action: operate.action,
1882
+ type: exports.CurdSubAction.EMIT,
1883
+ record: record
1884
+ });
1885
+ };
1897
1886
  }
1898
1887
 
1899
1888
  return item;
1900
- }; //table操作栏 items
1901
-
1902
-
1903
- var tableOperateItems = [createTableItem(exports.CurdAction.DETAIL), createTableItem(exports.CurdAction.EDIT), createTableItem(exports.CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
1889
+ }); //新配置的operate item,添加默认发送事件方法
1904
1890
 
1905
1891
  var convertOperateItems = function convertOperateItems(list) {
1906
1892
  return lodash.map(list, function (item) {
@@ -2085,24 +2071,24 @@ var provideProForm = function provideProForm(ctx) {
2085
2071
 
2086
2072
  var proFormProps = function proFormProps() {
2087
2073
  return {
2088
- /**
2089
- * 同 antd 或 element form中的model
2074
+ /**
2075
+ * 同 antd 或 element form中的model
2090
2076
  */
2091
2077
  model: {
2092
2078
  type: Object
2093
2079
  },
2094
2080
 
2095
- /**
2096
- * 子组件是否只读样式
2081
+ /**
2082
+ * 子组件是否只读样式
2097
2083
  */
2098
2084
  readonly: {
2099
2085
  type: Boolean,
2100
2086
  "default": undefined
2101
2087
  },
2102
2088
 
2103
- /**
2104
- * FormComponent 根据此项来确定组件是否显示
2105
- * rules 根据rules中方法生成showState对象
2089
+ /**
2090
+ * FormComponent 根据此项来确定组件是否显示
2091
+ * rules 根据rules中方法生成showState对象
2106
2092
  */
2107
2093
  showState: {
2108
2094
  type: Object
@@ -2111,8 +2097,8 @@ var proFormProps = function proFormProps() {
2111
2097
  type: Object
2112
2098
  },
2113
2099
 
2114
- /**
2115
- * 是否只读
2100
+ /**
2101
+ * 是否只读
2116
2102
  */
2117
2103
  readonlyState: {
2118
2104
  type: Object
@@ -2121,8 +2107,8 @@ var proFormProps = function proFormProps() {
2121
2107
  type: Object
2122
2108
  },
2123
2109
 
2124
- /**
2125
- * 是否disabled
2110
+ /**
2111
+ * 是否disabled
2126
2112
  */
2127
2113
  disableState: {
2128
2114
  type: Object
@@ -2131,8 +2117,8 @@ var proFormProps = function proFormProps() {
2131
2117
  type: Object
2132
2118
  },
2133
2119
 
2134
- /**
2135
- *
2120
+ /**
2121
+ *
2136
2122
  */
2137
2123
  columns: {
2138
2124
  type: Array
@@ -2141,30 +2127,30 @@ var proFormProps = function proFormProps() {
2141
2127
  type: Object
2142
2128
  },
2143
2129
 
2144
- /**
2145
- * 展示控件集合,readonly模式下使用这些组件渲染
2130
+ /**
2131
+ * 展示控件集合,readonly模式下使用这些组件渲染
2146
2132
  */
2147
2133
  elementMap: {
2148
2134
  type: Object
2149
2135
  },
2150
2136
 
2151
- /**
2152
- * 录入控件集合
2137
+ /**
2138
+ * 录入控件集合
2153
2139
  */
2154
2140
  formElementMap: {
2155
2141
  type: Object
2156
2142
  },
2157
2143
 
2158
- /**
2159
- * 是否启用rules验证
2144
+ /**
2145
+ * 是否启用rules验证
2160
2146
  */
2161
2147
  needRules: {
2162
2148
  type: Boolean,
2163
2149
  "default": true
2164
2150
  },
2165
2151
 
2166
- /**
2167
- * provide传递
2152
+ /**
2153
+ * provide传递
2168
2154
  */
2169
2155
  provideExtra: {
2170
2156
  type: Object
@@ -2510,8 +2496,8 @@ var proTableProps = function proTableProps() {
2510
2496
  type: String
2511
2497
  },
2512
2498
 
2513
- /**
2514
- * 公共column,会merge到columns item中
2499
+ /**
2500
+ * 公共column,会merge到columns item中
2515
2501
  */
2516
2502
  column: {
2517
2503
  type: Object
@@ -2524,29 +2510,29 @@ var proTableProps = function proTableProps() {
2524
2510
  type: Object
2525
2511
  },
2526
2512
 
2527
- /**
2528
- * 展示控件集合,readonly模式下使用这些组件渲染
2513
+ /**
2514
+ * 展示控件集合,readonly模式下使用这些组件渲染
2529
2515
  */
2530
2516
  elementMap: {
2531
2517
  type: Object
2532
2518
  },
2533
2519
 
2534
- /**
2535
- * 序号
2520
+ /**
2521
+ * 序号
2536
2522
  */
2537
2523
  serialNumber: {
2538
2524
  type: Boolean
2539
2525
  },
2540
2526
 
2541
- /**
2542
- * 分页
2527
+ /**
2528
+ * 分页
2543
2529
  */
2544
2530
  paginationState: {
2545
2531
  type: Object
2546
2532
  },
2547
2533
 
2548
- /**
2549
- * provide传递
2534
+ /**
2535
+ * provide传递
2550
2536
  */
2551
2537
  provideExtra: {
2552
2538
  type: Object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-start/pro",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "> TODO: description",
5
5
  "author": "zx <zxpstudy@163.com>",
6
6
  "homepage": "https://github.com/zxeryu/vue-start#readme",
@@ -32,5 +32,5 @@
32
32
  "vue": ">=3.x",
33
33
  "vue-router": ">=4.x"
34
34
  },
35
- "gitHead": "9075107632a73989f5ade116c22cbc0250f29340"
35
+ "gitHead": "8df4a1e0344f286bdbd7e5a071794d3e093f1a69"
36
36
  }