schoollist.js
6.47 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
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { Link } from 'dva/router';
import { Row, Col, Card, Form, Input, Select, Icon, Button, Dropdown, Menu, InputNumber, DatePicker, Modal, message } from 'antd';
import { Table, Alert, Badge, Divider } from 'antd';
import StandardTable from '../../components/StandardTableM';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from './schoollist.less';
import moment from 'moment';
const FormItem = Form.Item;
const { Option } = Select;
const getValue = obj => Object.keys(obj).map(key => obj[key]).join(',');
@connect(({ schools,areas, loading }) => ({
schools,
areas,
loading: loading.models.schools,
}))
@Form.create()
export default class schoollist extends PureComponent {
state = {
addInputValue: '',
selectedRows: [],
formValues: {},
};
componentDidMount() {
const { dispatch } = this.props;
dispatch({
type: 'areas/fetch',
});
}
handleStandardTableChange = (pagination, filtersArg, sorter) => {
const { dispatch } = this.props;
const { formValues } = this.state;
const filters = Object.keys(filtersArg).reduce((obj, key) => {
const newObj = { ...obj };
newObj[key] = getValue(filtersArg[key]);
return newObj;
}, {});
const params = {
currentPage: pagination.current,
pageSize: pagination.pageSize,
...formValues,
...filters,
};
if (sorter.field) {
params.sorter = `${sorter.field}_${sorter.order}`;
}
dispatch({
type: 'schools/fetch',
payload: params,
});
}
handleFormReset = () => {
const { form, dispatch } = this.props;
form.resetFields();
this.setState({
formValues: {},
});
dispatch({
type: 'schools/fetch',
payload: {},
});
}
toggleForm = () => {
this.setState({
expandForm: !this.state.expandForm,
});
}
handleMenuClick = (e) => {
}
handleSelectRows = (rows) => {
}
handleSearch = (e) => {
e.preventDefault();
const { dispatch, form } = this.props;
form.validateFields((err, fieldsValue) => {
if (err) return;
const values = {
...fieldsValue,
updatedAt: fieldsValue.updatedAt && fieldsValue.updatedAt.valueOf(),
};
this.setState({
formValues: values,
});
dispatch({
type: 'schools/fetch',
payload: values,
});
});
}
//加载地区属性的下来选择项目
renderSellectOption=(datas)=>{
return datas.map((item)=>{
return <Option key={`option_${item.code}`} value={item.code}>{item.name}</Option>
});
}
renderSimpleForm() {
const { getFieldDecorator } = this.props.form;
return (
<Form onSubmit={this.handleSearch} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}>
<FormItem label="地区">
{getFieldDecorator('areaCode')(
<Select placeholder="请选择" style={{ width: '100%' }}>
{this.renderSellectOption(this.props.areas.list)}
</Select>
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="学校名称">
{getFieldDecorator('name')(
<Input placeholder="请输入" />
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="学校代码">
{getFieldDecorator('schoolCode')(
<Input placeholder="请输入" />
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="企业号代码">
{getFieldDecorator('corpid')(
<Input placeholder="请输入" />
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<span className={styles.submitButtons}>
<Button type="primary" htmlType="submit">查询</Button>
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>重置</Button>
</span>
</Col>
</Row>
</Form>
);
}
renderForm() {
return this.renderSimpleForm();
}
render() {
const { schools: {data}, loading } = this.props;
const { selectedRows, modalVisible, addInputValue } = this.state;
const columns = [
{
title: '学校',
dataIndex: 'name',
},
{
title:'企业号信息',
dataIndex : 'corpid',
render:val => <span> {val} </span>,
},
{
title: '所属地区',
dataIndex: 'showArea',
},
{
title: '更新时间',
dataIndex: 'updatedAt',
sorter: true,
render: val => <span>{moment(val).format('YYYY-MM-DD HH:mm:ss')}</span>,
},
{
title: '操作',
dataIndex: 'code',
render: (val) => (
<Fragment>
<a href="">配置</a>
<Divider type="vertical" />
<Link to={`/devutil/schoolmgr/${val}`} className={styles.logo} key="logo">
<span>查看</span>
</Link>
</Fragment>
),
},
];
const menu = (
<Menu onClick={this.handleMenuClick} selectedKeys={[]}>
<Menu.Item key="remove">删除</Menu.Item>
<Menu.Item key="approval">批量审批</Menu.Item>
</Menu>
);
return (
<PageHeaderLayout title="查询表格">
<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListForm}>
{this.renderForm()}
</div>
<div className={styles.tableListOperator}>
{
selectedRows.length > 0 && (
<span>
<Button>批量操作</Button>
<Dropdown overlay={menu}>
<Button>
更多操作 <Icon type="down" />
</Button>
</Dropdown>
</span>
)
}
</div>
<StandardTable
selectedRows={selectedRows}
loading={loading}
data={data}
columns={columns}
onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange}
/>
</div>
</Card>
</PageHeaderLayout>
);
}
}