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