MessageMobile.js
8.07 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import React from 'react';
// eslint-disable-next-line no-unused-vars
import { Tabs, Badge, ListView, SearchBar } from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';
// import ExamineMobile from './ExamineMobile';
import * as commonConfig from '../../utils/config';
import * as commonUtils from '../../utils/utils';
import CommobileBase from '../../mobile/common/CommobileBase';
import CommobileListEvent from './CommobileListEvent';
import styles from '../../routes/mobile/IndexMobile.less';
import NewsMobile from './NewsMobile';
// eslint-disable-next-line no-unused-vars
import ExamineMobile from './ExamineMobile';
// import CommobileBill from './CommobileBill';
const dataSource = new ListView.DataSource({
rowHasChanged: (row1, row2) => row2,
});
// eslint-disable-next-line no-unused-vars
const tabs = [
{ title: <Badge text="">消息</Badge> },
{ title: <Badge text="">待处理</Badge> },
{ title: <Badge text="">已处理</Badge> },
{ title: <Badge text="">我的申请</Badge> },
];
class MessageMobile extends React.Component {
constructor(props) {
super(props);
this.state = {
height: (document.documentElement.clientHeight * 3) / 4,
tabPage: 0,
};
}
componentWillMount() {
/* 获取配置 */
this.props.onSaveState({ searchSolution: [] });
}
onEndReached = async () => {
if ((this.props.slavePagination.current + 1) <= Math.ceil(this.props.slavePagination.total / commonConfig.pageSize)) {
const addState = await this.props.onGetData(this.props.slaveConfig, [], this.props.slavePagination.current + 1, true);
addState.slaveData = this.props.slaveData.concat(addState.slaveData);
this.props.onSaveState({ ...addState });
}
}
onClose = key => () => {
this.setState({
[key]: false,
});
}
/* 页签切换 */
// eslint-disable-next-line no-unused-vars
handleTabClick =(index, tab) => {
this.setState({ tabPage: index });
}
render() {
const { slaveConfig, slaveData: slaveDataOld } = this.props;
const { tabPage } = this.state;
const slaveDataOld2 = slaveDataOld === undefined ? [] : slaveDataOld;
const slaveData = dataSource.cloneWithRows(slaveDataOld2);
const f1 = commonUtils.isEmptyObject(slaveConfig) ? {} : slaveConfig.gdsconfigformslave.filter(item => item.bVisible)[0];
const f2 = commonUtils.isEmptyObject(slaveConfig) ? {} : slaveConfig.gdsconfigformslave.filter(item => item.bVisible)[1];
const f3 = commonUtils.isEmptyObject(slaveConfig) ? {} : slaveConfig.gdsconfigformslave.filter(item => item.bVisible)[2];
const f4 = commonUtils.isEmptyObject(slaveConfig) ? {} : slaveConfig.gdsconfigformslave.filter(item => item.bVisible)[3];
const separator = (sectionID, rowID) => (
<div
key={`${sectionID}-${rowID}`}
style={{
backgroundColor: '#F5F5F9',
height: 6,
borderTop: '1px solid #ECECED',
borderBottom: '1px solid #ECECED',
}}
/>
);
const row = (rowData, sectionID, rowID) => {
const obj = rowData;
return (
<div key={rowID} style={{ padding: '0 15px' }}>
<div
style={{
lineHeight: '40px',
borderBottom: '1px solid #F6F6F6',
}}
>
<span style={{
fontSize: 18, color: '#000', fontWeight: 'bold', paddingLeft: '10px', paddingRight: '10px',
}}
>{obj[f1.sName]}
</span>
<span style={{ fontSize: 14, color: '#888' }}>{obj[f2.sName]}</span>
</div>
<div style={{ display: 'flex', padding: '10px 0' }}>
{/* <img style={{ height: '50px', marginRight: '15px', borderRadius: '50%' }} src="https://zos.alipayobjects.com/rmsportal/dKbkpPXKfvZzWCM.png" alt="" /> */}
<div style={{ lineHeight: 1, width: '100%' }}>
<div style={{ color: '#000', paddingLeft: '6px', marginBottom: '8px' }}>{obj[f3.sName]}</div>
<div style={{ color: '#000', paddingLeft: '6px', marginBottom: '8px' }}>{obj[f4.sName]}</div>
</div>
</div>
</div>
);
};
/* 待处理 */
const unNewsProps = {
app: {
...this.props.app,
},
sModelsId: '192116812112116672655865440',
dispatch: this.props.dispatch,
};
/* 已通过 */
const doneNewsProps = {
app: {
...this.props.app,
},
sModelsId: '192116812112116672668106810',
dispatch: this.props.dispatch,
};
/* 我的申请 */
const sendNewsProps = {
app: {
...this.props.app,
},
sModelsId: '192116812112116672733801250',
dispatch: this.props.dispatch,
};
// eslint-disable-next-line no-unused-vars
const examineProps = {
app: {
...this.props.app,
},
sModelsId: '192116812112116672690047620',
sModelType: 'examine',
dispatch: this.props.dispatch,
};
return (
<div>
<Tabs
tabs={tabs}
initialPage={0}
onChange={(tab, index) => this.handleTabClick(index, tab)}
onTabClick={(tab, index) => { console.log('onTabClick', index, tab); }}
>
{
tabPage === 0 ?
<div>
<SearchBar placeholder="关键词" />
<ListView
dataSource={slaveData}
renderFooter={() => (
<div style={{ padding: 30, textAlign: 'center' }}>
{this.props.isLoading ? 'Loading...' : 'Loaded'}
</div>)}
renderRow={row}
renderSeparator={separator}
style={{
height: this.state.height,
overflow: 'auto',
}}
pageSize={commonConfig.pageSize}
onScroll={() => {}}
scrollRenderAheadDistance={500}
onEndReached={this.onEndReached}
onEndReachedThreshold={10}
/>
</div> : '' }
{tabPage === 1 ? <div className={styles.demoContainer}> <NewsMobile {...unNewsProps} /></div> : ''}
{tabPage === 2 ? <div className={styles.demoContainer}> <NewsMobile {...doneNewsProps} /> </div> : ''}
{tabPage === 3 ? <div className={styles.demoContainer}> <NewsMobile {...sendNewsProps} /></div> : ''}
{/* <div> */}
{/* <SearchBar placeholder="单据号" /> */}
{/* <ListView */}
{/* dataSource={slaveData} */}
{/* renderFooter={() => ( */}
{/* <div style={{ padding: 30, textAlign: 'center' }}> */}
{/* {this.props.isLoading ? 'Loading...' : 'Loaded'} */}
{/* </div>)} */}
{/* renderRow={row} */}
{/* renderSeparator={separator} */}
{/* style={{ */}
{/* height: this.state.height, */}
{/* overflow: 'auto', */}
{/* }} */}
{/* pageSize={commonConfig.pageSize} */}
{/* onScroll={() => {}} */}
{/* scrollRenderAheadDistance={500} */}
{/* onEndReached={this.onEndReached} */}
{/* onEndReachedThreshold={10} */}
{/* /> */}
{/* </div> */}
</Tabs>
{/* <div> */}
{/* <ListView */}
{/* dataSource={slaveData} */}
{/* renderFooter={() => ( */}
{/* <div style={{ padding: 30, textAlign: 'center' }}> */}
{/* {this.props.isLoading ? 'Loading...' : 'Loaded'} */}
{/* </div>)} */}
{/* renderRow={row} */}
{/* renderSeparator={separator} */}
{/* style={{ */}
{/* height: this.state.height, */}
{/* overflow: 'auto', */}
{/* }} */}
{/* pageSize={commonConfig.pageSize} */}
{/* onScroll={() => {}} */}
{/* scrollRenderAheadDistance={500} */}
{/* onEndReached={this.onEndReached} */}
{/* onEndReachedThreshold={10} */}
{/* /> */}
{/* </div> */}
</div>
);
}
}
export default CommobileBase(CommobileListEvent(MessageMobile));