@vue-start/pro 0.4.8 → 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
  */
@@ -613,6 +616,13 @@ declare const proCurdListProps: () => {
613
616
  tableProps: {
614
617
  type: PropType<Record<string, any>>;
615
618
  };
619
+ paginationProps: {
620
+ type: PropType<Record<string, any>>;
621
+ };
622
+ showPagination: {
623
+ type: BooleanConstructor;
624
+ default: boolean;
625
+ };
616
626
  pageState: {
617
627
  type: PropType<TPageState>;
618
628
  };
@@ -632,6 +642,13 @@ declare const createCurdList: (SearchForm: any, Table: any) => vue.DefineCompone
632
642
  tableProps: {
633
643
  type: PropType<Record<string, any>>;
634
644
  };
645
+ paginationProps: {
646
+ type: PropType<Record<string, any>>;
647
+ };
648
+ showPagination: {
649
+ type: BooleanConstructor;
650
+ default: boolean;
651
+ };
635
652
  pageState: {
636
653
  type: PropType<TPageState>;
637
654
  };
@@ -649,6 +666,13 @@ declare const createCurdList: (SearchForm: any, Table: any) => vue.DefineCompone
649
666
  tableProps: {
650
667
  type: PropType<Record<string, any>>;
651
668
  };
669
+ paginationProps: {
670
+ type: PropType<Record<string, any>>;
671
+ };
672
+ showPagination: {
673
+ type: BooleanConstructor;
674
+ default: boolean;
675
+ };
652
676
  pageState: {
653
677
  type: PropType<TPageState>;
654
678
  };
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 () {
@@ -1820,6 +1811,14 @@ var proCurdListProps = function proCurdListProps() {
1820
1811
  tableProps: {
1821
1812
  type: Object
1822
1813
  },
1814
+ //pagination是否展示
1815
+ paginationProps: {
1816
+ type: Object
1817
+ },
1818
+ showPagination: {
1819
+ type: Boolean,
1820
+ "default": true
1821
+ },
1823
1822
  //pageState
1824
1823
  pageState: {
1825
1824
  type: Object
@@ -1839,8 +1838,8 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1839
1838
  curdState = _useProCurd.curdState,
1840
1839
  searchColumns = _useProCurd.searchColumns,
1841
1840
  tableColumns = _useProCurd.tableColumns,
1842
- getOperate = _useProCurd.getOperate,
1843
- sendCurdEvent = _useProCurd.sendCurdEvent;
1841
+ sendCurdEvent = _useProCurd.sendCurdEvent,
1842
+ operates = _useProCurd.operates;
1844
1843
  /******************* search pagination ********************/
1845
1844
 
1846
1845
 
@@ -1863,32 +1862,27 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1863
1862
  /******************* table ********************/
1864
1863
 
1865
1864
 
1866
- var createTableItem = function createTableItem(action) {
1867
- var operate = getOperate(action);
1868
-
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) {
1869
1869
  var item = _objectSpread2(_objectSpread2({}, pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
1870
1870
  show: !isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
1871
- value: action
1871
+ value: operate.action
1872
1872
  });
1873
1873
 
1874
1874
  if (!item.onClick) {
1875
- return _objectSpread2(_objectSpread2({}, item), {}, {
1876
- onClick: function onClick(record) {
1877
- //默认发送事件
1878
- sendCurdEvent({
1879
- action: action,
1880
- type: CurdSubAction.EMIT,
1881
- record: record
1882
- });
1883
- }
1884
- });
1875
+ item.onClick = function (record) {
1876
+ sendCurdEvent({
1877
+ action: operate.action,
1878
+ type: CurdSubAction.EMIT,
1879
+ record: record
1880
+ });
1881
+ };
1885
1882
  }
1886
1883
 
1887
1884
  return item;
1888
- }; //table操作栏 items
1889
-
1890
-
1891
- var tableOperateItems = [createTableItem(CurdAction.DETAIL), createTableItem(CurdAction.EDIT), createTableItem(CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
1885
+ }); //新配置的operate item,添加默认发送事件方法
1892
1886
 
1893
1887
  var convertOperateItems = function convertOperateItems(list) {
1894
1888
  return map(list, function (item) {
@@ -1946,7 +1940,7 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1946
1940
  "default": function _default() {
1947
1941
  return [props.extraInSearch && extra];
1948
1942
  }
1949
- }, (_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.slots)), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots.table ? slots.table(rewriteTableProps) : createVNode(Table, rewriteTableProps, tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), createVNode("div", {
1943
+ }, (_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.slots)), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots.table ? slots.table(rewriteTableProps) : createVNode(Table, rewriteTableProps, tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), props.showPagination && createVNode("div", {
1950
1944
  "class": "pro-curd-list-footer"
1951
1945
  }, [(_slots$footerStart = slots.footerStart) === null || _slots$footerStart === void 0 ? void 0 : _slots$footerStart.call(slots), (_slots$pagination = slots.pagination) === null || _slots$pagination === void 0 ? void 0 : _slots$pagination.call(slots, pageState, (_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total, handleSearch), (_slots$footerEnd = slots.footerEnd) === null || _slots$footerEnd === void 0 ? void 0 : _slots$footerEnd.call(slots)]), (_slots$end = slots.end) === null || _slots$end === void 0 ? void 0 : _slots$end.call(slots)]);
1952
1946
  };
@@ -2073,24 +2067,24 @@ var provideProForm = function provideProForm(ctx) {
2073
2067
 
2074
2068
  var proFormProps = function proFormProps() {
2075
2069
  return {
2076
- /**
2077
- * 同 antd 或 element form中的model
2070
+ /**
2071
+ * 同 antd 或 element form中的model
2078
2072
  */
2079
2073
  model: {
2080
2074
  type: Object
2081
2075
  },
2082
2076
 
2083
- /**
2084
- * 子组件是否只读样式
2077
+ /**
2078
+ * 子组件是否只读样式
2085
2079
  */
2086
2080
  readonly: {
2087
2081
  type: Boolean,
2088
2082
  "default": undefined
2089
2083
  },
2090
2084
 
2091
- /**
2092
- * FormComponent 根据此项来确定组件是否显示
2093
- * rules 根据rules中方法生成showState对象
2085
+ /**
2086
+ * FormComponent 根据此项来确定组件是否显示
2087
+ * rules 根据rules中方法生成showState对象
2094
2088
  */
2095
2089
  showState: {
2096
2090
  type: Object
@@ -2099,8 +2093,8 @@ var proFormProps = function proFormProps() {
2099
2093
  type: Object
2100
2094
  },
2101
2095
 
2102
- /**
2103
- * 是否只读
2096
+ /**
2097
+ * 是否只读
2104
2098
  */
2105
2099
  readonlyState: {
2106
2100
  type: Object
@@ -2109,8 +2103,8 @@ var proFormProps = function proFormProps() {
2109
2103
  type: Object
2110
2104
  },
2111
2105
 
2112
- /**
2113
- * 是否disabled
2106
+ /**
2107
+ * 是否disabled
2114
2108
  */
2115
2109
  disableState: {
2116
2110
  type: Object
@@ -2119,8 +2113,8 @@ var proFormProps = function proFormProps() {
2119
2113
  type: Object
2120
2114
  },
2121
2115
 
2122
- /**
2123
- *
2116
+ /**
2117
+ *
2124
2118
  */
2125
2119
  columns: {
2126
2120
  type: Array
@@ -2129,30 +2123,30 @@ var proFormProps = function proFormProps() {
2129
2123
  type: Object
2130
2124
  },
2131
2125
 
2132
- /**
2133
- * 展示控件集合,readonly模式下使用这些组件渲染
2126
+ /**
2127
+ * 展示控件集合,readonly模式下使用这些组件渲染
2134
2128
  */
2135
2129
  elementMap: {
2136
2130
  type: Object
2137
2131
  },
2138
2132
 
2139
- /**
2140
- * 录入控件集合
2133
+ /**
2134
+ * 录入控件集合
2141
2135
  */
2142
2136
  formElementMap: {
2143
2137
  type: Object
2144
2138
  },
2145
2139
 
2146
- /**
2147
- * 是否启用rules验证
2140
+ /**
2141
+ * 是否启用rules验证
2148
2142
  */
2149
2143
  needRules: {
2150
2144
  type: Boolean,
2151
2145
  "default": true
2152
2146
  },
2153
2147
 
2154
- /**
2155
- * provide传递
2148
+ /**
2149
+ * provide传递
2156
2150
  */
2157
2151
  provideExtra: {
2158
2152
  type: Object
@@ -2498,8 +2492,8 @@ var proTableProps = function proTableProps() {
2498
2492
  type: String
2499
2493
  },
2500
2494
 
2501
- /**
2502
- * 公共column,会merge到columns item中
2495
+ /**
2496
+ * 公共column,会merge到columns item中
2503
2497
  */
2504
2498
  column: {
2505
2499
  type: Object
@@ -2512,29 +2506,29 @@ var proTableProps = function proTableProps() {
2512
2506
  type: Object
2513
2507
  },
2514
2508
 
2515
- /**
2516
- * 展示控件集合,readonly模式下使用这些组件渲染
2509
+ /**
2510
+ * 展示控件集合,readonly模式下使用这些组件渲染
2517
2511
  */
2518
2512
  elementMap: {
2519
2513
  type: Object
2520
2514
  },
2521
2515
 
2522
- /**
2523
- * 序号
2516
+ /**
2517
+ * 序号
2524
2518
  */
2525
2519
  serialNumber: {
2526
2520
  type: Boolean
2527
2521
  },
2528
2522
 
2529
- /**
2530
- * 分页
2523
+ /**
2524
+ * 分页
2531
2525
  */
2532
2526
  paginationState: {
2533
2527
  type: Object
2534
2528
  },
2535
2529
 
2536
- /**
2537
- * provide传递
2530
+ /**
2531
+ * provide传递
2538
2532
  */
2539
2533
  provideExtra: {
2540
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 () {
@@ -1824,6 +1815,14 @@ var proCurdListProps = function proCurdListProps() {
1824
1815
  tableProps: {
1825
1816
  type: Object
1826
1817
  },
1818
+ //pagination是否展示
1819
+ paginationProps: {
1820
+ type: Object
1821
+ },
1822
+ showPagination: {
1823
+ type: Boolean,
1824
+ "default": true
1825
+ },
1827
1826
  //pageState
1828
1827
  pageState: {
1829
1828
  type: Object
@@ -1843,8 +1842,8 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1843
1842
  curdState = _useProCurd.curdState,
1844
1843
  searchColumns = _useProCurd.searchColumns,
1845
1844
  tableColumns = _useProCurd.tableColumns,
1846
- getOperate = _useProCurd.getOperate,
1847
- sendCurdEvent = _useProCurd.sendCurdEvent;
1845
+ sendCurdEvent = _useProCurd.sendCurdEvent,
1846
+ operates = _useProCurd.operates;
1848
1847
  /******************* search pagination ********************/
1849
1848
 
1850
1849
 
@@ -1867,32 +1866,27 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1867
1866
  /******************* table ********************/
1868
1867
 
1869
1868
 
1870
- var createTableItem = function createTableItem(action) {
1871
- var operate = getOperate(action);
1872
-
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) {
1873
1873
  var item = _objectSpread2(_objectSpread2({}, lodash.pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
1874
1874
  show: !lodash.isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
1875
- value: action
1875
+ value: operate.action
1876
1876
  });
1877
1877
 
1878
1878
  if (!item.onClick) {
1879
- return _objectSpread2(_objectSpread2({}, item), {}, {
1880
- onClick: function onClick(record) {
1881
- //默认发送事件
1882
- sendCurdEvent({
1883
- action: action,
1884
- type: exports.CurdSubAction.EMIT,
1885
- record: record
1886
- });
1887
- }
1888
- });
1879
+ item.onClick = function (record) {
1880
+ sendCurdEvent({
1881
+ action: operate.action,
1882
+ type: exports.CurdSubAction.EMIT,
1883
+ record: record
1884
+ });
1885
+ };
1889
1886
  }
1890
1887
 
1891
1888
  return item;
1892
- }; //table操作栏 items
1893
-
1894
-
1895
- var tableOperateItems = [createTableItem(exports.CurdAction.DETAIL), createTableItem(exports.CurdAction.EDIT), createTableItem(exports.CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
1889
+ }); //新配置的operate item,添加默认发送事件方法
1896
1890
 
1897
1891
  var convertOperateItems = function convertOperateItems(list) {
1898
1892
  return lodash.map(list, function (item) {
@@ -1950,7 +1944,7 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1950
1944
  "default": function _default() {
1951
1945
  return [props.extraInSearch && extra];
1952
1946
  }
1953
- }, (_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.slots)), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots.table ? slots.table(rewriteTableProps) : vue.createVNode(Table, rewriteTableProps, tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), vue.createVNode("div", {
1947
+ }, (_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.slots)), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots.table ? slots.table(rewriteTableProps) : vue.createVNode(Table, rewriteTableProps, tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), props.showPagination && vue.createVNode("div", {
1954
1948
  "class": "pro-curd-list-footer"
1955
1949
  }, [(_slots$footerStart = slots.footerStart) === null || _slots$footerStart === void 0 ? void 0 : _slots$footerStart.call(slots), (_slots$pagination = slots.pagination) === null || _slots$pagination === void 0 ? void 0 : _slots$pagination.call(slots, pageState, (_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total, handleSearch), (_slots$footerEnd = slots.footerEnd) === null || _slots$footerEnd === void 0 ? void 0 : _slots$footerEnd.call(slots)]), (_slots$end = slots.end) === null || _slots$end === void 0 ? void 0 : _slots$end.call(slots)]);
1956
1950
  };
@@ -2077,24 +2071,24 @@ var provideProForm = function provideProForm(ctx) {
2077
2071
 
2078
2072
  var proFormProps = function proFormProps() {
2079
2073
  return {
2080
- /**
2081
- * 同 antd 或 element form中的model
2074
+ /**
2075
+ * 同 antd 或 element form中的model
2082
2076
  */
2083
2077
  model: {
2084
2078
  type: Object
2085
2079
  },
2086
2080
 
2087
- /**
2088
- * 子组件是否只读样式
2081
+ /**
2082
+ * 子组件是否只读样式
2089
2083
  */
2090
2084
  readonly: {
2091
2085
  type: Boolean,
2092
2086
  "default": undefined
2093
2087
  },
2094
2088
 
2095
- /**
2096
- * FormComponent 根据此项来确定组件是否显示
2097
- * rules 根据rules中方法生成showState对象
2089
+ /**
2090
+ * FormComponent 根据此项来确定组件是否显示
2091
+ * rules 根据rules中方法生成showState对象
2098
2092
  */
2099
2093
  showState: {
2100
2094
  type: Object
@@ -2103,8 +2097,8 @@ var proFormProps = function proFormProps() {
2103
2097
  type: Object
2104
2098
  },
2105
2099
 
2106
- /**
2107
- * 是否只读
2100
+ /**
2101
+ * 是否只读
2108
2102
  */
2109
2103
  readonlyState: {
2110
2104
  type: Object
@@ -2113,8 +2107,8 @@ var proFormProps = function proFormProps() {
2113
2107
  type: Object
2114
2108
  },
2115
2109
 
2116
- /**
2117
- * 是否disabled
2110
+ /**
2111
+ * 是否disabled
2118
2112
  */
2119
2113
  disableState: {
2120
2114
  type: Object
@@ -2123,8 +2117,8 @@ var proFormProps = function proFormProps() {
2123
2117
  type: Object
2124
2118
  },
2125
2119
 
2126
- /**
2127
- *
2120
+ /**
2121
+ *
2128
2122
  */
2129
2123
  columns: {
2130
2124
  type: Array
@@ -2133,30 +2127,30 @@ var proFormProps = function proFormProps() {
2133
2127
  type: Object
2134
2128
  },
2135
2129
 
2136
- /**
2137
- * 展示控件集合,readonly模式下使用这些组件渲染
2130
+ /**
2131
+ * 展示控件集合,readonly模式下使用这些组件渲染
2138
2132
  */
2139
2133
  elementMap: {
2140
2134
  type: Object
2141
2135
  },
2142
2136
 
2143
- /**
2144
- * 录入控件集合
2137
+ /**
2138
+ * 录入控件集合
2145
2139
  */
2146
2140
  formElementMap: {
2147
2141
  type: Object
2148
2142
  },
2149
2143
 
2150
- /**
2151
- * 是否启用rules验证
2144
+ /**
2145
+ * 是否启用rules验证
2152
2146
  */
2153
2147
  needRules: {
2154
2148
  type: Boolean,
2155
2149
  "default": true
2156
2150
  },
2157
2151
 
2158
- /**
2159
- * provide传递
2152
+ /**
2153
+ * provide传递
2160
2154
  */
2161
2155
  provideExtra: {
2162
2156
  type: Object
@@ -2502,8 +2496,8 @@ var proTableProps = function proTableProps() {
2502
2496
  type: String
2503
2497
  },
2504
2498
 
2505
- /**
2506
- * 公共column,会merge到columns item中
2499
+ /**
2500
+ * 公共column,会merge到columns item中
2507
2501
  */
2508
2502
  column: {
2509
2503
  type: Object
@@ -2516,29 +2510,29 @@ var proTableProps = function proTableProps() {
2516
2510
  type: Object
2517
2511
  },
2518
2512
 
2519
- /**
2520
- * 展示控件集合,readonly模式下使用这些组件渲染
2513
+ /**
2514
+ * 展示控件集合,readonly模式下使用这些组件渲染
2521
2515
  */
2522
2516
  elementMap: {
2523
2517
  type: Object
2524
2518
  },
2525
2519
 
2526
- /**
2527
- * 序号
2520
+ /**
2521
+ * 序号
2528
2522
  */
2529
2523
  serialNumber: {
2530
2524
  type: Boolean
2531
2525
  },
2532
2526
 
2533
- /**
2534
- * 分页
2527
+ /**
2528
+ * 分页
2535
2529
  */
2536
2530
  paginationState: {
2537
2531
  type: Object
2538
2532
  },
2539
2533
 
2540
- /**
2541
- * provide传递
2534
+ /**
2535
+ * provide传递
2542
2536
  */
2543
2537
  provideExtra: {
2544
2538
  type: Object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-start/pro",
3
- "version": "0.4.8",
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": "abed29975a9db75dcc076220d3ce0c6ba5df98b6"
35
+ "gitHead": "8df4a1e0344f286bdbd7e5a071794d3e093f1a69"
36
36
  }