tntd 1.4.6 → 1.4.7

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.
Files changed (86) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/dist/stats.json +4958 -4958
  4. package/dist/tntd.js +1 -1
  5. package/es/Layout/HeaderActions.js +10 -10
  6. package/es/LoadingButton/index.js +20 -10
  7. package/lib/ArrayInput/icon.js +27 -31
  8. package/lib/ArrayInput/index.js +211 -298
  9. package/lib/AuthContext.js +2 -13
  10. package/lib/Columns/index.js +71 -100
  11. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  12. package/lib/DevelopmentLogin/index.js +28 -55
  13. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  14. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  15. package/lib/Ellipsis/index.js +148 -154
  16. package/lib/Handle/index.js +72 -109
  17. package/lib/Icon/fonts/iconfont.js +1 -43
  18. package/lib/Icon/iconList.js +119 -8
  19. package/lib/Icon/index.js +13 -45
  20. package/lib/Img/Contain.js +49 -81
  21. package/lib/Img/Cover.js +88 -136
  22. package/lib/Img/index.js +36 -89
  23. package/lib/Layout/ActionsContext.js +2 -11
  24. package/lib/Layout/AppList.js +262 -256
  25. package/lib/Layout/Application.js +119 -135
  26. package/lib/Layout/Avatar.js +137 -137
  27. package/lib/Layout/CompatibleLanguage.js +214 -195
  28. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  29. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  30. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  31. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  32. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  33. package/lib/Layout/GlobalNavigation/index.js +110 -158
  34. package/lib/Layout/Header.js +165 -116
  35. package/lib/Layout/HeaderActions.js +132 -129
  36. package/lib/Layout/HeaderNavs.js +90 -113
  37. package/lib/Layout/HeaderTabs.js +312 -278
  38. package/lib/Layout/Iconfont.js +2 -15
  39. package/lib/Layout/Language.js +63 -102
  40. package/lib/Layout/Layout.js +272 -261
  41. package/lib/Layout/Logo.js +132 -87
  42. package/lib/Layout/OrgAppList.js +440 -319
  43. package/lib/Layout/SideMenu.js +429 -343
  44. package/lib/Layout/Theme.js +95 -124
  45. package/lib/Layout/checkAuth.js +21 -35
  46. package/lib/Layout/createActions.js +38 -51
  47. package/lib/Layout/images/index.js +33 -41
  48. package/lib/Layout/index.js +110 -161
  49. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  50. package/lib/Layout/paaslayout/Header.js +84 -90
  51. package/lib/Layout/paaslayout/Logo.js +27 -32
  52. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  53. package/lib/Layout/paaslayout/index.js +240 -261
  54. package/lib/Layout/storage.js +20 -78
  55. package/lib/Layout/utils.js +93 -143
  56. package/lib/LoadingButton/index.js +25 -57
  57. package/lib/Modal/index.js +83 -108
  58. package/lib/Page/Box.js +56 -81
  59. package/lib/Page/index.js +151 -173
  60. package/lib/Page/utils.js +12 -30
  61. package/lib/QueryForm/Field/Checkbox.js +11 -33
  62. package/lib/QueryForm/Field/Select.js +63 -99
  63. package/lib/QueryForm/Field/SelectInput.js +69 -114
  64. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  65. package/lib/QueryForm/Field/index.js +76 -158
  66. package/lib/QueryForm/createActions.js +50 -65
  67. package/lib/QueryForm/index.js +304 -383
  68. package/lib/QueryForm/useForm.js +6 -17
  69. package/lib/QueryListScene/List.js +290 -366
  70. package/lib/QueryListScene/QueryForm.js +93 -161
  71. package/lib/QueryListScene/QueryListScene.js +33 -87
  72. package/lib/QueryListScene/Title.js +10 -20
  73. package/lib/QueryListScene/Toolbar.js +8 -31
  74. package/lib/QueryListScene/createActions.js +64 -79
  75. package/lib/QueryListScene/index.js +23 -40
  76. package/lib/QueryListScene/useActions.js +6 -17
  77. package/lib/Select/DropDownWrap.js +60 -124
  78. package/lib/Select/index.js +425 -561
  79. package/lib/Table/ResizableTable/index.js +77 -121
  80. package/lib/Table/index.js +19 -51
  81. package/lib/Title/index.js +34 -52
  82. package/lib/index.js +19 -159
  83. package/lib/locale.js +48 -63
  84. package/package.json +1 -1
  85. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  86. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -1,393 +1,317 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- require("antd/lib/spin/style");
