schoolmgr.js
7.55 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import styles from './schoolmgr.less'
import React, { Component } from 'react';
import { connect } from 'dva';
import {
Row,
Col,
Icon,
Card,
Tabs,
Table,
Radio,
DatePicker,
Tooltip,
Menu,
Dropdown,
Tree,
Button,
Input
} from 'antd';
import {
ChartCard,
yuan,
MiniArea,
MiniBar,
MiniProgress,
Field,
Bar,
Pie,
TimelineChart,
} from '../../components/Charts';
import Trend from '../../components/Trend';
import { R_OK } from 'constants';
import numeral from 'numeral';
import linkman from '../../../mock/linkman';
const { Search } = Input;
const TreeNode = Tree.TreeNode;
@connect(({ linkman, loading }) => ({
linkman,
loading: loading.models.linkman,
}))
export default class schoolmgr extends Component{
state = {
checkedKeys:[],
};
componentDidMount() {
const { dispatch } = this.props;
let schoolCode = this.props.match.params.schcode;
this.setState({
schoolCode:schoolCode
});
dispatch({
type: 'linkman/groups',
payload:{schoolCode:schoolCode},
});
}
//初始化对应的树节点数据
onLoadData = (treeNode) => {
let schoolCode = this.props.match.params.schcode;
return new Promise((resolve) => {
if (treeNode.props.children) {
resolve();
return;
}
const { dispatch } = this.props;
let groupid = treeNode.props.eventKey;
dispatch({
type: 'linkman/lklist',
payload:{
groupid:groupid,
schoolCode:schoolCode
},
});
resolve();
return;
});
}
//加载所有数节点
renderTreeNodes = (data) => {
return data.map((item) => {
if (item.children) {
return (
<TreeNode title={item.name} key={item.id} dataRef={item}>
{this.renderTreeNodes(item.children)}
</TreeNode>
);
}
return (<TreeNode title={item.name} key={item.id} dataRef={item}>
{this.renderTreeLefs(item.id)}
</TreeNode>);
});
}
//加载对应的联系人节点
renderTreeLefs = (groupid)=>{
const {linkman:{linkmanMap}} = this.props;
if(linkmanMap['g_'+groupid]){
return linkmanMap['g_'+groupid].map((item)=>{
let showninfo = item.name+" # "+item.userid;
return (<TreeNode isLeaf title={showninfo} key={item.userid} dataRef={item}/>);
});
}
else
return "";
}
onCheck = (checkedKeys) => {
console.log('onCheck', checkedKeys);
this.setState({ checkedKeys });
}
//根据当前选择的对象,删除指定的联系人
removelkman = () => {
console.log('removelkman');
}
//定义特殊操作的按钮流程
specopation = (action) => {
console.log('specatcion'+action);
}
//查找目标的用户
findUser = (content)=>{
if(content && content.length>0){
const {dispatch } = this.props;
const {schoolCode} = this.state;
dispatch({
type: 'linkman/findUser',
payload:{
phone:content,
schoolCode:schoolCode
},
});
}
}
//显示对应查询用户的结果信息
renderFoundUserResult(){
const {linkman:{userFoundResult}} = this.props;
if(userFoundResult){
return (<div>
<span><strong>检索结果:</strong></span>
<div>
<span>uid: {userFoundResult.userid}</span><br/>
<span>姓名: {userFoundResult.name}</span><br/>
<span>角色: {userFoundResult.position}</span><br/>
<span>部门: {userFoundResult.department}</span><br/>
</div>
</div>);
}else{
return (<div>
</div>);
}
}
render(){
const topColResponsiveProps = {
xs: 24,
sm: 12,
md: 12,
lg: 12,
xl: 6,
style: { marginBottom: 24 },
};
const {linkman:{groups}} = this.props;
return <div>
<Row gutter={24}>
<Col {...topColResponsiveProps}>
<ChartCard
bordered={false}
title={`学校名称-(${this.state.schoolCode})`}
action={
<Tooltip title="指标说明">
<Icon type="info-circle-o" />
</Tooltip>
}
total={`${numeral(12423).format('0,0')}`}
footer={<Field label="关注人员" value={`${numeral(12423).format('0,0')}`} />}
contentHeight={46}
>
<Trend flag="up" style={{ marginRight: 16 }}>
关注数<span className={styles.trendText}>--%</span>
</Trend>
<Trend flag="down">
取关数<span className={styles.trendText}>--%</span>
</Trend>
</ChartCard>
</Col>
</Row>
<Row gutter={24}>
<Col xl={14} lg={24} md={24} sm={24} xs={24}>
<ChartCard title='企业号通讯录结构'>
<div >
<div><span>可以展开</span></div>
<Tree
checkable
loadData={this.onLoadData}
onCheck={this.onCheck}
checkedKeys={this.state.checkedKeys}
>
{this.renderTreeNodes(groups)}
</Tree>
</div>
</ChartCard>
</Col>
<Col xl={10} lg={24} md={24} sm={24} xs={24}>
<ChartCard
bordered={true}
title='信息检索'
>
<Search
className={styles.extraContentSearch}
placeholder="请输入收集号码"
onSearch={this.findUser}
/>
{this.renderFoundUserResult()}
</ChartCard>
<br/>
<ChartCard
bordered={false}
title='操作/功能区'
contentHeight={46} >
<div>
<Button style={{ marginLeft: 8 }} onClick={this.removelkman}>删除联系人</Button>
<Button style={{ marginLeft: 8 }} onClick={() =>this.specopation(1)}>头像强刷</Button>
<Button style={{ marginLeft: 8 }} onClick={() =>this.specopation(2)}>通讯录强刷</Button>
</div>
</ChartCard>
</Col>
</Row>
</div>;
}
}