tntd 1.3.57 → 1.3.62

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 (110) hide show
  1. package/babel.config.js +2 -2
  2. package/components/Layout/Application.js +1 -1
  3. package/components/QueryForm/Field/index.js +2 -1
  4. package/components/QueryListScene/List.js +17 -13
  5. package/lib/0645cf743e4e44ca9da321d689897f07.png +0 -0
  6. package/lib/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  7. package/lib/1d0b52448de217857b270af807e9360d.png +0 -0
  8. package/lib/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  9. package/lib/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  10. package/lib/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  11. package/lib/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  12. package/lib/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  13. package/lib/4abe481e130d7be0574e45573de8beb7.png +0 -0
  14. package/lib/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  15. package/lib/ArrayInput/icon.js +31 -27
  16. package/lib/ArrayInput/index.js +298 -211
  17. package/lib/AuthContext.js +13 -2
  18. package/lib/BlockHeader/README.md +83 -0
  19. package/lib/BlockHeader/fonts/OswaldLight.ttf +0 -0
  20. package/lib/BlockHeader/index.js +42 -0
  21. package/lib/BlockHeader/index.less +141 -0
  22. package/lib/Columns/index.js +100 -71
  23. package/lib/DevelopmentLogin/LoginModal.js +141 -79
  24. package/lib/DevelopmentLogin/index.js +55 -28
  25. package/lib/Ellipsis/Svg/CopySVG.js +71 -23
  26. package/lib/Ellipsis/Svg/TickSVG.js +49 -17
  27. package/lib/Ellipsis/index.js +155 -149
  28. package/lib/Handle/index.js +109 -72
  29. package/lib/Icon/fonts/iconfont.js +43 -1
  30. package/lib/Icon/iconList.js +8 -119
  31. package/lib/Icon/index.js +45 -13
  32. package/lib/Img/Contain.js +81 -49
  33. package/lib/Img/Cover.js +136 -88
  34. package/lib/Img/index.js +89 -36
  35. package/lib/Layout/ActionsContext.js +11 -2
  36. package/lib/Layout/AppList.js +256 -262
  37. package/lib/Layout/Application.js +135 -119
  38. package/lib/Layout/Avatar.js +137 -137
  39. package/lib/Layout/CompatibleLanguage.js +195 -214
  40. package/lib/Layout/EnterpriseLayout/Avatar.js +168 -156
  41. package/lib/Layout/EnterpriseLayout/Language.js +100 -75
  42. package/lib/Layout/EnterpriseLayout/Theme.js +94 -96
  43. package/lib/Layout/EnterpriseLayout/index.js +45 -32
  44. package/lib/Layout/GlobalNavigation/NavigationPopup.js +407 -335
  45. package/lib/Layout/GlobalNavigation/index.js +158 -110
  46. package/lib/Layout/Header.js +116 -165
  47. package/lib/Layout/HeaderActions.js +129 -170
  48. package/lib/Layout/HeaderNavs.js +113 -90
  49. package/lib/Layout/HeaderTabs.js +278 -312
  50. package/lib/Layout/Iconfont.js +15 -2
  51. package/lib/Layout/Language.js +102 -63
  52. package/lib/Layout/Layout.js +261 -272
  53. package/lib/Layout/Logo.js +87 -132
  54. package/lib/Layout/OrgAppList.js +319 -440
  55. package/lib/Layout/SideMenu.js +343 -429
  56. package/lib/Layout/Theme.js +124 -95
  57. package/lib/Layout/checkAuth.js +35 -21
  58. package/lib/Layout/createActions.js +51 -38
  59. package/lib/Layout/images/index.js +41 -33
  60. package/lib/Layout/index.js +161 -110
  61. package/lib/Layout/locale.js +53 -0
  62. package/lib/Layout/paaslayout/CompactSideMenu.js +178 -200
  63. package/lib/Layout/paaslayout/Header.js +90 -84
  64. package/lib/Layout/paaslayout/Logo.js +32 -27
  65. package/lib/Layout/paaslayout/SideMenu.js +174 -161
  66. package/lib/Layout/paaslayout/index.js +261 -240
  67. package/lib/Layout/paaslayout/index.less +75 -0
  68. package/lib/Layout/storage.js +78 -20
  69. package/lib/Layout/utils.js +143 -93
  70. package/lib/LoadingButton/index.js +57 -29
  71. package/lib/Modal/index.js +108 -83
  72. package/lib/Page/Box.js +81 -56
  73. package/lib/Page/index.js +173 -151
  74. package/lib/Page/utils.js +30 -12
  75. package/lib/QueryForm/Field/Checkbox.js +33 -11
  76. package/lib/QueryForm/Field/Select.js +99 -63
  77. package/lib/QueryForm/Field/SelectInput.js +114 -69
  78. package/lib/QueryForm/Field/fieldsMap.js +52 -30
  79. package/lib/QueryForm/Field/index.js +158 -75
  80. package/lib/QueryForm/createActions.js +65 -50
  81. package/lib/QueryForm/index.js +382 -303
  82. package/lib/QueryForm/useForm.js +17 -6
  83. package/lib/QueryListScene/Field/SelectInput.js +115 -0
  84. package/lib/QueryListScene/Field/fieldsMap.js +52 -0
  85. package/lib/QueryListScene/Field/index.js +159 -0
  86. package/lib/QueryListScene/Field/select.js +100 -0
  87. package/lib/QueryListScene/List.js +362 -285
  88. package/lib/QueryListScene/QueryForm/index.js +423 -0
  89. package/lib/QueryListScene/QueryForm/index.less +141 -0
  90. package/lib/QueryListScene/QueryForm.js +159 -91
  91. package/lib/QueryListScene/QueryListScene.js +87 -33
  92. package/lib/QueryListScene/Title.js +20 -10
  93. package/lib/QueryListScene/Toolbar.js +31 -8
  94. package/lib/QueryListScene/createActions.js +79 -64
  95. package/lib/QueryListScene/index.js +40 -23
  96. package/lib/QueryListScene/useActions.js +17 -6
  97. package/lib/Select/DropDownWrap.js +124 -60
  98. package/lib/Select/index.js +563 -426
  99. package/lib/Table/ResizableTable/index.js +121 -77
  100. package/lib/Table/index.js +51 -19
  101. package/lib/Title/index.js +52 -34
  102. package/lib/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  103. package/lib/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  104. package/lib/index.html +6 -0
  105. package/lib/index.js +159 -19
  106. package/lib/locale.js +63 -48
  107. package/lib/main.css +16420 -0
  108. package/lib/tntd.js +2 -0
  109. package/lib/tntd.js.LICENSE.txt +36 -0
  110. package/package.json +1 -1