9
-
10
- var _spin = _interopRequireDefault(require("antd/lib/spin"));
11
-
12
- var _react = _interopRequireWildcard(require("react"));
13
-
14
- var _reactDom = require("react-dom");
15
-
16
- var _classnames = _interopRequireDefault(require("classnames"));
17
-
18
- var _lodash = require("lodash");
19
-
20
- var _Table = _interopRequireDefault(require("../Table"));
21
-
22
- var _locale = require("../locale");
23
-
24
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
25
-
26
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
-
30
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
31
-
32
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
33
-
34
- 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; }
35
-
36
- 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; }
37
-
38
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
39
-
40
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
41
-
42
- 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; }
43
-
44
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
45
-
46
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
47
-
48
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
49
-
50
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
51
-
52
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
53
-
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
55
-
56
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
57
-
58
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
59
-
60
- var QueryList =
61
- /*#__PURE__*/
62
- function (_React$PureComponent) {
63
- _inherits(QueryList, _React$PureComponent);
64
-
65
- function QueryList(props) {
66
- var _props$scroll;
67
-
68
- var _this;
69
-
70
- _classCallCheck(this, QueryList);
71
-
72
- _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryList).call(this, props));
73
- _this.onWindowResize = (0, _lodash.debounce)(function () {
74
- var scroll = _this.state.scroll;
75
-
76
- _this.setState({
77
- scroll: _objectSpread({}, scroll, {
78
- y: window.innerHeight - (_this.initialTop || _this.props.top || 200)
79
- })
80
- });
81
- }, 50);
1
+ /**
2
+ * @file QueryList
3
+ * @author you.zhang
4
+ */
5
+ import React, { createRef } from 'react';
6
+ import { findDOMNode } from 'react-dom';
7
+ import cn from 'classnames';
8
+ import { get, pickBy, isEmpty, debounce, throttle } from 'lodash';
9
+ import { Spin } from 'antd';
10
+ import Table from '../Table';
11
+ import { getText, getLanguage } from '../locale';
12
+
13
+ export default class QueryList extends React.PureComponent {
14
+ constructor(props) {
15
+ super(props);
16
+ this.state = {
17
+ loading: false,
18
+ dataSource: [],
19
+ pagination: {
20
+ // pageSize: 20,
21
+ current: 1,
22
+ total: 0
23
+ },
24
+ scroll: props.scroll,
25
+ hasScrollToBottom: !props.scroll?.y
26
+ };
27
+
28
+ this.tableRef = createRef();
29
+
30
+ const { actions } = props;
31
+ actions.on('search', this.onSearch);
32
+ actions.on('setTableDataSource', this.updateDataSource);
33
+ actions.on('setPagination', this.updatePagination);
34
+ actions.on('setFormData', this.onFormChange);
35
+ }
82
36
 
83
- _this.fetchData = function () {
84
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
37
+ render() {
38
+ const {
39
+ columns,
40
+ children,
41
+ pagination,
42
+ localPagination = false,
43
+ paginationSticky = false,
44
+ className = '',
45
+ qlsProps,
46
+ ...rest
47
+ } = this.props;
48
+ const {
49
+ dataSource,
50
+ loading,
51
+ expandedRowKeys = [],
52
+ scroll,
53
+ hasScrollToBottom,
54
+ } = this.state;
55
+ const hasPagination = typeof pagination !== 'undefined' ? pagination : true;
56
+ const paginationInfo = {
57
+ ...this.state.pagination,
58
+ // size: 'small',
59
+ showQuickJumper: true,
60
+ showSizeChanger: true,
61
+ showTotal: total => getText('totalRecords', getLanguage(), total),
62
+ ...(pagination || {})
63
+ };
64
+ const expandProps = {
65
+ ...(rest.defaultExpandAllRows ? {
66
+ expandedRowKeys,
67
+ onExpandedRowsChange: this.onExpandedRowsChange
68
+ } : {})
69
+ };
70
+
71
+ return (
72
+ <div className={cn(`tnt-querylistscene-list ${className}`, { paginationSticky, hasScrollToBottom })}>
73
+ <Spin spinning={loading}>
74
+ <Table
75
+ ref={this.tableRef}
76
+ {...expandProps}
77
+ {...rest}
78
+ {...(columns ? {
79
+ columns
80
+ } : {})}
81
+ scroll={scroll}
82
+ dataSource={dataSource}
83
+ pagination={hasPagination ? paginationInfo : localPagination}
84
+ onChange={this.onTableChange}
85
+ >
86
+ {!columns && children}
87
+ </Table>
88
+ </Spin>
89
+ </div>
90
+ );
91
+ }
85
92
 
86
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
87
- callback = _ref.callback,
88
- _ref$showLoading = _ref.showLoading,
89
- showLoading = _ref$showLoading === void 0 ? true : _ref$showLoading,
90
- isInterval = _ref.isInterval;
93
+ onWindowResize = debounce(() => {
94
+ const { scroll } = this.state;
91
95
 
92
- var _this$props = _this.props,
93
- query = _this$props.qlsProps.query,
94
- defaultExpandAllRows = _this$props.defaultExpandAllRows,
95
- rowKey = _this$props.rowKey,
96
- actions = _this$props.actions;
97
- var pagination = _this.state.pagination;
98
- var hasPagination = _this.props.pagination !== false;
96
+ this.setState({
97
+ scroll: {
98
+ ...scroll,
99
+ y: window.innerHeight - (this.initialTop || this.props.top || 200)
100
+ }
101
+ });
102
+ }, 50)
103
+
104
+ componentDidMount() {
105
+ const { qlsProps, actions } = this.props;
106
+
107
+ this.formData = {
108
+ ...(actions.getFormData() || {}),
109
+ // 记住上次查询的分页参数
110
+ ...(qlsProps.memory ? actions.getPagination() : {})
111
+ };
112
+
113
+ if (!qlsProps.initSearch) { // 默认进来不请求
114
+ this.fetchData(this.formData).finally(() => {
115
+ // 轮询
116
+ if (qlsProps.interval && !this.isUnmounted) {
117
+ const doIntervalQuery = ms => {
118
+ // 组件unmounted后,不执行轮训逻辑
119
+ if (!this.isUnmounted) {
120
+ this.timmer = setTimeout(() => {
121
+ // 如果有查询请求还未结束,则该次轮询不执行,重新设置下次轮询
122
+ if (!this.isFetching) {
123
+ this.fetchData(actions.getSubmittedFormData(), {
124
+ isInterval: true,
125
+ showLoading: false
126
+ }).then(() => {
127
+ doIntervalQuery(ms);
128
+ });
129
+ }
130
+ else {
131
+ doIntervalQuery(ms);
132
+ }
133
+ }, ms);
134
+ }
135
+ };
136
+ doIntervalQuery(qlsProps.interval);
137
+ }
138
+ });
139
+ }
140
+ if (this.state.scroll?.y) {
141
+ window.addEventListener('resize', this.onWindowResize);
142
+
143
+ if (this.tableRef.current) {
144
+ // table内垂直滚动,需要动态设置分页组件上阴影样式
145
+ const tableBody = findDOMNode(this.tableRef.current).querySelector('.ant-table-body');
146
+ this.initialTop = window.innerHeight - this.state.scroll.y;
147
+ this.updateIsScrollToBottom(tableBody);
148
+ tableBody.addEventListener('scroll', this.onTableBodyScroll);
149
+ }
150
+ }
151
+ }
99
152
 
100
- if (hasPagination) {
101
- params = _objectSpread({
102
- pageSize: pagination.pageSize,
103
- current: pagination.current
104
- }, params);
105
- }
153
+ componentWillUnmount() {
154
+ const { actions } = this.props;
106
155
 
107
- showLoading && _this.setState({
108
- loading: true
109
- }); // 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
156
+ this.isUnmounted = true;
110
157
 
111
- if (!isInterval) {
112
- _this.isFetching = true;
113
- }
158
+ actions.removeListener('search', this.onSearch);
159
+ actions.removeListener('setTableDataSource', this.updateDataSource);
160
+ actions.removeListener('setPagination', this.updatePagination);
161
+ actions.removeListener('setFormData', this.onFormChange);
162
+ window.removeEventListener('resize', this.onWindowResize);
163
+ this.timmer && clearTimeout(this.timmer);
164
+ }
114
165
 
115
- actions.setData('submittedFormData', params);
116
- return query((0, _lodash.pickBy)(params, function (val) {
117
- return val !== '' && val !== null && val !== undefined;
118
- })).then(function (result) {
119
- var dataSource = hasPagination ? result.data || [] : result;
166
+ fetchData = (params = {}, { callback, showLoading = true, isInterval } = {}) => {
167
+ const {
168
+ qlsProps: { query },
169
+ defaultExpandAllRows,
170
+ rowKey,
171
+ actions
172
+ } = this.props;
173
+ const { pagination } = this.state;
174
+ const hasPagination = this.props.pagination !== false;
175
+
176
+ if (hasPagination) {
177
+ params = {
178
+ pageSize: pagination.pageSize,
179
+ current: pagination.current,
180
+ ...params
181
+ };
182
+ }
120
183
 
121
- _this.setState(_objectSpread({
122
- loading: false,
123
- dataSource: dataSource,
124
- pagination: hasPagination ? {
125
- pageSize: result.pageSize || pagination.pageSize || 10,
126
- current: result.current || params.current || pagination.current || 1,
127
- total: result.total || 0
128
- } : null
129
- }, defaultExpandAllRows ? {
130
- expandedRowKeys: dataSource.map(function (row) {
131
- return row[rowKey];
132
- })
133
- } : {}), function () {
134
- actions.setData('pagination', _this.state.pagination);
135
- actions.setData('dataSource', _this.state.dataSource);
136
- });
137
- })["finally"](function () {
138
- _this.isFetching = false;
139
- showLoading && _this.setState({
140
- loading: false
184
+ showLoading && this.setState({
185
+ loading: true
141
186
  });
142
- callback && callback();
143
- });
144
- };
145
-
146
- _this.updateDataSource = function (dataSource) {
147
- _this.setState({
148
- dataSource: dataSource
149
- });
150
187
 
151
- _this.props.actions.setData('dataSource', dataSource);
152
- };
153
-
154
- _this.updatePagination = function (pagination) {
155
- _this.setState({
156
- pagination: pagination
157
- });
188
+ // 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
189
+ if (!isInterval) {
190
+ this.isFetching = true;
191
+ }
158
192
 
159
- _this.props.actions.setData('pagination', pagination);
193
+ actions.setData('submittedFormData', params);
194
+
195
+ return query(
196
+ pickBy(params, val => (val !== '' && val !== null && val !== undefined))
197
+ ).then(result => {
198
+ const dataSource = hasPagination ? result.data || [] : result;
199
+
200
+ this.setState(
201
+ {
202
+ loading: false,
203
+ dataSource,
204
+ pagination: hasPagination ? {
205
+ pageSize: result.pageSize || pagination.pageSize || 10,
206
+ current: result.current || params.current || pagination.current || 1,
207
+ total: result.total || 0
208
+ } : null,
209
+ ...(defaultExpandAllRows ? {
210
+ expandedRowKeys: dataSource.map(row => row[rowKey])
211
+ } : {})
212
+ },
213
+ () => {
214
+ actions.setData('pagination', this.state.pagination);
215
+ actions.setData('dataSource', this.state.dataSource);
216
+ }
217
+ );
218
+ }).finally(() => {
219
+ this.isFetching = false;
220
+ showLoading && this.setState({
221
+ loading: false
222
+ });
223
+ callback && callback();
224
+ });
160
225
  };
161
226
 
162
- _this.onFormChange = function (values) {
163
- _this.formData = (0, _lodash.pickBy)(_objectSpread({}, values, {
164
- sorter: (0, _lodash.get)(_this.formData, 'sorter'),
165
- filters: (0, _lodash.get)(_this.formData, 'filters')
166
- }), function (val) {
167
- return val !== undefined;
168
- });
227
+ updateDataSource = dataSource => {
228
+ this.setState({
229
+ dataSource
230
+ });
231
+ this.props.actions.setData('dataSource', dataSource);
169
232
  };
170
233
 
171
- _this.onSearch = function (values) {
172
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
173
- callback = _ref2.callback,
174
- _ref2$showLoading = _ref2.showLoading,
175
- showLoading = _ref2$showLoading === void 0 ? true : _ref2$showLoading;
234
+ updatePagination = pagination => {
235
+ this.setState({
236
+ pagination
237
+ });
238
+ this.props.actions.setData('pagination', pagination);
239
+ }
176
240
 
177
- _this.formData = _objectSpread({}, _this.formData, {}, values); // this.props.actions.setData('formData', this.formData);
241
+ onFormChange = values => {
242
+ this.formData = pickBy({
243
+ ...values,
244
+ sorter: get(this.formData, 'sorter'),
245
+ filters: get(this.formData, 'filters')
246
+ }, val => val !== undefined);
247
+ }
178
248
 
179
- return _this.fetchData(_this.formData, {
180
- callback: callback,
181
- showLoading: showLoading
182
- });
249
+ onSearch = (values, { callback, showLoading = true } = {}) => {
250
+ this.formData = {
251
+ ...this.formData,
252
+ ...values
253
+ };
254
+ // this.props.actions.setData('formData', this.formData);
255
+ return this.fetchData(this.formData, { callback, showLoading });
183
256
  };
184
257
 
185
- _this.onTableChange = function (pagination, filters, sorter) {
186
- var _this$props2 = _this.props,
187
- actions = _this$props2.actions,
188
- localPagination = _this$props2.localPagination;
189
- var tableParams = {
190
- pageSize: pagination.pageSize,
191
- current: pagination.current,
192
- filters: (0, _lodash.isEmpty)(filters) ? undefined : filters,
193
- sorter: (0, _lodash.isEmpty)(sorter) ? undefined : sorter
194
- };
195
- console.log('onTableChange...', actions.getSubmittedFormData(), _this.formData);
196
- Object.assign(_this.formData, tableParams); // 排序变化暂时不处理,因为有时可能是前端sorter不需要走请求
197
- // 所以暂时排序有使用者自己处理
198
-
199
- if (!localPagination) {
200
- _this.fetchData(_objectSpread({}, actions.getSubmittedFormData(), {}, tableParams));
201
-
202
- return;
203
- }
204
-
205
- var dataSource = _this.state.dataSource; // 前端本地分页
206
-
207
- if (localPagination) {
208
- _this.setState({
209
- dataSource: dataSource,
210
- pagination: {
211
- current: pagination.current,
258
+ onTableChange = (pagination, filters, sorter) => {
259
+ const { actions, localPagination } = this.props;
260
+ const tableParams = {
212
261
  pageSize: pagination.pageSize,
213
- total: pagination.total
214
- }
215
- }, function () {
216
- actions.setData('formData', _this.formData);
217
- actions.setData('pagination', _this.state.pagination);
218
- });
219
- }
220
- };
221
-
222
- _this.onTableBodyScroll = (0, _lodash.throttle)(function (evt) {
223
- console.log('onTableBodyScroll', evt.target.scrollTop);
224
-
225
- _this.updateIsScrollToBottom(evt.target);
226
- }, 50);
227
-
228
- _this.updateIsScrollToBottom = function (tableBody) {
229
- var isScrollToBottom = function isScrollToBottom(tableBody) {
230
- var scrollHeight = tableBody.scrollHeight,
231
- scrollTop = tableBody.scrollTop,
232
- offsetHeight = tableBody.offsetHeight;
233
- return scrollHeight === scrollTop + offsetHeight;
234
- };
262
+ current: pagination.current,
263
+ filters: isEmpty(filters) ? undefined : filters,
264
+ sorter: isEmpty(sorter) ? undefined : sorter
265
+ };
266
+ console.log('onTableChange...', actions.getSubmittedFormData(), this.formData);
267
+
268
+ Object.assign(this.formData, tableParams);
269
+
270
+ // 排序变化暂时不处理,因为有时可能是前端sorter不需要走请求
271
+ // 所以暂时排序有使用者自己处理
272
+ if (!localPagination) {
273
+ this.fetchData({
274
+ ...actions.getSubmittedFormData(),
275
+ ...tableParams
276
+ });
277
+ return;
278
+ }
235
279
 
236
- _this.setState({
237
- hasScrollToBottom: isScrollToBottom(tableBody)
238
- });
280
+ const { dataSource } = this.state;
281
+
282
+ // 前端本地分页
283
+ if (localPagination) {
284
+ this.setState(
285
+ {
286
+ dataSource,
287
+ pagination: {
288
+ current: pagination.current,
289
+ pageSize: pagination.pageSize,
290
+ total: pagination.total
291
+ }
292
+ },
293
+ () => {
294
+ actions.setData('formData', this.formData);
295
+ actions.setData('pagination', this.state.pagination);
296
+ }
297
+ );
298
+ }
239
299
  };
240
300
 
241
- _this.state = {
242
- loading: false,
243
- dataSource: [],
244
- pagination: {
245
- // pageSize: 20,
246
- current: 1,
247
- total: 0
248
- },
249
- scroll: props.scroll,
250
- hasScrollToBottom: !((_props$scroll = props.scroll) == null ? void 0 : _props$scroll.y)
251
- };
252
- _this.tableRef = (0, _react.createRef)();
253
- var _actions = props.actions;
254
-
255
- _actions.on('search', _this.onSearch);
256
-
257
- _actions.on('setTableDataSource', _this.updateDataSource);
258
-
259
- _actions.on('setPagination', _this.updatePagination);
260
-
261
- _actions.on('setFormData', _this.onFormChange);
262
-
263
- return _this;
264
- }
265
-
266
- _createClass(QueryList, [{
267
- key: "render",
268
- value: function render() {
269
- var _this$props3 = this.props,
270
- columns = _this$props3.columns,
271
- children = _this$props3.children,
272
- pagination = _this$props3.pagination,
273
- _this$props3$localPag = _this$props3.localPagination,
274
- localPagination = _this$props3$localPag === void 0 ? false : _this$props3$localPag,
275
- _this$props3$paginati = _this$props3.paginationSticky,
276
- paginationSticky = _this$props3$paginati === void 0 ? false : _this$props3$paginati,
277
- _this$props3$classNam = _this$props3.className,
278
- className = _this$props3$classNam === void 0 ? '' : _this$props3$classNam,
279
- qlsProps = _this$props3.qlsProps,
280
- rest = _objectWithoutProperties(_this$props3, ["columns", "children", "pagination", "localPagination", "paginationSticky", "className", "qlsProps"]);
281
-
282
- var _this$state = this.state,
283
- dataSource = _this$state.dataSource,
284
- loading = _this$state.loading,
285
- _this$state$expandedR = _this$state.expandedRowKeys,
286
- expandedRowKeys = _this$state$expandedR === void 0 ? [] : _this$state$expandedR,
287
- scroll = _this$state.scroll,
288
- hasScrollToBottom = _this$state.hasScrollToBottom;
289
- var hasPagination = typeof pagination !== 'undefined' ? pagination : true;
290
-
291
- var paginationInfo = _objectSpread({}, this.state.pagination, {
292
- // size: 'small',
293
- showQuickJumper: true,
294
- showSizeChanger: true,
295
- showTotal: function showTotal(total) {
296
- return (0, _locale.getText)('totalRecords', (0, _locale.getLanguage)(), total);
297
- }
298
- }, pagination || {});
299
-
300
- var expandProps = _objectSpread({}, rest.defaultExpandAllRows ? {
301
- expandedRowKeys: expandedRowKeys,
302
- onExpandedRowsChange: this.onExpandedRowsChange
303
- } : {});
304
-
305
- return _react["default"].createElement("div", {
306
- className: (0, _classnames["default"])("tnt-querylistscene-list ".concat(className), {
307
- paginationSticky: paginationSticky,
308
- hasScrollToBottom: hasScrollToBottom
309
- })
310
- }, _react["default"].createElement(_spin["default"], {
311
- spinning: loading
312
- }, _react["default"].createElement(_Table["default"], _extends({
313
- ref: this.tableRef
314
- }, expandProps, rest, columns ? {
315
- columns: columns
316
- } : {}, {
317
- scroll: scroll,
318
- dataSource: dataSource,
319
- pagination: hasPagination ? paginationInfo : localPagination,
320
- onChange: this.onTableChange
321
- }), !columns && children)));
322
- }
323
- }, {
324
- key: "componentDidMount",
325
- value: function componentDidMount() {
326
- var _this2 = this,
327
- _this$state$scroll;
328
-
329
- var _this$props4 = this.props,
330
- qlsProps = _this$props4.qlsProps,
331
- actions = _this$props4.actions;
332
- this.formData = _objectSpread({}, actions.getFormData() || {}, {}, qlsProps.memory ? actions.getPagination() : {});
333
-
334
- if (!qlsProps.initSearch) {
335
- // 默认进来不请求
336
- this.fetchData(this.formData)["finally"](function () {
337
- // 轮询
338
- if (qlsProps.interval && !_this2.isUnmounted) {
339
- var doIntervalQuery = function doIntervalQuery(ms) {
340
- // 组件unmounted后,不执行轮训逻辑
341
- if (!_this2.isUnmounted) {
342
- _this2.timmer = setTimeout(function () {
343
- // 如果有查询请求还未结束,则该次轮询不执行,重新设置下次轮询
344
- if (!_this2.isFetching) {
345
- _this2.fetchData(actions.getSubmittedFormData(), {
346
- isInterval: true,
347
- showLoading: false
348
- }).then(function () {
349
- doIntervalQuery(ms);
350
- });
351
- } else {
352
- doIntervalQuery(ms);
353
- }
354
- }, ms);
355
- }
356
- };
301
+ onTableBodyScroll = throttle(evt => {
302
+ console.log('onTableBodyScroll', evt.target.scrollTop);
303
+ this.updateIsScrollToBottom(evt.target);
304
+ }, 50)
357
305
 
358
- doIntervalQuery(qlsProps.interval);
359
- }
360
- });
361
- }
306
+ updateIsScrollToBottom = tableBody => {
307
+ const isScrollToBottom = tableBody => {
308
+ const { scrollHeight, scrollTop, offsetHeight } = tableBody;
362
309
 
363
- if ((_this$state$scroll = this.state.scroll) == null ? void 0 : _this$state$scroll.y) {
364
- window.addEventListener('resize', this.onWindowResize);
310
+ return scrollHeight === scrollTop + offsetHeight;
311
+ };
365
312
 
366
- if (this.tableRef.current) {
367
- // table内垂直滚动,需要动态设置分页组件上阴影样式
368
- var tableBody = (0, _reactDom.findDOMNode)(this.tableRef.current).querySelector('.ant-table-body');
369
- this.initialTop = window.innerHeight - this.state.scroll.y;
370
- this.updateIsScrollToBottom(tableBody);
371
- tableBody.addEventListener('scroll', this.onTableBodyScroll);
372
- }
373
- }
374
- }
375
- }, {
376
- key: "componentWillUnmount",
377
- value: function componentWillUnmount() {
378
- var actions = this.props.actions;
379
- this.isUnmounted = true;
380
- actions.removeListener('search', this.onSearch);
381
- actions.removeListener('setTableDataSource', this.updateDataSource);
382
- actions.removeListener('setPagination', this.updatePagination);
383
- actions.removeListener('setFormData', this.onFormChange);
384
- window.removeEventListener('resize', this.onWindowResize);
385
- this.timmer && clearTimeout(this.timmer);
313
+ this.setState({
314
+ hasScrollToBottom: isScrollToBottom(tableBody)
315
+ });
386
316
  }
387
- }]);
388
-
389
- return QueryList;
390
- }(_react["default"].PureComponent);
391
-
392
- exports["default"] = QueryList;
393
- ;
317
+ };