fmui-base 2.1.84 → 2.1.86
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 +2 -0
- package/lib/ScrollList/BottomTip.jsx +25 -0
- package/lib/ScrollList/EmptyContent.jsx +19 -0
- package/lib/ScrollList/Item.jsx +132 -0
- package/lib/ScrollList/ScrollList.jsx +412 -0
- package/lib/ScrollList/TagList.jsx +54 -0
- package/lib/button/button.jsx +46 -0
- package/lib/care/care.jsx +26 -0
- package/lib/chart/chart.jsx +344 -0
- package/lib/comment_list/List.jsx +285 -0
- package/lib/form/form.jsx +3434 -0
- package/lib/form/subForm.jsx +793 -0
- package/lib/form/table.jsx +1804 -0
- package/lib/form_info/formInfo.jsx +5158 -0
- package/lib/loading/loading.jsx +23 -0
- package/lib/no_data/no_data.jsx +34 -0
- package/lib/poppage/check.jsx +500 -0
- package/lib/poppage/table/table.jsx +641 -0
- package/lib/poppage/tree/tree.jsx +548 -0
- package/lib/poppage/treetable/treetable.jsx +340 -0
- package/lib/positioning/positioning.jsx +92 -0
- package/lib/process_batch/processBatch.jsx +1629 -0
- package/lib/process_info/processInfo.js +2 -1
- package/lib/process_info/processInfo.jsx +7752 -0
- package/lib/process_list/processList.jsx +1299 -0
- package/lib/react_grid/react_grid.jsx +1166 -0
- package/lib/select-fileno/pageHome.jsx +569 -0
- package/lib/select-serialnumber/pageHome.jsx +503 -0
- package/lib/select-serialnumber/pageHome1.jsx +503 -0
- package/lib/selectMember/select.jsx +9568 -0
- package/lib/signature/sign.jsx +274 -0
- package/lib/upload/upload.js +2 -2
- package/lib/upload/upload.jsx +647 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,132 @@
|
|
|
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;
|
|
@@ -0,0 +1,412 @@
|
|
|
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;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
class Item extends React.Component {
|
|
6
|
+
static propTypes = {
|
|
7
|
+
prefixCls: PropTypes.string,
|
|
8
|
+
className: PropTypes.string,
|
|
9
|
+
data: PropTypes.array,
|
|
10
|
+
onClick: PropTypes.func,
|
|
11
|
+
};
|
|
12
|
+
static defaultProps = {
|
|
13
|
+
prefixCls: 't-scroll-list-taglist',
|
|
14
|
+
className: undefined,
|
|
15
|
+
data: [],
|
|
16
|
+
onClick: () => {}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
renderTagItem(item, index, className) {
|
|
20
|
+
const { onClick, prefixCls } = this.props;
|
|
21
|
+
return <span
|
|
22
|
+
key={`${prefixCls}-item-${index}`}
|
|
23
|
+
onClick={() => onClick(item, index)}
|
|
24
|
+
className={classnames(`${prefixCls}-item`,{
|
|
25
|
+
[`${className}-item`]: !!className,
|
|
26
|
+
})}>
|
|
27
|
+
{item.value || item || ''}
|
|
28
|
+
</span>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
const {
|
|
33
|
+
prefixCls,
|
|
34
|
+
className,
|
|
35
|
+
data = [],
|
|
36
|
+
} = this.props;
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classnames({
|
|
40
|
+
[prefixCls]: true,
|
|
41
|
+
[className]: !!className,
|
|
42
|
+
})}
|
|
43
|
+
>
|
|
44
|
+
{
|
|
45
|
+
data.map((item, index) => {
|
|
46
|
+
return this.renderTagItem(item, index, className);
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default Item;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, {PropTypes} from 'react';
|
|
2
|
+
import Button from 'saltui/lib/Button';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ButtonSelf extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props)
|
|
8
|
+
let text=props.text
|
|
9
|
+
this.state = {
|
|
10
|
+
text: text,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
handleClick(){
|
|
15
|
+
console.log('button click')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
render () {
|
|
19
|
+
return (
|
|
20
|
+
<div>
|
|
21
|
+
<div className="demo-section">
|
|
22
|
+
<div className="section-content">
|
|
23
|
+
<Button type="primary" onClick={this.handleClick}>一级按钮</Button>
|
|
24
|
+
<br />
|
|
25
|
+
<Button type="secondary" onClick={this.handleClick}>二级按钮</Button>
|
|
26
|
+
<br />
|
|
27
|
+
<Button type="minor" onClick={this.handleClick}>次要按钮</Button>
|
|
28
|
+
<br />
|
|
29
|
+
<Button type="danger">警示按钮1</Button>
|
|
30
|
+
<br />
|
|
31
|
+
<Button loading>加载中</Button>
|
|
32
|
+
<br />
|
|
33
|
+
<Button disabled>失效按钮</Button>
|
|
34
|
+
<br />
|
|
35
|
+
<Button disabled>失效按钮1</Button>
|
|
36
|
+
<br />
|
|
37
|
+
<br />
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export default ButtonSelf
|