@@ -1,312 +1,389 @@
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
- }
1
+ "use strict";
36
2
 
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
- }
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
92
7
 
93
- onWindowResize = debounce(() => {
94
- const {scroll} = this.state;
8
+ require("antd/es/spin/style");
95
9
 
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
- this.fetchData(this.formData).finally(() => {
114
- // 轮询
115
- if (qlsProps.interval && !this.isUnmounted) {
116
- const doIntervalQuery = ms => {
117
- // 组件unmounted后,不执行轮训逻辑
118
- if (!this.isUnmounted) {
119
- this.timmer = setTimeout(() => {
120
- // 如果有查询请求还未结束,则该次轮询不执行,重新设置下次轮询
121
- if (!this.isFetching) {
122
- this.fetchData(actions.getSubmittedFormData(), {
123
- isInterval: true,
124
- showLoading: false
125
- }).then(() => {
126
- doIntervalQuery(ms);
127
- });
128
- }
129
- else {
130
- doIntervalQuery(ms);
131
- }
132
- }, ms);
133
- }
134
- };
135
- doIntervalQuery(qlsProps.interval);
136
- }
137
- });
10
+ var _spin = _interopRequireDefault(require("antd/es/spin"));
138
11
 
139
- if (this.state.scroll?.y) {
140
- window.addEventListener('resize', this.onWindowResize);
12
+ var _react = _interopRequireWildcard(require("react"));
141
13
 
142
- if (this.tableRef.current) {
143
- // table内垂直滚动,需要动态设置分页组件上阴影样式
144
- const tableBody = findDOMNode(this.tableRef.current).querySelector('.ant-table-body');
145
- this.initialTop = window.innerHeight - this.state.scroll.y;
146
- this.updateIsScrollToBottom(tableBody);
147
- tableBody.addEventListener('scroll', this.onTableBodyScroll);
148
- }
149
- }
150
- }
14
+ var _reactDom = require("react-dom");
151
15
 
152
- componentWillUnmount() {
153
- const { actions } = this.props;
16
+ var _classnames = _interopRequireDefault(require("classnames"));
154
17
 
155
- this.isUnmounted = true;
18
+ var _lodash = require("lodash");
156
19
 
157
- actions.removeListener('search', this.onSearch);
158
- actions.removeListener('setTableDataSource', this.updateDataSource);
159
- actions.removeListener('setPagination', this.updatePagination);
160
- actions.removeListener('setFormData', this.onFormChange);
161
- window.removeEventListener('resize', this.onWindowResize);
162
- this.timmer && clearTimeout(this.timmer);
163
- }
20
+ var _Table = _interopRequireDefault(require("../Table"));
164
21
 
165
- fetchData = (params = {}, { callback, showLoading = true, isInterval } = {}) => {
166
- const {
167
- qlsProps: { query },
168
- defaultExpandAllRows,
169
- rowKey,
170
- actions
171
- } = this.props;
172
- const {pagination} = this.state;
173
- const hasPagination = this.props.pagination !== false;
174
-
175
- if (hasPagination) {
176
- params = {
177
- pageSize: pagination.pageSize,
178
- current: pagination.current,
179
- ...params
180
- };
181
- }
22
+ var _locale = require("../locale");
182
23
 
183
- showLoading && this.setState({
184
- loading: true
185
- });
24
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
186
25
 
187
- // 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
188
- if (!isInterval) {
189
- this.isFetching = true;
190
- }
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; }
191
27
 
192
- actions.setData('submittedFormData', params);
193
-
194
- return query(
195
- pickBy(params, val => (val !== '' && val !== null && val !== undefined))
196
- ).then(result => {
197
- const dataSource = hasPagination ? result.data || [] : result;
198
-
199
- this.setState(
200
- {
201
- loading: false,
202
- dataSource,
203
- pagination: hasPagination ? {
204
- pageSize: result.pageSize || pagination.pageSize || 10,
205
- current: result.current || params.current || pagination.current || 1,
206
- total: result.total || 0
207
- } : null,
208
- ...(defaultExpandAllRows ? {
209
- expandedRowKeys: dataSource.map(row => row[rowKey])
210
- } : {})
211
- },
212
- () => {
213
- actions.setData('pagination', this.state.pagination);
214
- actions.setData('dataSource', this.state.dataSource);
215
- }
216
- );
217
- }).finally(() => {
218
- this.isFetching = false;
219
- showLoading && this.setState({
220
- loading: false
221
- });
222
- callback && callback();
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);
82
+
83
+ _this.fetchData = function () {
84
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
85
+
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;
91
+
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;
99
+
100
+ if (hasPagination) {
101
+ params = _objectSpread({
102
+ pageSize: pagination.pageSize,
103
+ current: pagination.current
104
+ }, params);
105
+ }
106
+
107
+ showLoading && _this.setState({
108
+ loading: true
109
+ }); // 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
110
+
111
+ if (!isInterval) {
112
+ _this.isFetching = true;
113
+ }
114
+
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;
120
+
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);
223
136
  });
