fmui-base 2.2.11 → 2.2.12
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/README.md +1 -0
- package/lib/form/form.js +4 -2
- package/lib/react_grid/react_grid.js +8 -8
- package/package.json +1 -1
- package/lib/ScrollList/BottomTip.jsx +0 -25
- package/lib/ScrollList/EmptyContent.jsx +0 -19
- package/lib/ScrollList/Item.jsx +0 -132
- package/lib/ScrollList/ScrollList.jsx +0 -412
- package/lib/ScrollList/TagList.jsx +0 -54
- package/lib/button/button.jsx +0 -46
- package/lib/care/care.jsx +0 -26
- package/lib/chart/chart.jsx +0 -344
- package/lib/comment_list/List.jsx +0 -285
- package/lib/form/form.jsx +0 -3434
- package/lib/form/subForm.jsx +0 -793
- package/lib/form/table.jsx +0 -1804
- package/lib/form_info/formInfo.jsx +0 -5158
- package/lib/loading/loading.jsx +0 -23
- package/lib/no_data/no_data.jsx +0 -34
- package/lib/poppage/check.jsx +0 -500
- package/lib/poppage/table/table.jsx +0 -641
- package/lib/poppage/tree/tree.jsx +0 -548
- package/lib/poppage/treetable/treetable.jsx +0 -340
- package/lib/positioning/positioning.jsx +0 -92
- package/lib/process_batch/processBatch.jsx +0 -1629
- package/lib/process_info/processInfo.jsx +0 -7752
- package/lib/process_list/processList.jsx +0 -1299
- package/lib/react_grid/react_grid.jsx +0 -1166
- package/lib/select-fileno/pageHome.jsx +0 -569
- package/lib/select-serialnumber/pageHome.jsx +0 -503
- package/lib/select-serialnumber/pageHome1.jsx +0 -503
- package/lib/selectMember/select.jsx +0 -9568
- package/lib/signature/sign.jsx +0 -274
- package/lib/upload/upload.jsx +0 -647
package/README.md
CHANGED
package/lib/form/form.js
CHANGED
|
@@ -3166,15 +3166,17 @@ var PageHome = function (_React$Component) {
|
|
|
3166
3166
|
_react2.default.createElement(
|
|
3167
3167
|
'div',
|
|
3168
3168
|
{ className: 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3169
|
-
_react2.default.createElement(
|
|
3169
|
+
_react2.default.createElement(_TextareaField2.default, {
|
|
3170
3170
|
className: 't-W100',
|
|
3171
3171
|
required: t.state.itemParam.required,
|
|
3172
3172
|
readOnly: t.state.itemParam.readOnly,
|
|
3173
3173
|
label: t.state.itemParam.title,
|
|
3174
|
+
minRows: 1,
|
|
3175
|
+
maxRows: 1,
|
|
3174
3176
|
placeholder: t.state.itemParam.readOnly ? '' : t.state.itemParam.placeholder,
|
|
3175
3177
|
value: t.state.itemParam.value,
|
|
3176
3178
|
onChange: function onChange(value) {
|
|
3177
|
-
t.
|
|
3179
|
+
t.handleTextAreaChange(t.state.itemParam, value);
|
|
3178
3180
|
}
|
|
3179
3181
|
// onFocus={(value) => { t.handleTextFocus(t.state.itemParam, value); }}
|
|
3180
3182
|
// onBlur={(value) => { t.handleTextBlur(t.state.itemParam, value); }}
|
|
@@ -621,7 +621,7 @@ var MyGrid = function (_React$Component) {
|
|
|
621
621
|
var componentContent = _react2.default.createElement(
|
|
622
622
|
'div',
|
|
623
623
|
null,
|
|
624
|
-
_react2.default.createElement('img', { className: 't-
|
|
624
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
625
625
|
);
|
|
626
626
|
var componentHead = '';
|
|
627
627
|
if (item.portletCode === 'banner') {
|
|
@@ -773,7 +773,7 @@ var MyGrid = function (_React$Component) {
|
|
|
773
773
|
) : _react2.default.createElement(
|
|
774
774
|
'div',
|
|
775
775
|
null,
|
|
776
|
-
_react2.default.createElement('img', { className: 't-
|
|
776
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
777
777
|
)
|
|
778
778
|
),
|
|
779
779
|
_react2.default.createElement(
|
|
@@ -823,7 +823,7 @@ var MyGrid = function (_React$Component) {
|
|
|
823
823
|
) : _react2.default.createElement(
|
|
824
824
|
'div',
|
|
825
825
|
null,
|
|
826
|
-
_react2.default.createElement('img', { className: 't-
|
|
826
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
827
827
|
)
|
|
828
828
|
)
|
|
829
829
|
)
|
|
@@ -855,7 +855,7 @@ var MyGrid = function (_React$Component) {
|
|
|
855
855
|
commonList = _react2.default.createElement(
|
|
856
856
|
'div',
|
|
857
857
|
null,
|
|
858
|
-
_react2.default.createElement('img', { className: 't-
|
|
858
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
859
859
|
);
|
|
860
860
|
}
|
|
861
861
|
}
|
|
@@ -886,7 +886,7 @@ var MyGrid = function (_React$Component) {
|
|
|
886
886
|
colectionList = _react2.default.createElement(
|
|
887
887
|
'div',
|
|
888
888
|
null,
|
|
889
|
-
_react2.default.createElement('img', { className: 't-
|
|
889
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
890
890
|
);
|
|
891
891
|
}
|
|
892
892
|
}
|
|
@@ -1118,7 +1118,7 @@ var MyGrid = function (_React$Component) {
|
|
|
1118
1118
|
{ className: 'info-more-btn', onClick: t.jumpPage.bind(this, "/channelDetail/" + item.channelId + '/' + item.columnId + '/' + item.columnName) },
|
|
1119
1119
|
'\u67E5\u770B\u66F4\u591A'
|
|
1120
1120
|
)
|
|
1121
|
-
) : _react2.default.createElement('img', { className: 't-
|
|
1121
|
+
) : _react2.default.createElement('img', { className: 't-PL10 t-PR10 t-MT16', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
1122
1122
|
);
|
|
1123
1123
|
});
|
|
1124
1124
|
}
|
|
@@ -1184,7 +1184,7 @@ var MyGrid = function (_React$Component) {
|
|
|
1184
1184
|
gryjContent = _react2.default.createElement(
|
|
1185
1185
|
'div',
|
|
1186
1186
|
null,
|
|
1187
|
-
_react2.default.createElement('img', { className: 't-
|
|
1187
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
1188
1188
|
);
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
@@ -1239,7 +1239,7 @@ var MyGrid = function (_React$Component) {
|
|
|
1239
1239
|
ggyjContent = _react2.default.createElement(
|
|
1240
1240
|
'div',
|
|
1241
1241
|
null,
|
|
1242
|
-
_react2.default.createElement('img', { className: 't-
|
|
1242
|
+
_react2.default.createElement('img', { className: 't-PL10 t-PR10', style: { height: '88px', margin: 'auto', display: 'block' }, src: '../../../fmui/images/home/nodata.png' })
|
|
1243
1243
|
);
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
class BottomTip extends React.Component {
|
|
5
|
-
static displayName = 'BottomTip';
|
|
6
|
-
static defaultProps = {
|
|
7
|
-
text: '',
|
|
8
|
-
icon: null,
|
|
9
|
-
};
|
|
10
|
-
static propTypes = {
|
|
11
|
-
icon: PropTypes.element,
|
|
12
|
-
text: PropTypes.string,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
render() {
|
|
16
|
-
return (
|
|
17
|
-
<div className="bottom-tip">
|
|
18
|
-
{this.props.icon}
|
|
19
|
-
<div className="text">{this.props.text}</div>
|
|
20
|
-
</div>);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default BottomTip;
|
|
25
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
const EmptyContent = props => (
|
|
5
|
-
<div key="empty-content" className="empty-content">
|
|
6
|
-
{props.image ? <div className="icon" style={{ backgroundImage: `url(${props.image})` }} /> : null}
|
|
7
|
-
{props.text ? <div className="text">{props.text}</div> : null}
|
|
8
|
-
</div>
|
|
9
|
-
);
|
|
10
|
-
EmptyContent.defaultProps = {
|
|
11
|
-
image: undefined,
|
|
12
|
-
text: undefined,
|
|
13
|
-
};
|
|
14
|
-
EmptyContent.propTypes = {
|
|
15
|
-
image: PropTypes.string,
|
|
16
|
-
text: PropTypes.string,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default EmptyContent;
|
package/lib/ScrollList/Item.jsx
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import Badge from 'saltui/lib/Badge';
|
|
5
|
-
|
|
6
|
-
class Item extends React.Component {
|
|
7
|
-
static propTypes = {
|
|
8
|
-
prefixCls: PropTypes.string,
|
|
9
|
-
className: PropTypes.string,
|
|
10
|
-
img: PropTypes.string,
|
|
11
|
-
avatar: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
12
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
13
|
-
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
14
|
-
badge: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.number, PropTypes.bool]),
|
|
15
|
-
badgePosition: PropTypes.string,
|
|
16
|
-
desMaxLine: PropTypes.number,
|
|
17
|
-
extra: PropTypes.any,
|
|
18
|
-
borderType: PropTypes.string,
|
|
19
|
-
onClick: PropTypes.func,
|
|
20
|
-
};
|
|
21
|
-
static defaultProps = {
|
|
22
|
-
prefixCls: 't-scroll-list-item',
|
|
23
|
-
desMaxLine: 2,
|
|
24
|
-
className: undefined,
|
|
25
|
-
img: undefined,
|
|
26
|
-
avatar: undefined,
|
|
27
|
-
title: undefined,
|
|
28
|
-
description: undefined,
|
|
29
|
-
badge: undefined,
|
|
30
|
-
badgePosition: 'followTitle', // indicator/followTitle/titleRight
|
|
31
|
-
extra: undefined,
|
|
32
|
-
borderType: '',
|
|
33
|
-
onClick: () => {},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
renderImg() {
|
|
37
|
-
const { img, prefixCls } = this.props;
|
|
38
|
-
if (typeof img === 'string') {
|
|
39
|
-
return (<img alt="" className={`${prefixCls}-img`} src={img} />);
|
|
40
|
-
}
|
|
41
|
-
return img;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
renderAvatar() {
|
|
45
|
-
const { avatar, prefixCls } = this.props;
|
|
46
|
-
if (typeof avatar === 'string') {
|
|
47
|
-
return (<img alt="" className={`${prefixCls}-avatar`} src={avatar} />);
|
|
48
|
-
}
|
|
49
|
-
return avatar;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
renderTitle() {
|
|
53
|
-
const { title, prefixCls, badgePosition } = this.props;
|
|
54
|
-
if (!title) return null;
|
|
55
|
-
return (
|
|
56
|
-
<div className={classnames(`${prefixCls}-title`, {
|
|
57
|
-
[badgePosition]: true,
|
|
58
|
-
})}
|
|
59
|
-
>{title}{badgePosition === 'indicator' ? null : this.renderBadge()}
|
|
60
|
-
</div>);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
renderBadge() {
|
|
64
|
-
const { badge, prefixCls } = this.props;
|
|
65
|
-
const className = `${prefixCls}-badge`;
|
|
66
|
-
if (typeof badge === 'string') {
|
|
67
|
-
return (<Badge text={badge} className={className} />);
|
|
68
|
-
} else if (typeof badge === 'number') {
|
|
69
|
-
return (<Badge count={badge} className={className} />);
|
|
70
|
-
} else if (typeof badge === 'boolean') {
|
|
71
|
-
return (<Badge dot className={className} />);
|
|
72
|
-
}
|
|
73
|
-
return badge;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
renderDes() {
|
|
77
|
-
const { description, prefixCls, desMaxLine } = this.props;
|
|
78
|
-
if (description) {
|
|
79
|
-
return (
|
|
80
|
-
<div className={`${prefixCls}-des`}>
|
|
81
|
-
<div
|
|
82
|
-
className={`${prefixCls}-des-inner`}
|
|
83
|
-
style={{
|
|
84
|
-
WebkitLineClamp: desMaxLine,
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
{description}
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
renderExtra() {
|
|
96
|
-
const { extra, prefixCls } = this.props;
|
|
97
|
-
if (extra) {
|
|
98
|
-
return (
|
|
99
|
-
<div className={`${prefixCls}-extra`}>
|
|
100
|
-
<div className={`${prefixCls}-extra-inner`}>{extra}</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
const {
|
|
108
|
-
prefixCls, className, borderType, badgePosition, onClick,
|
|
109
|
-
} = this.props;
|
|
110
|
-
return (
|
|
111
|
-
<div
|
|
112
|
-
className={classnames({
|
|
113
|
-
[prefixCls]: true,
|
|
114
|
-
[className]: !!className,
|
|
115
|
-
[borderType]: !!borderType,
|
|
116
|
-
})}
|
|
117
|
-
onClick={() => { onClick(this.props); }}
|
|
118
|
-
>
|
|
119
|
-
{this.renderImg()}
|
|
120
|
-
{this.renderAvatar()}
|
|
121
|
-
<div className={`${prefixCls}-content`}>
|
|
122
|
-
{this.renderTitle()}
|
|
123
|
-
{this.renderDes()}
|
|
124
|
-
</div>
|
|
125
|
-
{badgePosition === 'indicator' ? this.renderBadge() : null}
|
|
126
|
-
{this.renderExtra()}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export default Item;
|
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ScrollList Component for SaltUI
|
|
3
|
-
* @author xiaohe.wp
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2018-2019, SaltUI Team.
|
|
6
|
-
* All rights reserved.
|
|
7
|
-
*/
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { polyfill } from 'react-lifecycles-compat';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import ReactDOM from 'react-dom';
|
|
12
|
-
import NattyFetch from 'natty-fetch';
|
|
13
|
-
import isEmpty from 'lodash/isEmpty';
|
|
14
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
15
|
-
import assign from 'lodash/assign';
|
|
16
|
-
import classnames from 'classnames';
|
|
17
|
-
import Context from 'saltui/lib/Context';
|
|
18
|
-
import ScrollView from 'saltui/lib/ScrollView';
|
|
19
|
-
import BottomTip from './BottomTip';
|
|
20
|
-
import EmptyContent from './EmptyContent';
|
|
21
|
-
import Item from './Item';
|
|
22
|
-
import TagList from './TagList';
|
|
23
|
-
|
|
24
|
-
function odd(i) {
|
|
25
|
-
return !!((i + 1) % 2);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
class ScrollList extends React.Component {
|
|
29
|
-
static displayName = 'ScrollList';
|
|
30
|
-
|
|
31
|
-
static propTypes = {
|
|
32
|
-
prefixCls: PropTypes.string,
|
|
33
|
-
className: PropTypes.string,
|
|
34
|
-
listBorderType: PropTypes.string,
|
|
35
|
-
children: PropTypes.any,
|
|
36
|
-
scrollLoad: PropTypes.bool,
|
|
37
|
-
scrollRefresh: PropTypes.bool,
|
|
38
|
-
|
|
39
|
-
// 数据是否已就位标识符
|
|
40
|
-
dataGetted: PropTypes.bool,
|
|
41
|
-
data: PropTypes.array,
|
|
42
|
-
// 下拉配置
|
|
43
|
-
refreshing: PropTypes.bool,
|
|
44
|
-
pullLoadTip: PropTypes.string,
|
|
45
|
-
loadDataTip: PropTypes.string,
|
|
46
|
-
onRefresh: PropTypes.func,
|
|
47
|
-
// 触底加载配置
|
|
48
|
-
loading: PropTypes.bool,
|
|
49
|
-
loadingTip: PropTypes.string,
|
|
50
|
-
onLoad: PropTypes.func,
|
|
51
|
-
// 无更多数据提示文案
|
|
52
|
-
noMore: PropTypes.bool,
|
|
53
|
-
noMoreDataTip: PropTypes.string,
|
|
54
|
-
// 加载错误文案
|
|
55
|
-
hasError: PropTypes.bool,
|
|
56
|
-
errorTip: PropTypes.string,
|
|
57
|
-
// 无数据提示文案
|
|
58
|
-
noDataTip: PropTypes.string,
|
|
59
|
-
noDataImage: PropTypes.string,
|
|
60
|
-
//
|
|
61
|
-
url: PropTypes.string,
|
|
62
|
-
pageSize: PropTypes.number,
|
|
63
|
-
beforeFetch: PropTypes.func,
|
|
64
|
-
processData: PropTypes.func,
|
|
65
|
-
currentPageKey: PropTypes.string,
|
|
66
|
-
dataType: PropTypes.oneOf(['json', 'jsonp']),
|
|
67
|
-
fetchOption: PropTypes.object,
|
|
68
|
-
fetchDataOnOpen: PropTypes.bool,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
static defaultProps = {
|
|
72
|
-
scrollLoad: true, // 是否支持滚动,来自设计器配置
|
|
73
|
-
scrollRefresh: true,
|
|
74
|
-
dataGetted: false,
|
|
75
|
-
data: [],
|
|
76
|
-
refreshing: false,
|
|
77
|
-
prefixCls: 't-scroll-list',
|
|
78
|
-
pullLoadTip: '下拉显示更多',
|
|
79
|
-
loadDataTip: '释放加载数据',
|
|
80
|
-
onRefresh: null,
|
|
81
|
-
loading: false, // 触底加载
|
|
82
|
-
loadingTip: '加载中...',
|
|
83
|
-
onLoad: null,
|
|
84
|
-
beforeFetch: data => data,
|
|
85
|
-
processData: data => data,
|
|
86
|
-
currentPageKey: 'currentPage',
|
|
87
|
-
noMore: false, // 没有更多内容提示
|
|
88
|
-
noMoreDataTip: '没有更多了',
|
|
89
|
-
hasError: false,
|
|
90
|
-
errorTip: '获取数据失败',
|
|
91
|
-
noDataTip: '暂无数据',
|
|
92
|
-
noDataImage: 'https://img.alicdn.com/tps/TB1K6mHNpXXXXXiXpXXXXXXXXXX-1000-1000.svg',
|
|
93
|
-
fetchDataOnOpen: true,
|
|
94
|
-
className: undefined,
|
|
95
|
-
listBorderType: 'scroll-list-no-border', // scroll-list-no-border, scroll-list-cut-border, scroll-list-full-border
|
|
96
|
-
children: undefined,
|
|
97
|
-
url: undefined,
|
|
98
|
-
pageSize: undefined,
|
|
99
|
-
dataType: undefined,
|
|
100
|
-
fetchOption: undefined,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
constructor(props) {
|
|
104
|
-
super(props);
|
|
105
|
-
|
|
106
|
-
this.state = {
|
|
107
|
-
dataGetted: props.dataGetted,
|
|
108
|
-
data: props.data,
|
|
109
|
-
hasError: props.hasError,
|
|
110
|
-
refreshing: props.refreshing,
|
|
111
|
-
loading: props.loading,
|
|
112
|
-
noMore: props.noMore,
|
|
113
|
-
currentPage: 1,
|
|
114
|
-
fetchData: props.fetchDataOnOpen,
|
|
115
|
-
prevProps: {
|
|
116
|
-
dataGetted: props.dataGetted,
|
|
117
|
-
hasError: props.hasError,
|
|
118
|
-
refreshing: props.refreshing,
|
|
119
|
-
loading: props.loading,
|
|
120
|
-
noMore: props.noMore,
|
|
121
|
-
data: props.data,
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
static getDerivedStateFromProps(props, { prevProps }) {
|
|
127
|
-
if (!props.url) {
|
|
128
|
-
const {
|
|
129
|
-
dataGetted, hasError, refreshing, loading, noMore, data,
|
|
130
|
-
} = props;
|
|
131
|
-
const {
|
|
132
|
-
dataGetted: prevDataGetted,
|
|
133
|
-
hasError: prevHasError,
|
|
134
|
-
refreshing: prevRefreshing,
|
|
135
|
-
loading: prevLoading,
|
|
136
|
-
noMore: prevNoMore,
|
|
137
|
-
data: prevData,
|
|
138
|
-
} = prevProps;
|
|
139
|
-
const changes = {};
|
|
140
|
-
if (dataGetted !== prevDataGetted) {
|
|
141
|
-
changes.dataGetted = dataGetted;
|
|
142
|
-
}
|
|
143
|
-
if (hasError !== prevHasError) {
|
|
144
|
-
changes.hasError = hasError;
|
|
145
|
-
}
|
|
146
|
-
if (refreshing !== prevRefreshing) {
|
|
147
|
-
changes.refreshing = refreshing;
|
|
148
|
-
}
|
|
149
|
-
if (loading !== prevLoading) {
|
|
150
|
-
changes.loading = loading;
|
|
151
|
-
}
|
|
152
|
-
if (noMore !== prevNoMore) {
|
|
153
|
-
changes.noMore = noMore;
|
|
154
|
-
}
|
|
155
|
-
if (data !== prevData) {
|
|
156
|
-
changes.data = data;
|
|
157
|
-
}
|
|
158
|
-
changes.prevProps = { ...changes };
|
|
159
|
-
return changes;
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
onFetch(refresh, from) {
|
|
165
|
-
if (this.state.loading) return;
|
|
166
|
-
this.setState(refresh ? { refreshing: true } : { loading: true });
|
|
167
|
-
|
|
168
|
-
this.fetchFrom = this.fetchFrom || from;
|
|
169
|
-
const pageOption = {
|
|
170
|
-
pageSize: this.props.pageSize,
|
|
171
|
-
[this.props.currentPageKey]: refresh ? 1 : this.state.currentPage,
|
|
172
|
-
};
|
|
173
|
-
const data = this.props.beforeFetch(cloneDeep(pageOption), this.fetchFrom) || pageOption;
|
|
174
|
-
this.fetchFrom = '';
|
|
175
|
-
|
|
176
|
-
const numKey = data[this.props.currentPageKey];
|
|
177
|
-
delete data[this.props.currentPageKey];
|
|
178
|
-
const queryData = JSON.stringify(data);
|
|
179
|
-
data[this.props.currentPageKey] = numKey;
|
|
180
|
-
const fetchOption = assign(
|
|
181
|
-
{
|
|
182
|
-
url: this.props.url,
|
|
183
|
-
data,
|
|
184
|
-
withCredentials: false,
|
|
185
|
-
header: {
|
|
186
|
-
'Authorization': 'Bearer '+getLoginUserInfo().token,
|
|
187
|
-
// 其他自定义请求头
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
this.props.fetchOption,
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
if (this.props.dataType) {
|
|
194
|
-
fetchOption.jsonp = this.props.dataType === 'jsonp';
|
|
195
|
-
} else {
|
|
196
|
-
fetchOption.jsonp = /\.jsonp/.test(this.props.url);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
NattyFetch.create(fetchOption)()
|
|
200
|
-
.then((con) => {
|
|
201
|
-
const content = cloneDeep(this.props.processData(con));
|
|
202
|
-
const { state } = this;
|
|
203
|
-
const nextState = {
|
|
204
|
-
refreshing: false,
|
|
205
|
-
loading: false,
|
|
206
|
-
dataGetted: true,
|
|
207
|
-
hasError: false,
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
nextState.noMore = content.data.length < this.props.pageSize;
|
|
211
|
-
|
|
212
|
-
if (refresh) {
|
|
213
|
-
nextState.data = content.data;
|
|
214
|
-
nextState.currentPage = 2;
|
|
215
|
-
this.scrollTop();
|
|
216
|
-
} else {
|
|
217
|
-
if (
|
|
218
|
-
(state.lastQueryData && queryData !== state.lastQueryData) ||
|
|
219
|
-
content.currentPage !== state.currentPage
|
|
220
|
-
) {
|
|
221
|
-
nextState.currentPage = 1;
|
|
222
|
-
nextState.data = [];
|
|
223
|
-
this.scrollTop();
|
|
224
|
-
} else {
|
|
225
|
-
nextState.data = state.data;
|
|
226
|
-
nextState.currentPage = state.currentPage + 1;
|
|
227
|
-
}
|
|
228
|
-
nextState.data = nextState.data.concat(content.data);
|
|
229
|
-
}
|
|
230
|
-
nextState.lastQueryData = queryData;
|
|
231
|
-
nextState.showRefreshing = true;
|
|
232
|
-
this.setState(nextState, () => {
|
|
233
|
-
if (refresh) {
|
|
234
|
-
if (this.scrollViewRef) {
|
|
235
|
-
this.scrollViewRef.tryEmitScrollEvent();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
})
|
|
240
|
-
.catch((error) => {
|
|
241
|
-
this.setState({
|
|
242
|
-
refreshing: false,
|
|
243
|
-
loading: false,
|
|
244
|
-
dataGetted: true,
|
|
245
|
-
noMore: false,
|
|
246
|
-
hasError: true,
|
|
247
|
-
});
|
|
248
|
-
console.error(error);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
fetchData(from) {
|
|
253
|
-
this.fetchFrom = from;
|
|
254
|
-
|
|
255
|
-
if (this.state.fetchData) {
|
|
256
|
-
this.scrollTop();
|
|
257
|
-
if (this.props.url) {
|
|
258
|
-
this.setState({
|
|
259
|
-
showRefreshing: false,
|
|
260
|
-
});
|
|
261
|
-
this.onFetch(true, from);
|
|
262
|
-
} else if (this.props.onRefresh) {
|
|
263
|
-
this.props.onRefresh();
|
|
264
|
-
}
|
|
265
|
-
} else {
|
|
266
|
-
this.setState({
|
|
267
|
-
fetchData: true,
|
|
268
|
-
showRefreshing: !this.props.url,
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
scrollTop() {
|
|
274
|
-
/* eslint-disable react/no-find-dom-node */
|
|
275
|
-
/* TODO: need scrollView support getDomNode method */
|
|
276
|
-
this.scrollView = this.scrollView || ReactDOM.findDOMNode(this.scrollViewRef);
|
|
277
|
-
/* eslint-enable react/no-find-dom-node */
|
|
278
|
-
if (this.scrollView) {
|
|
279
|
-
this.scrollView.scrollTop = 0;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
refreshOptions() {
|
|
284
|
-
const onRefresh = this.props.url ? this.onFetch.bind(this, true, 'top') : this.props.onRefresh;
|
|
285
|
-
return {
|
|
286
|
-
refreshControl: this.props.scrollRefresh,
|
|
287
|
-
refreshControlOptions: {
|
|
288
|
-
showRefreshing: this.state.showRefreshing,
|
|
289
|
-
refreshing: this.state.refreshing,
|
|
290
|
-
beforePullLoadText: this.props.pullLoadTip,
|
|
291
|
-
afterPullLoadText: this.props.loadDataTip,
|
|
292
|
-
refreshingText: this.props.loadingTip,
|
|
293
|
-
onRefresh,
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
infiniteScrollOptions() {
|
|
299
|
-
const onLoad = this.props.url ? this.onFetch.bind(this, false, 'bottom') : this.props.onLoad;
|
|
300
|
-
const {
|
|
301
|
-
fetchData, noMore, hasError, refreshing,
|
|
302
|
-
} = this.state;
|
|
303
|
-
return {
|
|
304
|
-
infiniteScroll: !refreshing && fetchData && !noMore && !hasError && this.props.scrollLoad,
|
|
305
|
-
infiniteScrollOptions: {
|
|
306
|
-
loading: this.state.loading,
|
|
307
|
-
loadingText: this.props.loadingTip,
|
|
308
|
-
onLoad,
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
isEmpty() {
|
|
314
|
-
return this.state.dataGetted && isEmpty(this.state.data);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
renderPrevSiblings() {
|
|
318
|
-
const { children } = this.props;
|
|
319
|
-
if (!Array.isArray(children)) {
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
const prevs = children.slice(0, children.length - 1);
|
|
323
|
-
const prevSiblings = [];
|
|
324
|
-
prevs.forEach((element, i) => {
|
|
325
|
-
if (React.isValidElement(element)) {
|
|
326
|
-
prevSiblings.push(React.cloneElement(element, {
|
|
327
|
-
/* eslint-disable react/no-array-index-key */
|
|
328
|
-
key: `prev-sibling-${i}`,
|
|
329
|
-
/* eslint-enable react/no-array-index-key */
|
|
330
|
-
index: i,
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
return prevSiblings;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
renderList() {
|
|
338
|
-
const { data } = this.state;
|
|
339
|
-
const { children } = this.props;
|
|
340
|
-
const len = data.length;
|
|
341
|
-
if (!children) {
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
const lastChild = !Array.isArray(children) ? children : children[children.length - 1];
|
|
345
|
-
const isLastChildFunc = typeof lastChild === 'function';
|
|
346
|
-
if (!isLastChildFunc) {
|
|
347
|
-
return data.map((item, i) =>
|
|
348
|
-
React.cloneElement(lastChild, {
|
|
349
|
-
/* eslint-disable react/no-array-index-key */
|
|
350
|
-
key: `child-${i}`,
|
|
351
|
-
/* selint-enable react/no-array-index-key */
|
|
352
|
-
index: i,
|
|
353
|
-
first: i === 0,
|
|
354
|
-
last: i === len,
|
|
355
|
-
odd: odd(i),
|
|
356
|
-
data: item,
|
|
357
|
-
...item,
|
|
358
|
-
}));
|
|
359
|
-
}
|
|
360
|
-
return data.map((item, i) => lastChild(item, i));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
renderBottomTip() {
|
|
364
|
-
const noMore = this.state.dataGetted && this.state.noMore;
|
|
365
|
-
const hasError = this.state.dataGetted && this.state.hasError;
|
|
366
|
-
|
|
367
|
-
if (hasError) {
|
|
368
|
-
return <BottomTip key="bottom-tip" text={this.props.errorTip} />;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (noMore) {
|
|
372
|
-
return <BottomTip key="bottom-tip" text={this.props.noMoreDataTip} />;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
render() {
|
|
379
|
-
if (this.isEmpty()) {
|
|
380
|
-
return (
|
|
381
|
-
<div className={classnames(Context.prefixClass('scroll-list'), this.props.className)}>
|
|
382
|
-
<EmptyContent text={this.props.noDataTip} image={this.props.noDataImage} />
|
|
383
|
-
</div>
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return (
|
|
388
|
-
<ScrollView
|
|
389
|
-
ref={(ref) => {
|
|
390
|
-
this.scrollViewRef = ref;
|
|
391
|
-
}}
|
|
392
|
-
className={classnames(this.props.prefixCls, {
|
|
393
|
-
[this.props.className]: !!this.props.className,
|
|
394
|
-
[this.props.listBorderType]: !!this.props.listBorderType,
|
|
395
|
-
})}
|
|
396
|
-
{...this.refreshOptions()}
|
|
397
|
-
{...this.infiniteScrollOptions()}
|
|
398
|
-
>
|
|
399
|
-
{this.renderPrevSiblings()}
|
|
400
|
-
{this.renderList()}
|
|
401
|
-
{this.renderBottomTip()}
|
|
402
|
-
</ScrollView>
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
ScrollList.Item = Item;
|
|
408
|
-
ScrollList.TagList = TagList;
|
|
409
|
-
|
|
410
|
-
polyfill(ScrollList);
|
|
411
|
-
|
|
412
|
-
export default ScrollList;
|