@teamix/pro 1.4.24 → 1.4.25-bugfix.2
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/dist/pro.all.min.css +1 -0
- package/dist/pro.css +1 -1
- package/dist/pro.js +76829 -56886
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/dist/pro.min.js.LICENSE.txt +13 -6
- package/dist/pro.xconsole.min.css +1 -0
- package/es/actions/base.js +8 -21
- package/es/actions/dialog-component.js +2 -9
- package/es/actions/dialog-form.js +37 -75
- package/es/actions/dialog-info.js +1 -5
- package/es/actions/dialog.d.ts +2 -0
- package/es/actions/dialog.js +57 -94
- package/es/actions/index.d.ts +7 -0
- package/es/actions/index.js +93 -153
- package/es/actions/index.scss +6 -1
- package/es/actions/link.js +3 -5
- package/es/actions/quick.d.ts +2 -0
- package/es/actions/quick.js +26 -0
- package/es/actions/request.js +12 -27
- package/es/actions/utils.js +1 -9
- package/es/card/card-container.js +0 -5
- package/es/card/divider.js +0 -5
- package/es/card/index.js +61 -100
- package/es/card/index.scss +15 -0
- package/es/card/selectable.js +4 -13
- package/es/card/tab.js +1 -10
- package/es/card/utils.js +0 -2
- package/es/card/xconsole.scss +3 -0
- package/es/form/Components/Editable/index.js +16 -55
- package/es/form/Components/FormGroup/index.d.ts +1 -0
- package/es/form/Components/FormGroup/index.js +7 -22
- package/es/form/Components/LightFilter/index.js +15 -35
- package/es/form/Components/ProField/index.js +2 -14
- package/es/form/Components/ProField/mapDateFormat.js +2 -28
- package/es/form/Components/Text/index.d.ts +1 -0
- package/es/form/Components/Text/index.js +2 -11
- package/es/form/Filter/AdvancedFilter.js +18 -27
- package/es/form/Filter/Layout.js +11 -24
- package/es/form/Filter/LightFilter.js +13 -24
- package/es/form/Filter/SimpleFilter.js +7 -21
- package/es/form/Filter/index.js +117 -171
- package/es/form/Filter/index2.js +11 -28
- package/es/form/Filter/layout.scss +1 -1
- package/es/form/Filter/useBindUrl.js +18 -46
- package/es/form/Filter/useSpecialProps.js +8 -13
- package/es/form/ProForm/addCascadeEffect.d.ts +2 -0
- package/es/form/ProForm/addCascadeEffect.js +203 -0
- package/es/form/ProForm/customComponent.js +0 -5
- package/es/form/ProForm/index.js +30 -38
- package/es/form/ProForm/index.scss +33 -0
- package/es/form/ProForm/useAutoLayout.js +21 -42
- package/es/form/ProForm/useAutoSubmit.js +3 -8
- package/es/form/ProForm/useFieldRequest.js +0 -5
- package/es/form/ProForm/useFormDisplayValues.js +12 -28
- package/es/form/ProForm/useInitialRequest.js +0 -5
- package/es/form/SchemaForm/adapterComponent.js +0 -3
- package/es/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/es/form/SchemaForm/adapterDecorator.js +0 -8
- package/es/form/SchemaForm/adapterType.js +0 -2
- package/es/form/SchemaForm/index.js +78 -114
- package/es/form/SchemaForm/initializeArrayCards.js +0 -6
- package/es/form/SchemaForm/initializeArrayCollapse.js +0 -6
- package/es/form/SchemaForm/initializeArrayItems.js +2 -9
- package/es/form/SchemaForm/initializeArrayTable.js +21 -34
- package/es/form/SchemaForm/initializeDataSource.js +2 -6
- package/es/form/SchemaForm/initializeFormButton.js +14 -31
- package/es/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/es/form/SchemaForm/initializeFormGroup.js +10 -20
- package/es/form/SchemaForm/initializeFormStep.js +11 -23
- package/es/form/SchemaForm/initializeFormTab.js +10 -20
- package/es/form/SchemaForm/initializeReactions.js +9 -33
- package/es/form/SchemaForm/initializeRequest.js +2 -16
- package/es/form/SchemaForm/initializeRules.js +4 -22
- package/es/form/SchemaForm/initializeSelectTable.js +7 -33
- package/es/form/SchemaForm/reactions.js +19 -34
- package/es/form/docs/ActionResponse.d.ts +1 -0
- package/es/form/index.d.ts +12 -9
- package/es/form/index.js +0 -9
- package/es/form/typing.d.ts +26 -4
- package/es/form/utils.d.ts +1 -1
- package/es/form/utils.js +4 -49
- package/es/form/warning.js +2 -7
- package/es/global.scss +3 -1
- package/es/index-without-icon.js +4 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +18 -8
- package/es/info/components/InfoGroup/index.js +21 -32
- package/es/info/components/InfoValueItem/index.js +74 -116
- package/es/info/components/ProInfoItem/index.js +13 -21
- package/es/info/components/baseInfo/index.js +17 -27
- package/es/info/components/headerInfo/index.js +8 -20
- package/es/info/components/tableInfo/index.js +20 -50
- package/es/info/index.js +61 -86
- package/es/info/typing.d.ts +6 -1
- package/es/info/utils/index.js +0 -11
- package/es/next-xconsole.scss +34 -0
- package/es/nocode/configurators/ProTable.js +1 -22
- package/es/nocode/configurators/common.js +5 -6
- package/es/nocode/configurators/index.js +2 -3
- package/es/nocode/index.js +6 -6
- package/es/nocode/pages/editor.js +5 -9
- package/es/nocode/pages/index.js +5 -30
- package/es/nocode/pages/playground.js +18 -35
- package/es/nocode/pages/renderer.js +9 -42
- package/es/nocode/playground.js +10 -23
- package/es/page-header/index.d.ts +2 -2
- package/es/page-header/index.js +40 -76
- package/es/page-header/index.scss +2 -1
- package/es/page-header/xconsole.scss +5 -0
- package/es/sidebar/components/sidebar-container/index.js +54 -69
- package/es/sidebar/components/sidebar-container/index.scss +21 -14
- package/es/sidebar/components/tree/index.js +100 -138
- package/es/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -26
- package/es/sidebar/components/tree-node/components/IconAction/index.js +9 -35
- package/es/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/es/sidebar/components/tree-node/components/IconSwitch/index.js +12 -25
- package/es/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/es/sidebar/components/tree-node/index.js +42 -84
- package/es/sidebar/components/tree-node/index.scss +6 -0
- package/es/sidebar/index.d.ts +2 -0
- package/es/sidebar/index.js +72 -95
- package/es/sidebar/typing.d.ts +4 -0
- package/es/sidebar/utils/action-ref.js +2 -7
- package/es/sidebar/utils/index.d.ts +5 -2
- package/es/sidebar/utils/index.js +41 -98
- package/es/table/components/CardView/index.d.ts +5 -0
- package/es/table/components/CardView/index.js +392 -0
- package/es/table/components/CardView/index.scss +46 -0
- package/es/table/components/Filter/index.d.ts +6 -3
- package/es/table/components/Filter/index.js +115 -128
- package/es/table/components/Layout/index.js +32 -47
- package/es/table/components/Layout/index.scss +2 -1
- package/es/table/components/LoadMore/index.d.ts +20 -0
- package/es/table/components/LoadMore/index.js +88 -0
- package/es/table/components/LoadMore/index.scss +19 -0
- package/es/table/components/Pagination/index.js +26 -60
- package/es/table/components/QuickAction/index.d.ts +1 -0
- package/es/table/components/QuickAction/index.js +3 -11
- package/es/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/es/table/components/ToolBar/CardSwitch.js +52 -0
- package/es/table/components/ToolBar/DensityIcon.js +19 -31
- package/es/table/components/ToolBar/FilterColumnIcon.js +87 -125
- package/es/table/components/ToolBar/FullScreenIcon.js +7 -62
- package/es/table/components/ToolBar/Fullscreen.js +25 -28
- package/es/table/components/ToolBar/RefreshIcon.js +162 -27
- package/es/table/components/ToolBar/index.d.ts +1 -1
- package/es/table/components/ToolBar/index.js +130 -38
- package/es/table/components/ToolBar/index.scss +49 -3
- package/es/table/index.js +467 -422
- package/es/table/index.scss +9 -1
- package/es/table/typing.d.ts +125 -6
- package/es/table/utils/columnRender.d.ts +3 -3
- package/es/table/utils/columnRender.js +39 -79
- package/es/table/utils/genProColumnToColumn.d.ts +2 -2
- package/es/table/utils/genProColumnToColumn.js +13 -16
- package/es/table/utils/index.js +14 -47
- package/es/table/utils/pureColumnRender.js +21 -53
- package/es/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/es/table/utils/pureGenProColumnToColumn.js +2 -10
- package/es/table/utils/useTableSelection.js +6 -33
- package/es/table/utils/util.d.ts +5 -0
- package/es/table/utils/util.js +19 -0
- package/es/templates/List/index.js +2 -9
- package/es/timeline/ProTimeLineItem/index.js +25 -65
- package/es/timeline/index.js +8 -22
- package/es/timeline/typing.d.ts +1 -0
- package/es/utils/message.d.ts +2 -2
- package/es/utils/message.js +0 -5
- package/es/xconsole.scss +503 -0
- package/lib/actions/base.js +8 -24
- package/lib/actions/confirm.js +0 -5
- package/lib/actions/danger-confirm.js +0 -5
- package/lib/actions/danger-pop-confirm.js +0 -4
- package/lib/actions/dialog-component.js +2 -15
- package/lib/actions/dialog-form.js +36 -89
- package/lib/actions/dialog-info.js +1 -10
- package/lib/actions/dialog-table.js +0 -5
- package/lib/actions/dialog.d.ts +2 -0
- package/lib/actions/dialog.js +55 -111
- package/lib/actions/drawer-form.js +0 -3
- package/lib/actions/drawer-info.js +0 -3
- package/lib/actions/drawer-table.js +0 -3
- package/lib/actions/drawer.js +0 -4
- package/lib/actions/error.js +0 -5
- package/lib/actions/index.d.ts +7 -0
- package/lib/actions/index.js +115 -184
- package/lib/actions/index.scss +6 -1
- package/lib/actions/link.js +1 -10
- package/lib/actions/notice.js +0 -5
- package/lib/actions/pop-confirm.js +0 -5
- package/lib/actions/quick.d.ts +2 -0
- package/lib/actions/quick.js +33 -0
- package/lib/actions/request.js +8 -32
- package/lib/actions/utils.js +1 -9
- package/lib/card/card-container.js +0 -9
- package/lib/card/divider.js +0 -7
- package/lib/card/index.js +61 -127
- package/lib/card/index.scss +15 -0
- package/lib/card/selectable.js +4 -20
- package/lib/card/tab.js +1 -14
- package/lib/card/utils.js +0 -6
- package/lib/card/xconsole.scss +3 -0
- package/lib/field/index.js +0 -6
- package/lib/form/Components/Editable/index.js +15 -65
- package/lib/form/Components/FormGroup/index.d.ts +1 -0
- package/lib/form/Components/FormGroup/index.js +7 -28
- package/lib/form/Components/LightFilter/index.js +15 -47
- package/lib/form/Components/ProField/index.js +2 -21
- package/lib/form/Components/ProField/mapDateFormat.js +2 -32
- package/lib/form/Components/Text/index.d.ts +1 -0
- package/lib/form/Components/Text/index.js +2 -16
- package/lib/form/Filter/AdvancedFilter.js +17 -34
- package/lib/form/Filter/Layout.js +11 -33
- package/lib/form/Filter/LightFilter.js +13 -32
- package/lib/form/Filter/SimpleFilter.js +5 -27
- package/lib/form/Filter/index.js +116 -191
- package/lib/form/Filter/index2.js +11 -38
- package/lib/form/Filter/layout.scss +1 -1
- package/lib/form/Filter/useBindUrl.js +18 -50
- package/lib/form/Filter/useSpecialProps.js +6 -13
- package/lib/form/ProForm/addCascadeEffect.d.ts +2 -0
- package/lib/form/ProForm/addCascadeEffect.js +210 -0
- package/lib/form/ProForm/customComponent.js +0 -8
- package/lib/form/ProForm/index.js +30 -60
- package/lib/form/ProForm/index.scss +33 -0
- package/lib/form/ProForm/useAutoLayout.js +21 -45
- package/lib/form/ProForm/useAutoSubmit.js +1 -10
- package/lib/form/ProForm/useFieldRequest.js +0 -8
- package/lib/form/ProForm/useFormDisplayValues.js +12 -34
- package/lib/form/ProForm/useInitialRequest.js +0 -6
- package/lib/form/SchemaForm/adapterComponent.js +0 -6
- package/lib/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/lib/form/SchemaForm/adapterDecorator.js +0 -12
- package/lib/form/SchemaForm/adapterType.js +0 -5
- package/lib/form/SchemaForm/index.js +78 -144
- package/lib/form/SchemaForm/initializeArrayCards.js +0 -7
- package/lib/form/SchemaForm/initializeArrayCollapse.js +0 -7
- package/lib/form/SchemaForm/initializeArrayItems.js +2 -10
- package/lib/form/SchemaForm/initializeArrayTable.js +21 -34
- package/lib/form/SchemaForm/initializeDataSource.js +2 -8
- package/lib/form/SchemaForm/initializeFormButton.js +14 -32
- package/lib/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/lib/form/SchemaForm/initializeFormGroup.js +10 -20
- package/lib/form/SchemaForm/initializeFormStep.js +11 -23
- package/lib/form/SchemaForm/initializeFormTab.js +10 -20
- package/lib/form/SchemaForm/initializeReactions.js +9 -37
- package/lib/form/SchemaForm/initializeRequest.js +2 -18
- package/lib/form/SchemaForm/initializeRules.js +4 -24
- package/lib/form/SchemaForm/initializeSelectTable.js +7 -36
- package/lib/form/SchemaForm/reactions.js +17 -37
- package/lib/form/docs/ActionResponse.d.ts +1 -0
- package/lib/form/docs/ActionResponse.js +0 -5
- package/lib/form/index.d.ts +12 -9
- package/lib/form/index.js +0 -25
- package/lib/form/typing.d.ts +26 -4
- package/lib/form/utils.d.ts +1 -1
- package/lib/form/utils.js +4 -61
- package/lib/form/warning.js +2 -8
- package/lib/global.scss +3 -1
- package/lib/hooks/index.js +0 -5
- package/lib/index-without-icon.js +2 -36
- package/lib/index.d.ts +1 -1
- package/lib/index.js +13 -40
- package/lib/info/components/InfoGroup/index.js +21 -42
- package/lib/info/components/InfoValueItem/index.js +74 -131
- package/lib/info/components/ProInfoItem/index.js +13 -29
- package/lib/info/components/baseInfo/index.js +17 -39
- package/lib/info/components/headerInfo/index.js +8 -31
- package/lib/info/components/tableInfo/index.js +20 -62
- package/lib/info/index.js +61 -101
- package/lib/info/typing.d.ts +6 -1
- package/lib/info/utils/index.js +0 -19
- package/lib/info/utils/utils.js +0 -1
- package/lib/next-xconsole.scss +34 -0
- package/lib/nocode/configurators/PageHeader.js +0 -2
- package/lib/nocode/configurators/ProTable.js +1 -24
- package/lib/nocode/configurators/common.js +5 -10
- package/lib/nocode/configurators/index.js +2 -10
- package/lib/nocode/configurators/map.js +0 -5
- package/lib/nocode/index.js +0 -11
- package/lib/nocode/pages/editor.js +5 -19
- package/lib/nocode/pages/index.js +3 -35
- package/lib/nocode/pages/playground.js +18 -52
- package/lib/nocode/pages/renderer.js +9 -53
- package/lib/nocode/playground.js +10 -35
- package/lib/page-container/index.js +0 -6
- package/lib/page-header/index.d.ts +2 -2
- package/lib/page-header/index.js +39 -90
- package/lib/page-header/index.scss +2 -1
- package/lib/page-header/xconsole.scss +5 -0
- package/lib/sidebar/components/sidebar-container/index.js +54 -81
- package/lib/sidebar/components/sidebar-container/index.scss +21 -14
- package/lib/sidebar/components/tree/index.js +100 -152
- package/lib/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -34
- package/lib/sidebar/components/tree-node/components/IconAction/index.js +9 -46
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.js +12 -35
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/lib/sidebar/components/tree-node/index.js +42 -100
- package/lib/sidebar/components/tree-node/index.scss +6 -0
- package/lib/sidebar/index.d.ts +2 -0
- package/lib/sidebar/index.js +79 -111
- package/lib/sidebar/typing.d.ts +4 -0
- package/lib/sidebar/utils/action-ref.js +2 -8
- package/lib/sidebar/utils/index.d.ts +5 -2
- package/lib/sidebar/utils/index.js +41 -106
- package/lib/skeleton/index.js +0 -6
- package/lib/table/components/CardView/index.d.ts +5 -0
- package/lib/table/components/CardView/index.js +402 -0
- package/lib/table/components/CardView/index.scss +46 -0
- package/lib/table/components/EmptyContent/index.js +0 -6
- package/lib/table/components/Filter/index.d.ts +6 -3
- package/lib/table/components/Filter/index.js +114 -137
- package/lib/table/components/Layout/index.js +32 -60
- package/lib/table/components/Layout/index.scss +2 -1
- package/lib/table/components/LoadMore/index.d.ts +20 -0
- package/lib/table/components/LoadMore/index.js +99 -0
- package/lib/table/components/LoadMore/index.scss +19 -0
- package/lib/table/components/Pagination/index.js +26 -70
- package/lib/table/components/QuickAction/index.d.ts +1 -0
- package/lib/table/components/QuickAction/index.js +3 -15
- package/lib/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/lib/table/components/ToolBar/CardSwitch.js +60 -0
- package/lib/table/components/ToolBar/DensityIcon.js +19 -42
- package/lib/table/components/ToolBar/FilterColumnIcon.js +86 -136
- package/lib/table/components/ToolBar/FullScreenIcon.js +10 -74
- package/lib/table/components/ToolBar/Fullscreen.js +25 -35
- package/lib/table/components/ToolBar/RefreshIcon.js +164 -36
- package/lib/table/components/ToolBar/index.d.ts +1 -1
- package/lib/table/components/ToolBar/index.js +133 -47
- package/lib/table/components/ToolBar/index.scss +49 -3
- package/lib/table/index.js +466 -444
- package/lib/table/index.scss +9 -1
- package/lib/table/typing.d.ts +125 -6
- package/lib/table/utils/columnRender.d.ts +3 -3
- package/lib/table/utils/columnRender.js +39 -92
- package/lib/table/utils/genProColumnToColumn.d.ts +2 -2
- package/lib/table/utils/genProColumnToColumn.js +13 -21
- package/lib/table/utils/getTableProps.js +0 -2
- package/lib/table/utils/getTableSortIcons.js +0 -5
- package/lib/table/utils/index.js +12 -55
- package/lib/table/utils/pureColumnRender.js +21 -64
- package/lib/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/lib/table/utils/pureGenProColumnToColumn.js +2 -11
- package/lib/table/utils/useTableSelection.js +6 -35
- package/lib/table/utils/util.d.ts +5 -0
- package/lib/table/utils/util.js +25 -0
- package/lib/templates/Detail/index.js +0 -5
- package/lib/templates/Form/index.js +0 -5
- package/lib/templates/List/index.js +2 -19
- package/lib/templates/index.js +0 -6
- package/lib/timeline/ProTimeLineItem/index.js +25 -76
- package/lib/timeline/index.js +8 -33
- package/lib/timeline/typing.d.ts +1 -0
- package/lib/utils/index.js +0 -6
- package/lib/utils/message.d.ts +2 -2
- package/lib/utils/message.js +0 -10
- package/lib/xconsole.scss +503 -0
- package/package.json +2 -2
package/lib/table/index.js
CHANGED
@@ -5,45 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
var _exportNames = {};
|
7
7
|
exports.default = void 0;
|
8
|
-
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
10
|
-
|
11
9
|
var _components = require("@alicloudfe/components");
|
12
|
-
|
13
10
|
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
14
|
-
|
15
11
|
var _genProColumnToColumn = _interopRequireDefault(require("./utils/genProColumnToColumn"));
|
16
|
-
|
17
12
|
var _utils = require("@teamix/utils");
|
18
|
-
|
19
13
|
var _skeleton = require("../skeleton");
|
20
|
-
|
21
14
|
require("./index.scss");
|
22
|
-
|
23
15
|
var _Layout = _interopRequireDefault(require("./components/Layout"));
|
24
|
-
|
25
16
|
var _utils2 = require("./utils");
|
26
|
-
|
27
17
|
var _getTableProps = _interopRequireDefault(require("./utils/getTableProps"));
|
28
|
-
|
29
18
|
var _getTableSortIcons = _interopRequireDefault(require("./utils/getTableSortIcons"));
|
30
|
-
|
31
19
|
var _useTableSelection = _interopRequireDefault(require("./utils/useTableSelection"));
|
32
|
-
|
33
20
|
var _Fullscreen = _interopRequireDefault(require("./components/ToolBar/Fullscreen"));
|
34
|
-
|
35
|
-
var _EmptyContent = _interopRequireDefault(require("./components/EmptyContent"));
|
36
|
-
|
21
|
+
var _proField = require("@teamix/pro-field");
|
37
22
|
var _actions = require("../actions");
|
38
|
-
|
39
23
|
var _classnames = _interopRequireDefault(require("classnames"));
|
40
|
-
|
41
24
|
var _pageContainer = _interopRequireDefault(require("../page-container"));
|
42
|
-
|
43
25
|
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
44
|
-
|
26
|
+
var _CardView = _interopRequireDefault(require("./components/CardView"));
|
27
|
+
var _hooks = require("@teamix/hooks");
|
28
|
+
var _util = require("./utils/util");
|
45
29
|
var _typing = require("./typing");
|
46
|
-
|
47
30
|
Object.keys(_typing).forEach(function (key) {
|
48
31
|
if (key === "default" || key === "__esModule") return;
|
49
32
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -55,271 +38,258 @@ Object.keys(_typing).forEach(function (key) {
|
|
55
38
|
}
|
56
39
|
});
|
57
40
|
});
|
58
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree"]
|
59
|
-
|
41
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps", "bindUrlProps", "bindUrl"],
|
42
|
+
_excluded2 = ["onChange"];
|
60
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
61
|
-
|
62
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
63
|
-
|
64
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
65
|
-
|
66
46
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
67
|
-
|
68
47
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
69
|
-
|
70
48
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
71
|
-
|
72
49
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
73
|
-
|
74
50
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
75
|
-
|
76
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
77
|
-
|
78
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
79
|
-
|
80
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
81
|
-
|
82
51
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
83
|
-
|
84
52
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
85
|
-
|
86
53
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
87
|
-
|
88
54
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
89
|
-
|
90
55
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
91
|
-
|
92
56
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
93
|
-
|
94
57
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
95
|
-
|
96
58
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
97
|
-
|
59
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
60
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
61
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
98
62
|
var cls = (0, _utils.usePrefixCls)('teamix-pro-table');
|
99
63
|
/**
|
100
64
|
* 处理原生传入的 columns 以便于 选择列 方便处理
|
101
65
|
* @param columns 原生传入的 columns
|
102
66
|
* @returns
|
103
67
|
*/
|
104
|
-
|
105
68
|
var processColumns = function processColumns(columns, initialColumns) {
|
106
69
|
var _getGlobalConfig;
|
107
|
-
|
108
70
|
var globalFilterColumns = (_getGlobalConfig = (0, _utils.getGlobalConfig)('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.filterColumns;
|
109
71
|
var filterColumns = columns.filter(function (item) {
|
110
|
-
return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(item));
|
111
|
-
});
|
112
|
-
|
72
|
+
return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(_objectSpread({}, item)));
|
73
|
+
});
|
74
|
+
// 处理只剩一列批量选择的情况下宽度错乱问题
|
113
75
|
if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
|
114
76
|
var _initialColumns$;
|
115
|
-
|
116
77
|
if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
|
117
78
|
var _filterColumns$, _filterColumns$2;
|
118
|
-
|
119
79
|
if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
|
120
80
|
delete filterColumns[0].width;
|
121
81
|
}
|
122
|
-
|
123
82
|
if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
|
124
83
|
filterColumns[0].lock = false;
|
125
84
|
}
|
126
85
|
} else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
|
127
86
|
var _initialColumns$2, _initialColumns$3;
|
128
|
-
|
129
87
|
if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
|
130
88
|
filterColumns[0].width = initialColumns[0].width;
|
131
89
|
}
|
132
|
-
|
133
90
|
if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
|
134
91
|
filterColumns[0].lock = initialColumns[0].lock;
|
135
92
|
}
|
136
93
|
}
|
137
94
|
}
|
138
|
-
|
139
95
|
return filterColumns;
|
140
96
|
};
|
141
97
|
/** 默认请求翻页参数 */
|
142
|
-
|
143
|
-
|
144
98
|
var globalPageKey = 'currentPage';
|
145
99
|
var globalPageSizeKey = 'pageSize';
|
146
|
-
|
147
100
|
var globalFormatSort = function globalFormatSort(sort) {
|
148
101
|
if (Object.keys(sort).length > 0) {
|
149
102
|
return {
|
150
103
|
sort: sort
|
151
104
|
};
|
152
105
|
}
|
153
|
-
|
154
106
|
return {};
|
155
107
|
};
|
156
|
-
|
157
108
|
var ProTable = function ProTable(props) {
|
158
|
-
var _rowSelection$selecte;
|
159
|
-
|
109
|
+
var _urlState$currentPage, _rowSelection$selecte;
|
160
110
|
var header = props.header,
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
111
|
+
className = props.className,
|
112
|
+
tableClassName = props.tableClassName,
|
113
|
+
mainAction = props.mainAction,
|
114
|
+
extra = props.extra,
|
115
|
+
propsDataFilter = props.dataFilter,
|
116
|
+
afterDataFilter = props.afterDataFilter,
|
117
|
+
toolBar = props.toolBar,
|
118
|
+
propsColumns = props.columns,
|
119
|
+
useRowSelection = props.useRowSelection,
|
120
|
+
propsRowSelection = props.rowSelection,
|
121
|
+
onChangeRowSelection = props.onChangeRowSelection,
|
122
|
+
getRowSelection = props.getRowSelection,
|
123
|
+
primaryKey = props.primaryKey,
|
124
|
+
footerAction = props.footerAction,
|
125
|
+
footer = props.footer,
|
126
|
+
url = props.url,
|
127
|
+
pageKey = props.pageKey,
|
128
|
+
pageSizeKey = props.pageSizeKey,
|
129
|
+
_props$method = props.method,
|
130
|
+
method = _props$method === void 0 ? 'get' : _props$method,
|
131
|
+
_props$params = props.params,
|
132
|
+
propsParams = _props$params === void 0 ? {} : _props$params,
|
133
|
+
formatSort = props.formatSort,
|
134
|
+
_props$formatParams = props.formatParams,
|
135
|
+
formatParams = _props$formatParams === void 0 ? function (params) {
|
136
|
+
return params;
|
137
|
+
} : _props$formatParams,
|
138
|
+
formatResult = props.formatResult,
|
139
|
+
requestConfig = props.requestConfig,
|
140
|
+
_props$requestWhenMou = props.requestWhenMount,
|
141
|
+
requestWhenMount = _props$requestWhenMou === void 0 ? true : _props$requestWhenMou,
|
142
|
+
_props$showPagination = props.showPagination,
|
143
|
+
showPagination = _props$showPagination === void 0 ? true : _props$showPagination,
|
144
|
+
_props$pageSizeList = props.pageSizeList,
|
145
|
+
pageSizeList = _props$pageSizeList === void 0 ? [5, 10, 20, 50, 100] : _props$pageSizeList,
|
146
|
+
responsivePaginationType = props.responsivePaginationType,
|
147
|
+
_props$showSkeleton = props.showSkeleton,
|
148
|
+
propsShowSkeleton = _props$showSkeleton === void 0 ? true : _props$showSkeleton,
|
149
|
+
_props$skeletonSize = props.skeletonSize,
|
150
|
+
skeletonSize = _props$skeletonSize === void 0 ? 5 : _props$skeletonSize,
|
151
|
+
propsActionRef = props.actionRef,
|
152
|
+
propsDataSource = props.dataSource,
|
153
|
+
_props$filterDebounce = props.filterDebounce,
|
154
|
+
filterDebounce = _props$filterDebounce === void 0 ? 300 : _props$filterDebounce,
|
155
|
+
_props$footerSuction = props.footerSuction,
|
156
|
+
footerSuction = _props$footerSuction === void 0 ? false : _props$footerSuction,
|
157
|
+
_props$autoRefresh = props.autoRefresh,
|
158
|
+
autoRefresh = _props$autoRefresh === void 0 ? false : _props$autoRefresh,
|
159
|
+
autoRefreshProps = props.autoRefreshProps,
|
160
|
+
customRequest = props.customRequest,
|
161
|
+
_props$filterColumnTy = props.filterColumnType,
|
162
|
+
filterColumnType = _props$filterColumnTy === void 0 ? 'auto' : _props$filterColumnTy,
|
163
|
+
defaultFilterParams = props.defaultFilterParams,
|
164
|
+
_props$reserveSelecte = props.reserveSelectedRecords,
|
165
|
+
reserveSelectedRecords = _props$reserveSelecte === void 0 ? false : _props$reserveSelecte,
|
166
|
+
_props$size = props.size,
|
167
|
+
propsSize = _props$size === void 0 ? 'medium' : _props$size,
|
168
|
+
disableSelectAll = props.disableSelectAll,
|
169
|
+
context = props.context,
|
170
|
+
_props$fixedTableBody = props.fixedTableBody,
|
171
|
+
fixedTableBody = _props$fixedTableBody === void 0 ? false : _props$fixedTableBody,
|
172
|
+
isTree = props.isTree,
|
173
|
+
_props$toolBarAutoWid = props.toolBarAutoWidth,
|
174
|
+
toolBarAutoWidth = _props$toolBarAutoWid === void 0 ? true : _props$toolBarAutoWid,
|
175
|
+
dataTeamixSpm = props['data-teamix-spm'],
|
176
|
+
_props$switchCardView = props.switchCardView,
|
177
|
+
switchCardView = _props$switchCardView === void 0 ? false : _props$switchCardView,
|
178
|
+
cardViewProps = props.cardViewProps,
|
179
|
+
_props$defaultView = props.defaultView,
|
180
|
+
defaultView = _props$defaultView === void 0 ? 'table' : _props$defaultView,
|
181
|
+
emptyProps = props.emptyProps,
|
182
|
+
bindUrlProps = props.bindUrlProps,
|
183
|
+
bindUrl = props.bindUrl,
|
184
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
225
185
|
var targetPageKey = pageKey || globalPageKey;
|
226
186
|
var targetPageSizeKey = pageSizeKey || globalPageSizeKey;
|
227
187
|
var targetFormatSort = formatSort || globalFormatSort;
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
188
|
+
var _ref = bindUrl ? (0, _hooks.useUrlState)() : [],
|
189
|
+
_ref2 = _slicedToArray(_ref, 2),
|
190
|
+
urlState = _ref2[0],
|
191
|
+
setUrlState = _ref2[1];
|
192
|
+
var _useState = (0, _react.useState)((_urlState$currentPage = urlState === null || urlState === void 0 ? void 0 : urlState.currentPage) !== null && _urlState$currentPage !== void 0 ? _urlState$currentPage : 1),
|
193
|
+
_useState2 = _slicedToArray(_useState, 2),
|
194
|
+
currentPage = _useState2[0],
|
195
|
+
setCurrentPage = _useState2[1];
|
196
|
+
var _useState3 = (0, _react.useState)((urlState === null || urlState === void 0 ? void 0 : urlState.pageSize) || props.pageSize || 10),
|
197
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
198
|
+
pageSize = _useState4[0],
|
199
|
+
setPageSize = _useState4[1];
|
239
200
|
var _useState5 = (0, _react.useState)(0),
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
201
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
202
|
+
total = _useState6[0],
|
203
|
+
setTotal = _useState6[1];
|
244
204
|
var _useState7 = (0, _react.useState)(propsDataSource !== null && propsDataSource !== void 0 ? propsDataSource : []),
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
205
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
206
|
+
data = _useState8[0],
|
207
|
+
_setData = _useState8[1];
|
249
208
|
var _useState9 = (0, _react.useState)(props.sort || {}),
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
setShowSkeleton = _useState12[1]; // 首次加载,渲染骨架屏
|
258
|
-
|
259
|
-
|
209
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
210
|
+
sort = _useState10[0],
|
211
|
+
setSort = _useState10[1];
|
212
|
+
var _useState11 = (0, _react.useState)(!propsDataSource && requestWhenMount && propsShowSkeleton && !!url),
|
213
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
214
|
+
showSkeleton = _useState12[0],
|
215
|
+
setShowSkeleton = _useState12[1]; // 首次加载,渲染骨架屏
|
260
216
|
var skeletonDataSource = new Array(skeletonSize).fill({});
|
261
|
-
var requestDataKey = method.toLowerCase() === 'get' ? 'params' : 'data';
|
262
|
-
|
217
|
+
var requestDataKey = method.toLowerCase() === 'get' ? 'params' : 'data';
|
218
|
+
// 如果使用 customRequest 的话,内置 loading
|
263
219
|
var _useState13 = (0, _react.useState)(requestWhenMount),
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
220
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
221
|
+
customTableLoading = _useState14[0],
|
222
|
+
setCustomTableLoading = _useState14[1];
|
268
223
|
var tableRef = (0, _react.useRef)(null);
|
269
|
-
var actionRef = (0, _react.useRef)();
|
270
|
-
|
224
|
+
var actionRef = (0, _react.useRef)();
|
225
|
+
// 传给 table 的过滤后的 columns
|
271
226
|
var _useState15 = (0, _react.useState)(processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [], propsColumns)),
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
227
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
228
|
+
filteredColumns = _useState16[0],
|
229
|
+
setFilteredColumns = _useState16[1];
|
276
230
|
var _useState17 = (0, _react.useState)(propsSize),
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
231
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
232
|
+
size = _useState18[0],
|
233
|
+
_setSize = _useState18[1];
|
281
234
|
var _useState19 = (0, _react.useState)(true),
|
282
|
-
|
283
|
-
|
284
|
-
|
235
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
236
|
+
showLoading = _useState20[0],
|
237
|
+
setShowLoading = _useState20[1];
|
238
|
+
// 表格内部用作存储的 Ref,标识 Table 组件是否被第一次渲染。用作 useUrlState filter 第一次渲染时使用 state 数据请求
|
239
|
+
var dataRef = (0, _react.useRef)({
|
240
|
+
flag: true
|
241
|
+
});
|
242
|
+
(0, _react.useEffect)(function () {
|
243
|
+
if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.pagination) !== false) {
|
244
|
+
if ((urlState === null || urlState === void 0 ? void 0 : urlState.currentPage) !== currentPage) {
|
245
|
+
setUrlState === null || setUrlState === void 0 ? void 0 : setUrlState({
|
246
|
+
currentPage: currentPage
|
247
|
+
});
|
248
|
+
}
|
249
|
+
if ((urlState === null || urlState === void 0 ? void 0 : urlState.pageSize) !== pageSize) {
|
250
|
+
setUrlState === null || setUrlState === void 0 ? void 0 : setUrlState({
|
251
|
+
pageSize: pageSize
|
252
|
+
});
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}, [currentPage, pageSize, urlState]);
|
256
|
+
// 存储能够被 on 监听到的 ProTable 状态
|
285
257
|
// 因为只做存储用。不需要更新视图以及需要同步更改。所以不使用 setState 更新
|
286
|
-
|
287
|
-
|
288
258
|
var _useState21 = (0, _react.useState)({
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
259
|
+
fullScreenState: false,
|
260
|
+
filterRules: {},
|
261
|
+
filterColumns: []
|
262
|
+
}),
|
263
|
+
_useState22 = _slicedToArray(_useState21, 1),
|
264
|
+
actionRefState = _useState22[0];
|
265
|
+
// 存储 on 监听事件
|
297
266
|
var _useState23 = (0, _react.useState)({
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
267
|
+
fullScreenState: {}
|
268
|
+
}),
|
269
|
+
_useState24 = _slicedToArray(_useState23, 1),
|
270
|
+
actionRefCallback = _useState24[0];
|
271
|
+
// 存储定时器 id
|
304
272
|
var autoRefreshTimerRef = (0, _react.useRef)();
|
305
273
|
var onResize = null;
|
274
|
+
// useEffect(() => {
|
275
|
+
// setShowSkeleton(propsShowSkeleton);
|
276
|
+
// }, [propsShowSkeleton]);
|
277
|
+
// useEffect(() => {
|
278
|
+
// console.log('传入的props变化', propsLoading);
|
279
|
+
// setShowLoading(propsLoading ?? false);
|
280
|
+
// }, [propsLoading]);
|
306
281
|
(0, _react.useEffect)(function () {
|
307
282
|
var _propsDataFilter$sche, _propsDataFilter$sche2;
|
308
|
-
|
309
283
|
getHeaderHeight(fullscreenState);
|
310
284
|
getFooterSuctionState();
|
311
|
-
|
312
285
|
if (window.onresize) {
|
313
286
|
onResize = window.onresize;
|
314
287
|
window.onresize = (0, _lodash.default)(function () {
|
315
288
|
var _onResize;
|
316
|
-
|
317
289
|
(_onResize = onResize) === null || _onResize === void 0 ? void 0 : _onResize();
|
318
|
-
|
319
290
|
if (footerSuction) {
|
320
291
|
getFooterSuctionState();
|
321
292
|
}
|
322
|
-
|
323
293
|
if (fixedTableBody) {
|
324
294
|
getHeaderHeight(fullscreenState);
|
325
295
|
}
|
@@ -329,44 +299,35 @@ var ProTable = function ProTable(props) {
|
|
329
299
|
if (footerSuction) {
|
330
300
|
getFooterSuctionState();
|
331
301
|
}
|
332
|
-
|
333
302
|
if (fixedTableBody) {
|
334
303
|
getHeaderHeight(fullscreenState);
|
335
304
|
}
|
336
305
|
}, 500);
|
337
|
-
}
|
338
|
-
|
339
|
-
|
306
|
+
}
|
307
|
+
// 如果不传 dataFilter,则在这里初始化请求
|
340
308
|
var hasDataFilter = (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche = propsDataFilter.schema) === null || _propsDataFilter$sche === void 0 ? void 0 : _propsDataFilter$sche.length) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche2 = propsDataFilter.schema) === null || _propsDataFilter$sche2 === void 0 ? void 0 : _propsDataFilter$sche2.length) > 0;
|
341
|
-
|
342
309
|
if (requestWhenMount && !hasDataFilter) {
|
343
310
|
(0, _utils2.processDefaultFilter)(propsColumns, actionRef, defaultFilterParams);
|
344
|
-
|
345
311
|
_request();
|
346
312
|
}
|
347
|
-
|
348
313
|
return function () {
|
349
314
|
if (onResize) {
|
350
315
|
window.onresize = onResize;
|
351
316
|
} else {
|
352
317
|
window.onresize = null;
|
353
318
|
}
|
354
|
-
|
355
319
|
if (autoRefreshTimerRef.current) {
|
356
320
|
clearTimeout(autoRefreshTimerRef.current);
|
357
321
|
}
|
358
|
-
|
359
322
|
actionRef.current = undefined;
|
360
323
|
};
|
361
|
-
}, []);
|
362
|
-
|
324
|
+
}, []);
|
325
|
+
// 获取header高度,用作全屏吸底吸底高度计算以及固定body高度计算(滚动条在底部)
|
363
326
|
var getHeaderHeight = function getHeaderHeight(isFullscreen, offset) {
|
364
327
|
var _tableDom$getElements, _tableDom$getElements2, _document$querySelect, _document$querySelect2, _document$querySelect3;
|
365
|
-
|
366
328
|
if (!fixedTableBody) {
|
367
329
|
return;
|
368
330
|
}
|
369
|
-
|
370
331
|
var tableDom = tableRef.current;
|
371
332
|
var headerDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements = tableDom.getElementsByClassName('teamix-pro-table-layout')) === null || _tableDom$getElements === void 0 ? void 0 : _tableDom$getElements[0];
|
372
333
|
var basePrefix = (0, _utils.usePrefixCls)('', {
|
@@ -375,95 +336,90 @@ var ProTable = function ProTable(props) {
|
|
375
336
|
var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName(basePrefix('table-header-inner'))) === null || _tableDom$getElements2 === void 0 ? void 0 : _tableDom$getElements2[0];
|
376
337
|
var pageContainerDom = document.querySelector('.teamix-pro-page-container-header');
|
377
338
|
var teamixNavDom = document.querySelector('.teamix-nav-console');
|
378
|
-
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer');
|
379
|
-
|
339
|
+
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer');
|
340
|
+
// 这边不能直接取 next-table-body
|
380
341
|
var tableBodyDom = (_document$querySelect = document.querySelector('.teamix-pro-table')) === null || _document$querySelect === void 0 ? void 0 : (_document$querySelect2 = _document$querySelect.getElementsByTagName('table')) === null || _document$querySelect2 === void 0 ? void 0 : (_document$querySelect3 = _document$querySelect2[1]) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.parentNode;
|
381
342
|
var headerFixedTopSectionDom = document.querySelector('.teamix-pro-page-container-fixed-top');
|
382
343
|
setTimeout(function () {
|
383
344
|
var _headerDom$offsetHeig, _tableHeaderDom$offse;
|
384
|
-
|
385
|
-
|
386
|
-
|
345
|
+
var headerHeight = (_headerDom$offsetHeig = headerDom === null || headerDom === void 0 ? void 0 : headerDom.offsetHeight) !== null && _headerDom$offsetHeig !== void 0 ? _headerDom$offsetHeig : 0;
|
346
|
+
// table表头默认一行。即42px
|
387
347
|
var tableHeaderHeight = (_tableHeaderDom$offse = tableHeaderDom === null || tableHeaderDom === void 0 ? void 0 : tableHeaderDom.offsetHeight) !== null && _tableHeaderDom$offse !== void 0 ? _tableHeaderDom$offse : 42;
|
388
|
-
var footerRowSelectionHeight = (footerRowSelectionDom === null || footerRowSelectionDom === void 0 ? void 0 : footerRowSelectionDom.offsetHeight) || 50;
|
389
|
-
|
348
|
+
var footerRowSelectionHeight = (footerRowSelectionDom === null || footerRowSelectionDom === void 0 ? void 0 : footerRowSelectionDom.offsetHeight) || 50;
|
349
|
+
// 固定表格主体高度
|
390
350
|
if (fixedTableBody && !isFullscreen) {
|
391
351
|
var _pageContainerDom$off, _teamixNavDom$offsetH;
|
392
|
-
|
393
352
|
// 16px 为 padding
|
394
353
|
var pageHeaderHeight = ((_pageContainerDom$off = pageContainerDom === null || pageContainerDom === void 0 ? void 0 : pageContainerDom.offsetHeight) !== null && _pageContainerDom$off !== void 0 ? _pageContainerDom$off : 0) + 16;
|
395
|
-
var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0;
|
396
|
-
|
354
|
+
var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0;
|
355
|
+
// 1 为预留值,js无法取出精确高度,会被四舍五入
|
397
356
|
var offsetHeaderHeight = headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0) + 1;
|
398
|
-
|
399
|
-
|
357
|
+
if (switchViewState === 'card') {
|
358
|
+
offsetHeaderHeight = offsetHeaderHeight - tableHeaderHeight - footerRowSelectionHeight;
|
359
|
+
}
|
360
|
+
if ((tableBodyDom === null || tableBodyDom === void 0 ? void 0 : tableBodyDom.clientHeight) < (tableBodyDom === null || tableBodyDom === void 0 ? void 0 : tableBodyDom.scrollHeight)) {
|
400
361
|
setFooterSuctionState(true);
|
401
362
|
} else {
|
402
363
|
setFooterSuctionState(false);
|
403
|
-
}
|
404
|
-
|
405
|
-
|
364
|
+
}
|
365
|
+
// 如果有切换区tab,那么重新计算
|
406
366
|
if (headerFixedTopSectionDom.clientHeight) {
|
407
367
|
var _headerFixedTopSectio;
|
408
|
-
|
409
|
-
|
368
|
+
var headerFixedTopSectionHeight = (_headerFixedTopSectio = headerFixedTopSectionDom.clientHeight) !== null && _headerFixedTopSectio !== void 0 ? _headerFixedTopSectio : 0;
|
369
|
+
// const clientTableBodyHeight =
|
410
370
|
// document.body.clientHeight - offsetHeaderHeight;
|
411
|
-
|
412
371
|
setHeaderHeight(headerFixedTopSectionHeight + teamixNavHeight + footerRowSelectionHeight + tableHeaderHeight + 1);
|
413
372
|
return;
|
414
373
|
}
|
415
|
-
|
416
374
|
setHeaderHeight(offsetHeaderHeight);
|
417
375
|
} else {
|
418
376
|
// 24px 为 padding
|
419
377
|
setHeaderHeight(headerHeight + tableHeaderHeight + footerRowSelectionHeight + 24 + (offset !== null && offset !== void 0 ? offset : 0) + 1);
|
420
378
|
}
|
421
379
|
}, 50);
|
422
|
-
};
|
423
|
-
|
424
|
-
|
380
|
+
};
|
381
|
+
// header 区域高度。用作全屏计算吸顶吸底高度。默认不做计算
|
425
382
|
var _useState25 = (0, _react.useState)(0),
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
383
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
384
|
+
headerHeight = _useState26[0],
|
385
|
+
setHeaderHeight = _useState26[1];
|
386
|
+
// 全屏显示 className
|
431
387
|
var _useState27 = (0, _react.useState)(false),
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
388
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
389
|
+
fullscreenState = _useState28[0],
|
390
|
+
setFullscreenState = _useState28[1];
|
391
|
+
// 切换视角
|
392
|
+
var _useState29 = (0, _react.useState)(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
|
393
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
394
|
+
switchViewState = _useState30[0],
|
395
|
+
setSwitchViewState = _useState30[1];
|
396
|
+
// 切换全屏搜索开关
|
437
397
|
var filterEnableRef = (0, _react.useRef)({
|
438
398
|
fullscreen: false,
|
439
399
|
normal: true
|
440
|
-
});
|
441
|
-
|
400
|
+
});
|
401
|
+
// 非全屏状态下的
|
442
402
|
var normalDataFilterFormRef = (0, _react.useRef)();
|
443
403
|
var fullscreenDataFilterFormRef = (0, _react.useRef)();
|
444
404
|
var normalDataFilterForm = normalDataFilterFormRef.current;
|
445
|
-
var fullscreenDataFilterForm = fullscreenDataFilterFormRef.current;
|
446
|
-
|
447
|
-
var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
|
405
|
+
var fullscreenDataFilterForm = fullscreenDataFilterFormRef.current;
|
406
|
+
// 传给 QueryFilter 的 formRef
|
407
|
+
var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
|
408
|
+
// let dataFilterForm = dataFilterFormRef.current;
|
448
409
|
// 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
410
|
+
var _useState31 = (0, _react.useState)(false),
|
411
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
412
|
+
footerSuctionState = _useState32[0],
|
413
|
+
setFooterSuctionState = _useState32[1];
|
414
|
+
// TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
|
456
415
|
var getFooterSuctionState = function getFooterSuctionState() {
|
457
416
|
if (!footerSuction) {
|
458
417
|
return;
|
459
418
|
}
|
460
|
-
|
461
419
|
var containerDom = document.querySelector('.teamix-pro-page-container-scroll-container');
|
462
|
-
|
463
420
|
if (containerDom) {
|
464
421
|
var offsetHeight = containerDom.offsetHeight;
|
465
422
|
var scrollHeight = containerDom.scrollHeight;
|
466
|
-
|
467
423
|
if (offsetHeight < scrollHeight) {
|
468
424
|
setFooterSuctionState(true);
|
469
425
|
} else {
|
@@ -475,35 +431,28 @@ var ProTable = function ProTable(props) {
|
|
475
431
|
setFooterSuctionState(true);
|
476
432
|
}
|
477
433
|
}
|
478
|
-
};
|
479
|
-
|
480
|
-
|
434
|
+
};
|
435
|
+
// rowSelection 相关
|
481
436
|
var rowSelectionHook = (0, _useTableSelection.default)(_objectSpread(_objectSpread({}, propsRowSelection), {}, {
|
482
437
|
// 当初始出现骨架屏的时候,不可选择
|
483
438
|
getProps: function getProps(record, index) {
|
484
439
|
var result = {};
|
485
|
-
|
486
440
|
if (propsRowSelection === null || propsRowSelection === void 0 ? void 0 : propsRowSelection.getProps) {
|
487
441
|
result = propsRowSelection.getProps(record, index);
|
488
442
|
}
|
489
|
-
|
490
443
|
if (showSkeleton && result) {
|
491
444
|
result.disabled = true;
|
492
445
|
}
|
493
|
-
|
494
446
|
return result;
|
495
447
|
},
|
496
448
|
titleProps: function titleProps() {
|
497
449
|
var result = {};
|
498
|
-
|
499
450
|
if (propsRowSelection === null || propsRowSelection === void 0 ? void 0 : propsRowSelection.titleProps) {
|
500
451
|
result = propsRowSelection.titleProps();
|
501
452
|
}
|
502
|
-
|
503
453
|
if (showSkeleton || disableSelectAll) {
|
504
454
|
result.disabled = true;
|
505
455
|
}
|
506
|
-
|
507
456
|
return result;
|
508
457
|
},
|
509
458
|
onChange: onChangeRowSelection
|
@@ -512,21 +461,19 @@ var ProTable = function ProTable(props) {
|
|
512
461
|
var selectedCount = (rowSelection === null || rowSelection === void 0 ? void 0 : (_rowSelection$selecte = rowSelection.selectedRowKeys) === null || _rowSelection$selecte === void 0 ? void 0 : _rowSelection$selecte.length) || 0;
|
513
462
|
(0, _react.useEffect)(function () {
|
514
463
|
getRowSelection && getRowSelection(rowSelectionHook);
|
515
|
-
}, [rowSelectionHook]);
|
516
|
-
|
464
|
+
}, [rowSelectionHook]);
|
465
|
+
// 获取 table 左下角 checkbox 属性
|
517
466
|
function getCheckAllProps() {
|
518
467
|
var _rowSelection$onChang = rowSelection.onChange,
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
468
|
+
_onChange = _rowSelection$onChang === void 0 ? function () {} : _rowSelection$onChang,
|
469
|
+
_rowSelection$onSelec = rowSelection.onSelectAll,
|
470
|
+
onSelectAll = _rowSelection$onSelec === void 0 ? function () {} : _rowSelection$onSelec,
|
471
|
+
_rowSelection$selecte2 = rowSelection.selectedRowKeys,
|
472
|
+
selectedRowKeys = _rowSelection$selecte2 === void 0 ? [] : _rowSelection$selecte2,
|
473
|
+
getProps = rowSelection.getProps;
|
526
474
|
var dataSource = data;
|
527
475
|
var allRowKeys = dataSource.filter(function (d, i) {
|
528
476
|
var _getProps;
|
529
|
-
|
530
477
|
return getProps ? !((_getProps = getProps(d, i)) === null || _getProps === void 0 ? void 0 : _getProps.disabled) : true;
|
531
478
|
}).map(function (d) {
|
532
479
|
return (0, _utils.getDeepValue)(primaryKey || 'id', d);
|
@@ -542,15 +489,12 @@ var ProTable = function ProTable(props) {
|
|
542
489
|
result.push.apply(result, _toConsumableArray(allRowKeys.filter(function (k) {
|
543
490
|
return !selectedRowKeys.includes(k);
|
544
491
|
})));
|
545
|
-
|
546
492
|
_onChange(result, dataSource);
|
547
|
-
|
548
493
|
onSelectAll(check, dataSource);
|
549
494
|
} else {
|
550
495
|
_onChange(selectedRowKeys.filter(function (k) {
|
551
496
|
return !allRowKeys.includes(k);
|
552
497
|
}), []);
|
553
|
-
|
554
498
|
onSelectAll(check, []);
|
555
499
|
}
|
556
500
|
},
|
@@ -558,7 +502,6 @@ var ProTable = function ProTable(props) {
|
|
558
502
|
checked: nowCheckedKeys.length !== 0 && nowCheckedKeys.length === allRowKeys.length
|
559
503
|
};
|
560
504
|
}
|
561
|
-
|
562
505
|
(0, _react.useEffect)(function () {
|
563
506
|
if (typeof propsActionRef === 'function' && actionRef.current) {
|
564
507
|
// @ts-ignore
|
@@ -567,18 +510,17 @@ var ProTable = function ProTable(props) {
|
|
567
510
|
}, [propsActionRef]);
|
568
511
|
(0, _react.useEffect)(function () {
|
569
512
|
var _actionRef$current, _actionRef$current$se;
|
570
|
-
|
571
513
|
var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [], propsColumns);
|
572
514
|
setFilteredColumns(columns);
|
573
515
|
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setState) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, 'filterColumns', columns);
|
574
|
-
}, [propsColumns]);
|
575
|
-
|
516
|
+
}, [propsColumns]);
|
517
|
+
// dataSource 受控
|
576
518
|
(0, _react.useEffect)(function () {
|
577
519
|
if (propsDataSource) {
|
578
|
-
|
520
|
+
_setData(propsDataSource);
|
579
521
|
}
|
580
|
-
}, [propsDataSource]);
|
581
|
-
|
522
|
+
}, [propsDataSource]);
|
523
|
+
// 初始化 ActionRef。
|
582
524
|
(0, _utils2.initActionRef)(actionRef, {
|
583
525
|
getState: function getState() {
|
584
526
|
return actionRefState;
|
@@ -594,32 +536,28 @@ var ProTable = function ProTable(props) {
|
|
594
536
|
if (!actionRefCallback[state]) {
|
595
537
|
actionRefCallback[state] = {};
|
596
538
|
}
|
597
|
-
|
598
539
|
actionRefCallback[state][name] = fun;
|
599
540
|
},
|
600
541
|
off: function off(name) {
|
601
|
-
actionRefCallback = Object.fromEntries(Object.entries(actionRefCallback).map(function (
|
602
|
-
var
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
k = _ref4[0];
|
609
|
-
|
542
|
+
actionRefCallback = Object.fromEntries(Object.entries(actionRefCallback).map(function (_ref3) {
|
543
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
544
|
+
k = _ref4[0],
|
545
|
+
v = _ref4[1];
|
546
|
+
var filterV = Object.fromEntries(Object.entries(v).filter(function (_ref5) {
|
547
|
+
var _ref6 = _slicedToArray(_ref5, 1),
|
548
|
+
k = _ref6[0];
|
610
549
|
return k !== name;
|
611
550
|
}));
|
612
551
|
return [k, filterV];
|
613
552
|
}));
|
614
553
|
}
|
615
|
-
});
|
616
|
-
|
554
|
+
});
|
555
|
+
// 绑定 Actions
|
617
556
|
(0, _utils2.useActionType)(actionRef, {
|
618
557
|
fullScreen: function fullScreen() {
|
619
558
|
var _actionRef$current2, _actionRef$current2$s;
|
620
|
-
|
621
|
-
|
622
|
-
|
559
|
+
var state = !fullscreenState;
|
560
|
+
// 全屏时需要重新计算header高度
|
623
561
|
setFullscreenState(state);
|
624
562
|
getHeaderHeight(state);
|
625
563
|
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$s = _actionRef$current2.setState) === null || _actionRef$current2$s === void 0 ? void 0 : _actionRef$current2$s.call(_actionRef$current2, 'fullScreenState', state);
|
@@ -627,12 +565,10 @@ var ProTable = function ProTable(props) {
|
|
627
565
|
},
|
628
566
|
setColumn: function setColumn(newColumns) {
|
629
567
|
var _actionRef$current3, _actionRef$current3$s;
|
630
|
-
|
631
568
|
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
632
569
|
var columns = processColumns(newColumns, propsColumns);
|
633
570
|
setFilteredColumns(columns);
|
634
571
|
(_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setState) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, 'filterColumns', columns);
|
635
|
-
|
636
572
|
if (update) {
|
637
573
|
(0, _utils2.emit)('refreshFilterState', newColumns);
|
638
574
|
}
|
@@ -642,34 +578,46 @@ var ProTable = function ProTable(props) {
|
|
642
578
|
_setSize(mode);
|
643
579
|
},
|
644
580
|
refresh: function refresh(params) {
|
645
|
-
|
581
|
+
// card视角的刷新等于重新请求
|
582
|
+
if (switchViewState === 'card' && !propsDataSource) {
|
583
|
+
setCurrentPage(1);
|
584
|
+
_request(_objectSpread(_objectSpread({}, params), {}, _defineProperty({}, targetPageKey, 1)), undefined, undefined, true);
|
585
|
+
setShowSkeleton(true);
|
586
|
+
} else {
|
587
|
+
_request(params);
|
588
|
+
}
|
646
589
|
},
|
647
590
|
request: function request(params) {
|
648
591
|
// 如果请求中还有翻页相关信息,需要自动设置到指定页
|
649
592
|
if (params === null || params === void 0 ? void 0 : params[targetPageKey]) {
|
650
593
|
setCurrentPage(params[targetPageKey]);
|
651
594
|
}
|
652
|
-
|
653
595
|
if (params === null || params === void 0 ? void 0 : params[targetPageSizeKey]) {
|
654
596
|
setPageSize(params[targetPageSizeKey]);
|
655
597
|
}
|
656
|
-
|
657
598
|
_request(params);
|
658
599
|
},
|
659
600
|
reset: function reset() {
|
660
601
|
var _actionRef$current4, _actionRef$current4$s, _dataFilterFormRef$cu;
|
661
|
-
|
662
|
-
|
663
|
-
|
602
|
+
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
|
603
|
+
// 清空列过滤参数
|
664
604
|
(_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setFilterRules) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, {});
|
665
605
|
(_dataFilterFormRef$cu = dataFilterFormRef.current) === null || _dataFilterFormRef$cu === void 0 ? void 0 : _dataFilterFormRef$cu.reset();
|
666
606
|
setCurrentPage(1);
|
667
|
-
|
668
|
-
_request(_defineProperty({}, targetPageKey, 1));
|
607
|
+
_request(_defineProperty({}, targetPageKey, 1), undefined, undefined, true);
|
669
608
|
},
|
670
609
|
resetPage: function resetPage() {
|
671
610
|
setCurrentPage(1);
|
672
611
|
},
|
612
|
+
nextPage: function nextPage() {
|
613
|
+
var _props$paginationProp, _props$paginationProp2;
|
614
|
+
var newCurrentPage = currentPage + 1;
|
615
|
+
setCurrentPage(newCurrentPage);
|
616
|
+
props === null || props === void 0 ? void 0 : (_props$paginationProp = props.paginationProps) === null || _props$paginationProp === void 0 ? void 0 : (_props$paginationProp2 = _props$paginationProp.onChange) === null || _props$paginationProp2 === void 0 ? void 0 : _props$paginationProp2.call(_props$paginationProp, newCurrentPage, {});
|
617
|
+
if (!propsDataSource) {
|
618
|
+
_request(_defineProperty({}, targetPageKey, newCurrentPage));
|
619
|
+
}
|
620
|
+
},
|
673
621
|
rowSelection: rowSelection,
|
674
622
|
clearRowSelection: function clearRowSelection() {
|
675
623
|
rowSelectionHook.setSelectedRowKeys([]);
|
@@ -689,35 +637,84 @@ var ProTable = function ProTable(props) {
|
|
689
637
|
normalDataFilterForm: normalDataFilterForm,
|
690
638
|
fullscreenDataFilterForm: fullscreenDataFilterForm,
|
691
639
|
filterEnableRef: filterEnableRef,
|
640
|
+
setData: function setData(data) {
|
641
|
+
_setData(data);
|
642
|
+
},
|
692
643
|
resetTableMaxBodyHeight: function resetTableMaxBodyHeight(offset) {
|
693
644
|
getHeaderHeight(fullscreenState, offset);
|
645
|
+
},
|
646
|
+
switchView: function switchView(view) {
|
647
|
+
setSwitchViewState(view);
|
648
|
+
if (!propsDataSource) {
|
649
|
+
setCurrentPage(1);
|
650
|
+
}
|
651
|
+
if (view === 'table') {
|
652
|
+
setPageSize(pageSize !== null && pageSize !== void 0 ? pageSize : 20);
|
653
|
+
if (!propsDataSource) {
|
654
|
+
var _request4;
|
655
|
+
setShowSkeleton(true);
|
656
|
+
_request((_request4 = {}, _defineProperty(_request4, targetPageSizeKey, pageSize !== null && pageSize !== void 0 ? pageSize : 20), _defineProperty(_request4, targetPageKey, 1), _request4));
|
657
|
+
}
|
658
|
+
}
|
659
|
+
if (view === 'card') {
|
660
|
+
var _cardViewProps$pageSi;
|
661
|
+
setPageSize((_cardViewProps$pageSi = cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.pageSize) !== null && _cardViewProps$pageSi !== void 0 ? _cardViewProps$pageSi : 12);
|
662
|
+
if (!propsDataSource) {
|
663
|
+
var _cardViewProps$pageSi2, _request5;
|
664
|
+
setShowSkeleton(true);
|
665
|
+
_request((_request5 = {}, _defineProperty(_request5, targetPageSizeKey, (_cardViewProps$pageSi2 = cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.pageSize) !== null && _cardViewProps$pageSi2 !== void 0 ? _cardViewProps$pageSi2 : 12), _defineProperty(_request5, targetPageKey, 1), _request5));
|
666
|
+
}
|
667
|
+
}
|
668
|
+
getHeaderHeight(fullscreenState);
|
669
|
+
},
|
670
|
+
setAutoRefreshTimers: function setAutoRefreshTimers(timers) {
|
671
|
+
clearTimeout(autoRefreshTimerRef.current);
|
672
|
+
autoRefreshTimerRef.current = null;
|
673
|
+
autoRefreshTimerRef.current = setTimeout(function () {
|
674
|
+
var _actionRef$current5, _actionRef$current5$r;
|
675
|
+
(_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$r = _actionRef$current5.refresh) === null || _actionRef$current5$r === void 0 ? void 0 : _actionRef$current5$r.call(_actionRef$current5);
|
676
|
+
}, timers);
|
677
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', timers);
|
678
|
+
},
|
679
|
+
clearAutoRefreshTimers: function clearAutoRefreshTimers() {
|
680
|
+
clearTimeout(autoRefreshTimerRef.current);
|
681
|
+
autoRefreshTimerRef.current = null;
|
694
682
|
}
|
695
|
-
});
|
696
|
-
|
683
|
+
});
|
684
|
+
// 将 Actions 绑定到传入的 propsActionRef 中
|
697
685
|
if (propsActionRef) {
|
698
686
|
propsActionRef.current = actionRef.current;
|
699
687
|
}
|
700
|
-
|
701
688
|
function onFormatResult(next) {
|
702
|
-
var _next$data;
|
703
|
-
|
704
689
|
props.onFormatResult && props.onFormatResult(next);
|
705
|
-
var time =
|
706
|
-
|
690
|
+
var time = 0;
|
691
|
+
if (autoRefresh) {
|
692
|
+
time = 60 * 1000;
|
693
|
+
}
|
694
|
+
if (autoRefresh && typeof autoRefresh !== 'boolean') {
|
695
|
+
time = autoRefresh ? autoRefresh(next.data) : 0;
|
696
|
+
}
|
707
697
|
if (Number.isInteger(time) && time >= 1000) {
|
708
698
|
autoRefreshTimerRef.current = setTimeout(function () {
|
709
699
|
// 自动刷新不显示 loading
|
710
700
|
_request({}, true);
|
711
701
|
}, Number(time));
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
702
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
|
703
|
+
}
|
704
|
+
// 设置 dataSource、total
|
705
|
+
if (switchViewState === 'table' || currentPage === 1 || (cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.useTablePagination)) {
|
706
|
+
var _next$data;
|
707
|
+
_setData(next.data || []);
|
708
|
+
setTotal(next.total || ((_next$data = next.data) === null || _next$data === void 0 ? void 0 : _next$data.length));
|
709
|
+
}
|
710
|
+
if (switchViewState === 'card' && currentPage !== 1 && !(cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.useTablePagination)) {
|
711
|
+
var _next$data2;
|
712
|
+
_setData([].concat(_toConsumableArray(data), _toConsumableArray(next.data || [])));
|
713
|
+
setTotal(total + (next.total || ((_next$data2 = next.data) === null || _next$data2 === void 0 ? void 0 : _next$data2.length)));
|
714
|
+
}
|
717
715
|
setShowSkeleton(false);
|
718
|
-
}
|
719
|
-
|
720
|
-
|
716
|
+
}
|
717
|
+
// 请求表格数据工具函数
|
721
718
|
var getData = (0, _utils.useRequest)(function (params) {
|
722
719
|
return _defineProperty({
|
723
720
|
url: url,
|
@@ -726,13 +723,13 @@ var ProTable = function ProTable(props) {
|
|
726
723
|
}, {
|
727
724
|
// 使用 request 方法代替 fetch
|
728
725
|
requestMethod: function requestMethod(params) {
|
729
|
-
|
726
|
+
// 支持使用 requestConfig 自定义请求配置
|
727
|
+
return (0, _utils.request)(_objectSpread(_objectSpread({}, params), requestConfig));
|
730
728
|
},
|
731
729
|
manual: true,
|
732
730
|
onSuccess: function onSuccess(result) {
|
733
731
|
props.onSuccess && props.onSuccess(result);
|
734
732
|
var nextData = result;
|
735
|
-
|
736
733
|
if (formatResult) {
|
737
734
|
if (typeof formatResult === 'function') {
|
738
735
|
nextData = formatResult(result) || {};
|
@@ -742,9 +739,12 @@ var ProTable = function ProTable(props) {
|
|
742
739
|
data: (0, _utils.getDeepValue)(formatResult.data, result) || [],
|
743
740
|
total: isNaN(dataTotal) ? 0 : Number(dataTotal)
|
744
741
|
};
|
742
|
+
} else if (typeof formatResult === 'string') {
|
743
|
+
nextData = (0, _utils.getTargetValue)(formatResult, {
|
744
|
+
res: result
|
745
|
+
});
|
745
746
|
}
|
746
747
|
}
|
747
|
-
|
748
748
|
if (nextData instanceof Promise) {
|
749
749
|
nextData.then(function (res) {
|
750
750
|
onFormatResult(res);
|
@@ -753,62 +753,67 @@ var ProTable = function ProTable(props) {
|
|
753
753
|
});
|
754
754
|
} else {
|
755
755
|
onFormatResult(nextData);
|
756
|
-
}
|
757
|
-
|
758
|
-
|
756
|
+
}
|
757
|
+
// 重新计算是否需要吸底
|
759
758
|
if (footerSuction) {
|
760
759
|
getFooterSuctionState();
|
761
760
|
}
|
762
|
-
|
763
761
|
if (fixedTableBody) {
|
764
762
|
getHeaderHeight(fullscreenState);
|
765
763
|
}
|
766
764
|
},
|
767
765
|
onError: function onError(error) {
|
768
766
|
setShowSkeleton(false);
|
769
|
-
|
770
767
|
if (props.onError) {
|
771
768
|
props.onError(error);
|
772
|
-
} else {
|
773
|
-
|
774
|
-
|
775
|
-
|
769
|
+
} else {
|
770
|
+
// Message.error(error.toString());
|
771
|
+
}
|
772
|
+
// 重新计算是否需要吸底
|
776
773
|
if (footerSuction) {
|
777
774
|
getFooterSuctionState();
|
778
775
|
}
|
779
|
-
|
780
776
|
if (fixedTableBody) {
|
781
777
|
getHeaderHeight(fullscreenState);
|
782
778
|
}
|
783
779
|
}
|
784
|
-
});
|
785
|
-
|
786
|
-
function _request(params, noLoading, filterParams) {
|
787
|
-
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$
|
788
|
-
|
780
|
+
});
|
781
|
+
// 请求函数
|
782
|
+
function _request(params, noLoading, filterParams, isReset) {
|
783
|
+
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current6, _actionRef$current6$g, _objectSpread3;
|
784
|
+
// 首次渲染表格,获取 urlState 上的 表头 filter 数据
|
785
|
+
if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.headerFilters) !== false && dataRef.current.flag) {
|
786
|
+
(0, _util.getUrlStateFilter)(urlState !== null && urlState !== void 0 ? urlState : {}, actionRef);
|
787
|
+
dataRef.current.flag = false;
|
788
|
+
}
|
789
789
|
// 如果没有传 url 且没有 customRequest,直接返回
|
790
790
|
if (!url && !customRequest) {
|
791
791
|
return;
|
792
792
|
}
|
793
|
-
|
794
793
|
var nextShowLoading = !noLoading;
|
795
|
-
nextShowLoading !== showLoading && setShowLoading(nextShowLoading);
|
794
|
+
nextShowLoading !== showLoading && setShowLoading(nextShowLoading);
|
795
|
+
// 请求前需要优先清空列过滤条件
|
796
796
|
// actionRef.current?.setFilterRules?.({});
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
var
|
805
|
-
|
797
|
+
var sortParams = targetFormatSort(sort);
|
798
|
+
// 筛选区请求参数
|
799
|
+
var dataFilterParams = filterParams !== null && filterParams !== void 0 ? filterParams : (_dataFilterFormRef$cu2 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu2 === void 0 ? void 0 : _dataFilterFormRef$cu2.values;
|
800
|
+
// 列过滤请求参数
|
801
|
+
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$g = _actionRef$current6.getFilterRules) === null || _actionRef$current6$g === void 0 ? void 0 : _actionRef$current6$g.call(_actionRef$current6)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
|
802
|
+
// 格式化后的请求参数
|
803
|
+
var requestData = {};
|
804
|
+
var preParams = _objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((_objectSpread3 = {}, _defineProperty(_objectSpread3, targetPageKey, currentPage), _defineProperty(_objectSpread3, targetPageSizeKey, pageSize), _objectSpread3), dataFilterParams), propsParams), sortParams), columnsFilterParams)), params);
|
805
|
+
if (typeof formatParams === 'string') {
|
806
|
+
requestData = (0, _utils.getTargetValue)(formatParams, {
|
807
|
+
params: preParams
|
808
|
+
});
|
809
|
+
} else {
|
810
|
+
requestData = formatParams(preParams);
|
811
|
+
}
|
806
812
|
if (requestData) {
|
807
813
|
if (autoRefreshTimerRef.current) {
|
808
814
|
clearTimeout(autoRefreshTimerRef.current);
|
809
815
|
autoRefreshTimerRef.current = null;
|
810
816
|
}
|
811
|
-
|
812
817
|
if (!(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.searchUndefined)) {
|
813
818
|
Object.keys(requestData).forEach(function (key) {
|
814
819
|
if (requestData[key] === undefined) {
|
@@ -816,110 +821,110 @@ var ProTable = function ProTable(props) {
|
|
816
821
|
}
|
817
822
|
});
|
818
823
|
}
|
819
|
-
|
820
824
|
if (!(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.searchEmptyString)) {
|
821
825
|
Object.keys(requestData).forEach(function (key) {
|
822
826
|
if (requestData[key] === '') {
|
823
827
|
delete requestData[key];
|
824
828
|
}
|
825
829
|
});
|
826
|
-
}
|
827
|
-
|
828
|
-
|
830
|
+
}
|
831
|
+
// 如果使用自定义请求
|
829
832
|
if (customRequest && typeof customRequest === 'function') {
|
830
|
-
|
833
|
+
if (isReset) {
|
834
|
+
setShowSkeleton(true);
|
835
|
+
} else {
|
836
|
+
setCustomTableLoading(true);
|
837
|
+
}
|
831
838
|
customRequest(requestData).then(function (res) {
|
832
|
-
var
|
833
|
-
|
834
|
-
|
835
|
-
|
839
|
+
var dataRes = res.data,
|
840
|
+
totalRes = res.total,
|
841
|
+
success = res.success;
|
836
842
|
if (success === true) {
|
837
843
|
// 设置 dataSource、total
|
838
|
-
|
839
|
-
|
844
|
+
if (switchViewState === 'table' || params[targetPageKey] === 1 || isReset || (cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.useTablePagination)) {
|
845
|
+
_setData(dataRes || []);
|
846
|
+
setTotal(totalRes || (dataRes === null || dataRes === void 0 ? void 0 : dataRes.length));
|
847
|
+
}
|
848
|
+
if (switchViewState === 'card' && params[targetPageKey] !== 1 && !isReset && !(cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.useTablePagination)) {
|
849
|
+
_setData([].concat(_toConsumableArray(data), _toConsumableArray(dataRes || [])));
|
850
|
+
setTotal(total + (totalRes || (dataRes === null || dataRes === void 0 ? void 0 : dataRes.length)));
|
851
|
+
}
|
840
852
|
setShowSkeleton(false);
|
841
853
|
setCustomTableLoading(false);
|
842
|
-
}
|
843
|
-
|
844
|
-
|
854
|
+
}
|
855
|
+
// 重新计算是否需要吸底
|
845
856
|
if (footerSuction) {
|
846
857
|
getFooterSuctionState();
|
847
858
|
}
|
848
|
-
|
849
859
|
if (fixedTableBody) {
|
850
860
|
getHeaderHeight(fullscreenState);
|
851
|
-
}
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
861
|
+
}
|
862
|
+
// customRequest 中支持 autoRefresh
|
863
|
+
var time = 0;
|
864
|
+
if (autoRefresh) {
|
865
|
+
time = 60 * 1000;
|
866
|
+
}
|
867
|
+
if (autoRefresh && typeof autoRefresh !== 'boolean') {
|
868
|
+
time = autoRefresh ? autoRefresh(data) : 0;
|
869
|
+
}
|
856
870
|
if (Number.isInteger(time) && time >= 1000) {
|
857
871
|
autoRefreshTimerRef.current = setTimeout(function () {
|
858
872
|
// 自动刷新不显示 loading
|
859
|
-
_request(
|
873
|
+
_request({}, true);
|
860
874
|
}, Number(time));
|
875
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
|
861
876
|
}
|
877
|
+
}).finally(function () {
|
878
|
+
setCustomTableLoading(false);
|
862
879
|
});
|
863
880
|
} else {
|
864
881
|
getData.run(requestData);
|
865
882
|
}
|
866
883
|
}
|
867
884
|
}
|
868
|
-
|
869
885
|
function onSort(dataIndex, order) {
|
870
886
|
var nextSort = _defineProperty({}, dataIndex, order);
|
871
|
-
|
872
887
|
setSort(nextSort);
|
873
|
-
|
874
888
|
_request(targetFormatSort(nextSort));
|
875
|
-
}
|
876
|
-
|
877
|
-
|
889
|
+
}
|
890
|
+
// 处理 dataFilter 中的 onFilter、onReset
|
878
891
|
var dataFilter = _objectSpread(_objectSpread({
|
879
892
|
mode: 'inline',
|
880
893
|
forceClear: true
|
881
894
|
}, propsDataFilter), {}, {
|
882
895
|
onInit: (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) || requestWhenMount ? function (values) {
|
883
896
|
var _propsDataFilter$onIn;
|
884
|
-
|
885
897
|
// 表单初始化请求处理
|
886
898
|
propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$onIn = propsDataFilter.onInit) === null || _propsDataFilter$onIn === void 0 ? void 0 : _propsDataFilter$onIn.call(propsDataFilter, values);
|
887
899
|
!fullscreenState && requestWhenMount && _request({}, false, values);
|
888
900
|
return true;
|
889
901
|
} : undefined,
|
890
902
|
onFilter: function onFilter(values) {
|
891
|
-
var _actionRef$
|
892
|
-
|
903
|
+
var _actionRef$current7, _actionRef$current7$c;
|
893
904
|
// 全屏状态,判断全屏表单onFilter是否禁用
|
894
905
|
if (fullscreenState && !filterEnableRef.current.fullscreen) {
|
895
906
|
filterEnableRef.current.fullscreen = true;
|
896
907
|
return;
|
897
|
-
}
|
898
|
-
|
899
|
-
|
908
|
+
}
|
909
|
+
// 非全屏状态,判断普通表单onFiler是否禁用
|
900
910
|
if (!fullscreenState && !filterEnableRef.current.normal) {
|
901
911
|
filterEnableRef.current.normal = true;
|
902
912
|
return;
|
903
913
|
}
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
(_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
|
914
|
+
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
|
915
|
+
// 搜索变化时,暂时先清空选择
|
916
|
+
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
|
908
917
|
setCurrentPage(1);
|
909
|
-
|
910
918
|
_request(_defineProperty({}, targetPageKey, 1), false, values);
|
911
919
|
},
|
912
920
|
onReset: function onReset(values) {
|
913
921
|
var _dataFilterFormRef$cu3;
|
914
|
-
|
915
922
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
|
916
923
|
(_dataFilterFormRef$cu3 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu3 === void 0 ? void 0 : _dataFilterFormRef$cu3.reset();
|
917
924
|
setCurrentPage(1);
|
918
|
-
|
919
925
|
_request(_defineProperty({}, targetPageKey, 1), false, values);
|
920
926
|
}
|
921
927
|
});
|
922
|
-
|
923
928
|
var getTableLoading = function getTableLoading() {
|
924
929
|
if (!customRequest) {
|
925
930
|
return showLoading && !showSkeleton && (getData.loading || props.loading);
|
@@ -927,14 +932,14 @@ var ProTable = function ProTable(props) {
|
|
927
932
|
return showLoading && !showSkeleton && (customTableLoading || props.loading);
|
928
933
|
}
|
929
934
|
};
|
930
|
-
|
931
935
|
var renderTable = function renderTable(isFullScreen) {
|
932
936
|
if (propsColumns) {
|
933
937
|
return /*#__PURE__*/_react.default.createElement("div", {
|
934
938
|
className: (0, _classnames.default)('teamix-pro-table-container', className, 'teamix-test-request'),
|
935
939
|
"data-teamix-test-request": "url=".concat(url, "&formatResult=").concat(!!formatResult),
|
936
940
|
"data-teamix-test-params": (0, _utils.getTestRequestParams)(propsParams),
|
937
|
-
"data-teamix-test-data": (0, _utils.getTestRequestData)(propsColumns)
|
941
|
+
"data-teamix-test-data": (0, _utils.getTestRequestData)(propsColumns),
|
942
|
+
"data-teamix-spm": dataTeamixSpm
|
938
943
|
}, /*#__PURE__*/_react.default.createElement(_Layout.default, {
|
939
944
|
header: header,
|
940
945
|
mainAction: mainAction,
|
@@ -946,11 +951,20 @@ var ProTable = function ProTable(props) {
|
|
946
951
|
afterDataFilter: afterDataFilter,
|
947
952
|
dataFilterFormRef: isFullScreen ? fullscreenDataFilterFormRef : normalDataFilterFormRef,
|
948
953
|
rowSelection: rowSelection,
|
949
|
-
filterColumnType: filterColumnType
|
950
|
-
|
954
|
+
filterColumnType: filterColumnType,
|
955
|
+
fullScreenState: isFullScreen,
|
956
|
+
toolBarAutoWidth: toolBarAutoWidth,
|
957
|
+
dataTeamixSpm: dataTeamixSpm,
|
958
|
+
switchCardView: switchCardView,
|
959
|
+
defaultView: defaultView,
|
960
|
+
autoRefresh: autoRefresh,
|
961
|
+
autoRefreshProps: autoRefreshProps,
|
962
|
+
bindUrlProps: bindUrlProps,
|
963
|
+
bindUrl: bindUrl
|
964
|
+
}), switchViewState === 'table' && /*#__PURE__*/_react.default.createElement(_components.Table.StickyLock, _objectSpread({
|
951
965
|
hasBorder: false,
|
952
966
|
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
953
|
-
columns: (0, _genProColumnToColumn.default)(filteredColumns, showSkeleton, actionRef, context),
|
967
|
+
columns: (0, _genProColumnToColumn.default)(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps),
|
954
968
|
loading: getTableLoading(),
|
955
969
|
className: (0, _classnames.default)('teamix-pro-table', tableClassName, {
|
956
970
|
'with-row-select': rowSelection,
|
@@ -962,11 +976,21 @@ var ProTable = function ProTable(props) {
|
|
962
976
|
sort: sort,
|
963
977
|
primaryKey: primaryKey,
|
964
978
|
rowSelection: rowSelection,
|
965
|
-
emptyContent: /*#__PURE__*/_react.default.createElement(
|
979
|
+
emptyContent: /*#__PURE__*/_react.default.createElement(_proField.EmptyContent, _objectSpread({}, emptyProps)),
|
966
980
|
sortIcons: (0, _getTableSortIcons.default)(),
|
967
981
|
fixedHeader: fullscreenState || fixedTableBody,
|
968
982
|
maxBodyHeight: "calc(100vh - ".concat(headerHeight, "px)")
|
969
|
-
}, (0, _utils.pickProps)((0, _getTableProps.default)(), otherProps)))
|
983
|
+
}, (0, _utils.pickProps)((0, _getTableProps.default)(), otherProps))), switchViewState === 'card' && /*#__PURE__*/_react.default.createElement(_CardView.default, {
|
984
|
+
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
985
|
+
showSkeleton: showSkeleton,
|
986
|
+
loading: getTableLoading(),
|
987
|
+
originColumns: propsColumns,
|
988
|
+
cardViewProps: cardViewProps,
|
989
|
+
scrollHeight: fullscreenState || fixedTableBody ? "calc(100vh - ".concat(headerHeight, "px)") : undefined,
|
990
|
+
actionRef: actionRef,
|
991
|
+
context: context,
|
992
|
+
columns: (0, _genProColumnToColumn.default)(filteredColumns, showSkeleton, actionRef, context)
|
993
|
+
}));
|
970
994
|
} else {
|
971
995
|
// 不传 columns 直接返回原始 Table
|
972
996
|
return /*#__PURE__*/_react.default.createElement(_components.Table, _objectSpread({
|
@@ -974,67 +998,53 @@ var ProTable = function ProTable(props) {
|
|
974
998
|
}, (0, _utils.pickProps)((0, _getTableProps.default)(), otherProps)));
|
975
999
|
}
|
976
1000
|
};
|
977
|
-
|
978
1001
|
var renderFooterAction = function renderFooterAction() {
|
979
1002
|
var _footerAction$actions;
|
980
|
-
|
981
1003
|
if (_typeof(footerAction) === 'object' && (footerAction === null || footerAction === void 0 ? void 0 : (_footerAction$actions = footerAction.actions) === null || _footerAction$actions === void 0 ? void 0 : _footerAction$actions.length) >= 0) {
|
982
1004
|
// 默认 context
|
983
1005
|
var defaultContext = {
|
984
1006
|
action: actionRef.current,
|
985
1007
|
rowSelection: rowSelection
|
986
|
-
};
|
987
|
-
|
1008
|
+
};
|
1009
|
+
// 未选择的时候所有 button 默认 disabled
|
988
1010
|
var targetActions = footerAction.actions.map(function (action) {
|
989
1011
|
return _objectSpread(_objectSpread({}, action), {}, {
|
990
1012
|
disabled: (action === null || action === void 0 ? void 0 : action.disabled) || selectedCount === 0
|
991
1013
|
});
|
992
1014
|
});
|
993
|
-
|
994
1015
|
var targetFooterActions = _objectSpread(_objectSpread({}, footerAction), {}, {
|
995
1016
|
actions: targetActions
|
996
1017
|
});
|
997
|
-
|
998
1018
|
return /*#__PURE__*/_react.default.createElement("div", {
|
999
1019
|
className: cls('footer-action')
|
1000
1020
|
}, /*#__PURE__*/_react.default.createElement(_actions.ProActionGroup, _objectSpread(_objectSpread({}, targetFooterActions), {}, {
|
1001
|
-
context: _objectSpread(_objectSpread({}, defaultContext), targetFooterActions === null || targetFooterActions === void 0 ? void 0 : targetFooterActions.context)
|
1021
|
+
context: _objectSpread(_objectSpread({}, defaultContext), targetFooterActions === null || targetFooterActions === void 0 ? void 0 : targetFooterActions.context),
|
1022
|
+
"data-teamix-spm": dataTeamixSpm ? "".concat(dataTeamixSpm, "-footerAction") : undefined
|
1002
1023
|
})));
|
1003
1024
|
} else return footerAction;
|
1004
1025
|
};
|
1005
|
-
|
1006
1026
|
var renderFooter = function renderFooter() {
|
1007
1027
|
function onChangePagination(currentPage) {
|
1008
1028
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1009
|
-
|
1010
1029
|
// 翻页默认清空选择
|
1011
1030
|
if (!reserveSelectedRecords) {
|
1012
|
-
var _actionRef$
|
1013
|
-
|
1014
|
-
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
|
1031
|
+
var _actionRef$current8, _actionRef$current8$c;
|
1032
|
+
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
|
1015
1033
|
}
|
1016
|
-
|
1017
1034
|
setCurrentPage(currentPage);
|
1018
|
-
|
1019
1035
|
_request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
|
1020
1036
|
}
|
1021
|
-
|
1022
1037
|
function onChangePaginationSize(currentPageSize) {
|
1023
|
-
var
|
1024
|
-
|
1038
|
+
var _request8;
|
1025
1039
|
// 翻页默认清空选择
|
1026
1040
|
if (!reserveSelectedRecords) {
|
1027
|
-
var _actionRef$
|
1028
|
-
|
1029
|
-
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
|
1041
|
+
var _actionRef$current9, _actionRef$current9$c;
|
1042
|
+
(_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
|
1030
1043
|
}
|
1031
|
-
|
1032
1044
|
setPageSize(currentPageSize);
|
1033
1045
|
setCurrentPage(1);
|
1034
|
-
|
1035
|
-
_request((_request5 = {}, _defineProperty(_request5, targetPageSizeKey, currentPageSize), _defineProperty(_request5, targetPageKey, 1), _request5));
|
1046
|
+
_request((_request8 = {}, _defineProperty(_request8, targetPageSizeKey, currentPageSize), _defineProperty(_request8, targetPageKey, 1), _request8));
|
1036
1047
|
}
|
1037
|
-
|
1038
1048
|
function renderRowSelection() {
|
1039
1049
|
if (rowSelection) {
|
1040
1050
|
if (showSkeleton) {
|
@@ -1044,28 +1054,43 @@ var ProTable = function ProTable(props) {
|
|
1044
1054
|
} else {
|
1045
1055
|
return /*#__PURE__*/_react.default.createElement("div", {
|
1046
1056
|
className: cls('footer-left-wrapper')
|
1047
|
-
}, rowSelection.mode !== 'single' && /*#__PURE__*/_react.default.createElement(_components.Checkbox, _objectSpread({
|
1057
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, rowSelection.mode !== 'single' && /*#__PURE__*/_react.default.createElement(_components.Checkbox, _objectSpread({
|
1048
1058
|
className: cls("footer-checkbox-".concat(size))
|
1049
1059
|
}, getCheckAllProps())), footerAction && renderFooterAction(), /*#__PURE__*/_react.default.createElement("span", {
|
1050
1060
|
className: cls('selected-msg')
|
1051
1061
|
}, (0, _utils.getMessage)('selected', {
|
1052
1062
|
count: selectedCount
|
1053
|
-
})));
|
1063
|
+
}))));
|
1064
|
+
}
|
1065
|
+
} else if (footerAction) {
|
1066
|
+
if (showSkeleton) {
|
1067
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
1068
|
+
className: cls('footer-left-wrapper')
|
1069
|
+
}, /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Operation, null));
|
1070
|
+
} else {
|
1071
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
1072
|
+
className: cls('footer-left-wrapper')
|
1073
|
+
}, footerAction && renderFooterAction());
|
1054
1074
|
}
|
1055
1075
|
}
|
1056
1076
|
}
|
1057
|
-
|
1058
|
-
|
1077
|
+
if (showPagination && switchViewState === 'table' || (cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.useTablePagination) && switchViewState === 'card') {
|
1078
|
+
var _props$paginationProp3;
|
1079
|
+
var _ref8 = (_props$paginationProp3 = props === null || props === void 0 ? void 0 : props.paginationProps) !== null && _props$paginationProp3 !== void 0 ? _props$paginationProp3 : {},
|
1080
|
+
onPaginationPropsChange = _ref8.onChange,
|
1081
|
+
othersPaginationProps = _objectWithoutProperties(_ref8, _excluded2);
|
1059
1082
|
return /*#__PURE__*/_react.default.createElement("div", {
|
1060
1083
|
className: cls('footer', {
|
1061
|
-
'footer-has-rowSelection': rowSelection
|
1084
|
+
'footer-has-rowSelection': rowSelection,
|
1085
|
+
'footer-has-action': footerAction
|
1062
1086
|
})
|
1063
1087
|
}, renderRowSelection(), /*#__PURE__*/_react.default.createElement("div", {
|
1064
1088
|
className: cls('footer-right-wrapper')
|
1065
1089
|
}, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, data.length > 0 && /*#__PURE__*/_react.default.createElement(_Pagination.default, _objectSpread({
|
1066
1090
|
className: cls('pagination'),
|
1067
|
-
onChange: function onChange(number) {
|
1068
|
-
|
1091
|
+
onChange: function onChange(number, e) {
|
1092
|
+
onChangePagination(number);
|
1093
|
+
onPaginationPropsChange === null || onPaginationPropsChange === void 0 ? void 0 : onPaginationPropsChange(number, e);
|
1069
1094
|
},
|
1070
1095
|
total: total,
|
1071
1096
|
responsivePaginationType: responsivePaginationType,
|
@@ -1084,8 +1109,8 @@ var ProTable = function ProTable(props) {
|
|
1084
1109
|
onPageSizeChange: function onPageSizeChange(number) {
|
1085
1110
|
return onChangePaginationSize(number);
|
1086
1111
|
}
|
1087
|
-
},
|
1088
|
-
} else if (!showPagination) {
|
1112
|
+
}, othersPaginationProps)))));
|
1113
|
+
} else if (!showPagination && (footerAction || rowSelection || useRowSelection)) {
|
1089
1114
|
return /*#__PURE__*/_react.default.createElement("div", {
|
1090
1115
|
className: cls('footer', {
|
1091
1116
|
'footer-has-rowSelection': rowSelection
|
@@ -1094,20 +1119,18 @@ var ProTable = function ProTable(props) {
|
|
1094
1119
|
className: cls('footer-right-wrapper')
|
1095
1120
|
}, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : footer));
|
1096
1121
|
}
|
1097
|
-
};
|
1098
|
-
|
1099
|
-
|
1122
|
+
};
|
1123
|
+
// 判断是否需要吸底
|
1100
1124
|
var fixFooterState = (0, _react.useMemo)(function () {
|
1101
1125
|
if (fullscreenState) {
|
1126
|
+
// TODO XXX
|
1102
1127
|
return false;
|
1103
1128
|
}
|
1104
|
-
|
1105
1129
|
if (fixedTableBody || footerSuction) {
|
1106
1130
|
if (footerSuctionState) {
|
1107
1131
|
return true;
|
1108
1132
|
}
|
1109
1133
|
}
|
1110
|
-
|
1111
1134
|
return false;
|
1112
1135
|
}, [fullscreenState, fixedTableBody, footerSuction, footerSuctionState]);
|
1113
1136
|
return /*#__PURE__*/_react.default.createElement(_Fullscreen.default, {
|
@@ -1117,13 +1140,12 @@ var ProTable = function ProTable(props) {
|
|
1117
1140
|
return /*#__PURE__*/_react.default.createElement("div", {
|
1118
1141
|
className: cls({
|
1119
1142
|
'': true,
|
1120
|
-
fullscreen:
|
1121
|
-
|
1143
|
+
fullscreen: isFullScreen
|
1144
|
+
// 'footer-suction': footerSuctionState && footerSuction,
|
1122
1145
|
}),
|
1123
1146
|
ref: tableRef
|
1124
1147
|
}, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
|
1125
1148
|
});
|
1126
1149
|
};
|
1127
|
-
|
1128
1150
|
var _default = ProTable;
|
1129
1151
|
exports.default = _default;
|