137
+ })["finally"](function () {
138
+ _this.isFetching = false;
139
+ showLoading && _this.setState({
140
+ loading: false
141
+ });
142
+ callback && callback();
143
+ });
224
144
  };
225
145
 
226
- updateDataSource = dataSource => {
227
- this.setState({
228
- dataSource
229
- });
230
- this.props.actions.setData('dataSource', dataSource);
146
+ _this.updateDataSource = function (dataSource) {
147
+ _this.setState({
148
+ dataSource: dataSource
149
+ });
150
+
151
+ _this.props.actions.setData('dataSource', dataSource);
231
152
  };
232
153
 
233
- updatePagination = pagination => {
234
- this.setState({
235
- pagination
236
- });
237
- this.props.actions.setData('pagination', pagination);
238
- }
154
+ _this.updatePagination = function (pagination) {
155
+ _this.setState({
156
+ pagination: pagination
157
+ });
239
158
 
240
- onFormChange = values => {
241
- this.formData = pickBy({
242
- ...values,
243
- sorter: get(this.formData, 'sorter'),
244
- filters: get(this.formData, 'filters')
245
- }, val => val !== undefined);
246
- }
159
+ _this.props.actions.setData('pagination', pagination);
160
+ };
247
161
 
248
- onSearch = (values, {callback, showLoading = true} = {}) => {
249
- this.formData = {
250
- ...this.formData,
251
- ...values
252
- };
253
- // this.props.actions.setData('formData', this.formData);
254
- return this.fetchData(this.formData, {callback, showLoading});
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
+ });
255
169
  };
256
170
 
