tntd 1.4.4 → 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.
- package/components/Layout/HeaderActions.js +90 -128
- package/components/LoadingButton/index.js +11 -15
- package/components/QueryListScene/QueryForm.js +7 -4
- package/dist/stats.json +4990 -4990
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/es/QueryListScene/QueryForm.js +6 -3
- package/lib/ArrayInput/icon.js +27 -31
- package/lib/ArrayInput/index.js +211 -298
- package/lib/AuthContext.js +2 -13
- package/lib/Columns/index.js +71 -100
- package/lib/DevelopmentLogin/LoginModal.js +79 -141
- package/lib/DevelopmentLogin/index.js +28 -55
- package/lib/Ellipsis/Svg/CopySVG.js +23 -71
- package/lib/Ellipsis/Svg/TickSVG.js +17 -49
- package/lib/Ellipsis/index.js +148 -154
- package/lib/Handle/index.js +72 -109
- package/lib/Icon/fonts/iconfont.js +1 -43
- package/lib/Icon/iconList.js +119 -8
- package/lib/Icon/index.js +13 -45
- package/lib/Img/Contain.js +49 -81
- package/lib/Img/Cover.js +88 -136
- package/lib/Img/index.js +36 -89
- package/lib/Layout/ActionsContext.js +2 -11
- package/lib/Layout/AppList.js +262 -256
- package/lib/Layout/Application.js +119 -135
- package/lib/Layout/Avatar.js +137 -137
- package/lib/Layout/CompatibleLanguage.js +214 -195
- package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
- package/lib/Layout/EnterpriseLayout/Language.js +75 -100
- package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
- package/lib/Layout/EnterpriseLayout/index.js +32 -45
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
- package/lib/Layout/GlobalNavigation/index.js +110 -158
- package/lib/Layout/Header.js +165 -116
- package/lib/Layout/HeaderActions.js +132 -129
- package/lib/Layout/HeaderNavs.js +90 -113
- package/lib/Layout/HeaderTabs.js +312 -278
- package/lib/Layout/Iconfont.js +2 -15
- package/lib/Layout/Language.js +63 -102
- package/lib/Layout/Layout.js +272 -261
- package/lib/Layout/Logo.js +132 -87
- package/lib/Layout/OrgAppList.js +440 -319
- package/lib/Layout/SideMenu.js +429 -343
- package/lib/Layout/Theme.js +95 -124
- package/lib/Layout/checkAuth.js +21 -35
- package/lib/Layout/createActions.js +38 -51
- package/lib/Layout/images/index.js +33 -41
- package/lib/Layout/index.js +110 -161
- package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
- package/lib/Layout/paaslayout/Header.js +84 -90
- package/lib/Layout/paaslayout/Logo.js +27 -32
- package/lib/Layout/paaslayout/SideMenu.js +161 -174
- package/lib/Layout/paaslayout/index.js +240 -261
- package/lib/Layout/storage.js +20 -78
- package/lib/Layout/utils.js +93 -143
- package/lib/LoadingButton/index.js +25 -57
- package/lib/Modal/index.js +83 -108
- package/lib/Page/Box.js +56 -81
- package/lib/Page/index.js +151 -173
- package/lib/Page/utils.js +12 -30
- package/lib/QueryForm/Field/Checkbox.js +11 -33
- package/lib/QueryForm/Field/Select.js +63 -99
- package/lib/QueryForm/Field/SelectInput.js +69 -114
- package/lib/QueryForm/Field/fieldsMap.js +30 -52
- package/lib/QueryForm/Field/index.js +76 -158
- package/lib/QueryForm/createActions.js +50 -65
- package/lib/QueryForm/index.js +304 -383
- package/lib/QueryForm/useForm.js +6 -17
- package/lib/QueryListScene/List.js +290 -366
- package/lib/QueryListScene/QueryForm.js +93 -158
- package/lib/QueryListScene/QueryListScene.js +33 -87
- package/lib/QueryListScene/Title.js +10 -20
- package/lib/QueryListScene/Toolbar.js +8 -31
- package/lib/QueryListScene/createActions.js +64 -79
- package/lib/QueryListScene/index.js +23 -40
- package/lib/QueryListScene/useActions.js +6 -17
- package/lib/Select/DropDownWrap.js +60 -124
- package/lib/Select/index.js +425 -561
- package/lib/Table/ResizableTable/index.js +77 -121
- package/lib/Table/index.js +19 -51
- package/lib/Title/index.js +34 -52
- package/lib/index.js +19 -159
- package/lib/locale.js +48 -63
- package/package.json +1 -1
- package/lib/Layout/EnterpriseLayout/Header.js +0 -113
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
|
@@ -1,393 +1,317 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
pageSize: pagination.pageSize,
|
|
103
|
-
current: pagination.current
|
|
104
|
-
}, params);
|
|
105
|
-
}
|
|
153
|
+
componentWillUnmount() {
|
|
154
|
+
const { actions } = this.props;
|
|
106
155
|
|
|
107
|
-
|
|
108
|
-
loading: true
|
|
109
|
-
}); // 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
|
|
156
|
+
this.isUnmounted = true;
|
|
110
157
|
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
_this.setState({
|
|
156
|
-
pagination: pagination
|
|
157
|
-
});
|
|
188
|
+
// 当用户操作查询还未得到服务端响应前,不要执行轮询请求时序问题导致覆盖
|
|
189
|
+
if (!isInterval) {
|
|
190
|
+
this.isFetching = true;
|
|
191
|
+
}
|
|
158
192
|
|
|
159
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
234
|
+
updatePagination = pagination => {
|
|
235
|
+
this.setState({
|
|
236
|
+
pagination
|
|
237
|
+
});
|
|
238
|
+
this.props.actions.setData('pagination', pagination);
|
|
239
|
+
}
|
|
176
240
|
|
|
177
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
237
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
306
|
+
updateIsScrollToBottom = tableBody => {
|
|
307
|
+
const isScrollToBottom = tableBody => {
|
|
308
|
+
const { scrollHeight, scrollTop, offsetHeight } = tableBody;
|
|
362
309
|
|
|
363
|
-
|
|
364
|
-
|
|
310
|
+
return scrollHeight === scrollTop + offsetHeight;
|
|
311
|
+
};
|
|
365
312
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
+
};
|