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