257
- onTableChange = (pagination, filters, sorter) => {
258
- const { actions, localPagination } = this.props;
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;
259
176
 
260
- this.formData = {
261
- ...this.formData,
262
- pageSize: pagination.pageSize,
177
+ _this.formData = _objectSpread({}, _this.formData, {}, values); // this.props.actions.setData('formData', this.formData);
178
+
179
+ return _this.fetchData(_this.formData, {
180
+ callback: callback,
181
+ showLoading: showLoading
182
+ });
183
+ };
184
+
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: {
263
211
  current: pagination.current,
264
- filters: isEmpty(filters) ? undefined : filters,
265
- sorter: isEmpty(sorter) ? undefined : sorter
266
- };
267
-
268
- // 排序变化暂时不处理,因为有时可能是前端sorter不需要走请求
269
- // 所以暂时排序有使用者自己处理
270
- if (!localPagination) {
271
- this.fetchData(this.formData);
272
- return;
273
- }
212
+ 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);
274
227
 
275
- const { dataSource } = this.state;
276
-
277
- // 前端本地分页
278
- if (localPagination) {
279
- this.setState(
280
- {
281
- dataSource,
282
- pagination: {
283
- current: pagination.current,
284
- pageSize: pagination.pageSize,
285
- total: pagination.total
286
- }
287
- },
288
- () => {
289
- actions.setData('formData', this.formData);
290
- actions.setData('pagination', this.state.pagination);
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
+ };
235
+
236
+ _this.setState({
237
+ hasScrollToBottom: isScrollToBottom(tableBody)
238
+ });
239
+ };
240
+
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
+ this.fetchData(this.formData)["finally"](function () {
334
+ // 轮询
335
+ if (qlsProps.interval && !_this2.isUnmounted) {
336
+ var doIntervalQuery = function doIntervalQuery(ms) {
337
+ // 组件unmounted后,不执行轮训逻辑
338
+ if (!_this2.isUnmounted) {
339
+ _this2.timmer = setTimeout(function () {
340
+ // 如果有查询请求还未结束,则该次轮询不执行,重新设置下次轮询
341
+ if (!_this2.isFetching) {
342
+ _this2.fetchData(actions.getSubmittedFormData(), {
343
+ isInterval: true,
344
+ showLoading: false
345
+ }).then(function () {
346
+ doIntervalQuery(ms);
347
+ });
348
+ } else {
349
+ doIntervalQuery(ms);
291
350
  }
292
- );
351
+ }, ms);
352
+ }
353
+ };
354
+
355
+ doIntervalQuery(qlsProps.interval);
293
356
  }
294
- };
295
-
296
- onTableBodyScroll = throttle(evt => {
297
- console.log('onTableBodyScroll', evt.target.scrollTop);
298
- this.updateIsScrollToBottom(evt.target);
299
- }, 50)
300
-
301
- updateIsScrollToBottom = tableBody => {
302
- const isScrollToBottom = tableBody => {
303
- const { scrollHeight, scrollTop, offsetHeight } = tableBody;
304
-
305
- return scrollHeight === scrollTop + offsetHeight;
306
- };
307
-
308
- this.setState({
309
- hasScrollToBottom: isScrollToBottom(tableBody)
310
- });
357
+ });
358
+
359
+ if ((_this$state$scroll = this.state.scroll) == null ? void 0 : _this$state$scroll.y) {
360
+ window.addEventListener('resize', this.onWindowResize);
361
+
362
+ if (this.tableRef.current) {
363
+ // table内垂直滚动,需要动态设置分页组件上阴影样式
364
+ var tableBody = (0, _reactDom.findDOMNode)(this.tableRef.current).querySelector('.ant-table-body');
365
+ this.initialTop = window.innerHeight - this.state.scroll.y;
366
+ this.updateIsScrollToBottom(tableBody);
367
+ tableBody.addEventListener('scroll', this.onTableBodyScroll);
368
+ }
369
+ }
370
+ }
371
+ }, {
372
+ key: "componentWillUnmount",
373
+ value: function componentWillUnmount() {
374
+ var actions = this.props.actions;
375
+ this.isUnmounted = true;
376
+ actions.removeListener('search', this.onSearch);
377
+ actions.removeListener('setTableDataSource', this.updateDataSource);
378
+ actions.removeListener('setPagination', this.updatePagination);
379
+ actions.removeListener('setFormData', this.onFormChange);
380
+ window.removeEventListener('resize', this.onWindowResize);
381
+ this.timmer && clearTimeout(this.timmer);
311
382
  }
312
- };
383
+ }]);
384
+
385
+ return QueryList;
386
+ }(_react["default"].PureComponent);
387
+
388
+ exports["default"] = QueryList;
389
+ ;