|
@@ -1,108 +1,73 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
2
|
import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
3
|
|
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, Breadcrumb } from 'antd';
|
|
3
|
+import { Form, Pagination, Button, Icon, message, Modal, Table, Input } from 'antd';
|
4
|
4
|
import router from 'umi/router';
|
5
|
5
|
import moment from 'moment';
|
|
6
|
+import className from 'classnames';
|
|
7
|
+import Cell from '../../components/Cell';
|
6
|
8
|
import styles from './style.less';
|
7
|
9
|
import { fetch, apis } from '../../utils/request';
|
8
|
10
|
import request from '../../utils/request';
|
9
|
11
|
import AuthButton from '@/components/AuthButton';
|
|
12
|
+import SelectContact from './components/SelectContact';
|
10
|
13
|
|
11
|
|
-function header(props) {
|
12
|
14
|
|
13
|
|
- const [data, setData] = useState([])
|
|
15
|
+function header(props) {
|
|
16
|
+ // 获取初始化数据
|
|
17
|
+ const [data, setData] = useState({})
|
14
|
18
|
const [contactList, setContactList] = useState([])
|
|
19
|
+
|
15
|
20
|
useEffect(() => {
|
16
|
21
|
getList({ pageNum: 1, pageSize: 10 });
|
17
|
22
|
}, [])
|
|
23
|
+
|
18
|
24
|
// 查询列表
|
19
|
|
- const getList = params => {
|
20
|
|
- request({ ...apis.contact.list, params: { ...params } }).then(data => {
|
|
25
|
+ const getList = (params) => {
|
|
26
|
+ request({ ...apis.fund.contactList, params: { ...params, contentType: 'promote' } }).then((data) => {
|
21
|
27
|
console.log(data)
|
22
|
28
|
setData(data)
|
23
|
29
|
})
|
24
|
30
|
}
|
25
|
31
|
|
26
|
|
- const toAdd = (id) => () => {
|
27
|
|
- router.push({
|
28
|
|
- pathname: '/contact/contact/add',
|
29
|
|
- // query: {
|
30
|
|
- // id
|
31
|
|
- // },
|
32
|
|
- });
|
33
|
|
- }
|
34
|
|
-
|
35
|
|
- const toEdit = (id) => () => {
|
36
|
|
- router.push({
|
37
|
|
- pathname: '/contact/contact/detail',
|
38
|
|
- query: {
|
39
|
|
- id
|
40
|
|
- },
|
41
|
|
- });
|
42
|
|
- }
|
43
|
32
|
|
|
33
|
+ // 提交事件
|
44
|
34
|
const handleSubmit = (e, props) => {
|
45
|
|
- console.log(e)
|
46
|
35
|
e.preventDefault();
|
47
|
36
|
props.form.validateFields((err, values) => {
|
48
|
37
|
if (!err) {
|
49
|
|
- getList({ pageNum: 1, pageSize: 10, ...values })
|
50
|
|
- }
|
51
|
|
- });
|
52
|
|
- }
|
53
|
|
-
|
54
|
|
- function handleReset() {
|
55
|
|
- props.form.resetFields();
|
56
|
|
- getList({ pageNum: 1, pageSize: 10 });
|
57
|
|
- }
|
|
38
|
+ let { ...submitValue } = values
|
58
|
39
|
|
59
|
|
- const toDel = rowData => () => {
|
60
|
|
- if (contactList.length < 1) {
|
61
|
|
- message.info('请至少选择一条数据')
|
62
|
|
- return
|
63
|
|
- }
|
64
|
|
-
|
65
|
|
- Modal.confirm({
|
66
|
|
- title: '确定删除联系人信息吗',
|
67
|
|
- okText: '确定',
|
68
|
|
- cancelText: '取消',
|
69
|
|
- onOk() {
|
70
|
|
- request({ ...apis.contact.batchDeleteContact, data: contactList, }).then((data) => {
|
71
|
|
- message.info("操作成功")
|
72
|
|
- getList({ pageNum: 1, pageSize: 10 });
|
73
|
|
- }).catch((err) => {
|
74
|
|
-
|
75
|
|
- })
|
76
|
|
- },
|
77
|
|
- onCancel() { },
|
|
40
|
+ getList({ pageNum: 1, pageSize: 10, ...submitValue })
|
|
41
|
+ }
|
78
|
42
|
});
|
79
|
43
|
}
|
80
|
44
|
|
81
|
|
- const rowSelection = {
|
82
|
|
- onChange: (selectedRowKeys, selectedRows) => {
|
83
|
|
- console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
|
84
|
|
- setContactList(selectedRows)
|
85
|
|
- },
|
86
|
|
- };
|
|
45
|
+ const changePageNum = (pageNumber) => {
|
|
46
|
+ let { ...submitValue } = props.form.getFieldsValue()
|
87
|
47
|
|
88
|
|
- const changePageNum = pageNumber => {
|
89
|
|
- getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
|
|
48
|
+ getList({ pageNum: pageNumber, pageSize: 10, ...submitValue })
|
90
|
49
|
}
|
91
|
50
|
|
|
51
|
+ /**
|
|
52
|
+ *
|
|
53
|
+ *
|
|
54
|
+ * @param {*} props
|
|
55
|
+ * @returns
|
|
56
|
+ */
|
92
|
57
|
const columns = [
|
93
|
58
|
{
|
94
|
59
|
title: '姓名',
|
95
|
60
|
dataIndex: 'contactName',
|
96
|
61
|
key: 'contactName',
|
97
|
62
|
align: 'center',
|
98
|
|
-
|
99
|
63
|
},
|
100
|
64
|
{
|
101
|
65
|
title: '性别',
|
102
|
66
|
dataIndex: 'sex',
|
103
|
67
|
key: 'sex',
|
104
|
68
|
align: 'center',
|
105
|
|
- render: (sex) => <span>{sex != null ? (sex === 1 ? '男' : '女') : ""}</span>,
|
|
69
|
+ render: (text, record) => <span>{record.sex == '1' ? '男' : record.sex == '2' ? '女' : '未知'}</span>
|
|
70
|
+
|
106
|
71
|
},
|
107
|
72
|
{
|
108
|
73
|
title: '头像',
|
|
@@ -124,11 +89,10 @@ function header(props) {
|
124
|
89
|
align: 'center',
|
125
|
90
|
},
|
126
|
91
|
{
|
127
|
|
- title: '内部岗位',
|
128
|
|
- dataIndex: 'job',
|
129
|
|
- key: 'job',
|
|
92
|
+ title: '对外头衔',
|
|
93
|
+ dataIndex: 'appellation',
|
|
94
|
+ key: 'appellation',
|
130
|
95
|
align: 'center',
|
131
|
|
-
|
132
|
96
|
},
|
133
|
97
|
{
|
134
|
98
|
title: '权重',
|
|
@@ -136,83 +100,99 @@ function header(props) {
|
136
|
100
|
key: 'orderNo',
|
137
|
101
|
align: 'center',
|
138
|
102
|
},
|
139
|
|
- {
|
140
|
|
- title: '操作',
|
141
|
|
- dataIndex: 'handle',
|
142
|
|
- key: 'handle',
|
143
|
|
- align: 'center',
|
144
|
|
- render: (x, row) => (
|
145
|
|
- <>
|
146
|
|
- <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEdit(row.contactId)}>
|
147
|
|
- 删除
|
148
|
|
- </span>
|
149
|
|
- </>
|
150
|
|
- ),
|
151
|
|
- },
|
|
103
|
+
|
152
|
104
|
];
|
|
105
|
+ function handleReset() {
|
|
106
|
+ props.form.resetFields();
|
|
107
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+ const rowSelection = {
|
|
112
|
+ onChange: (selectedRowKeys, selectedRows) => {
|
|
113
|
+ console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
|
|
114
|
+ setContactList(selectedRows)
|
|
115
|
+ },
|
|
116
|
+ };
|
153
|
117
|
|
|
118
|
+ const toDel = () => {
|
|
119
|
+ if (contactList.length < 1) {
|
|
120
|
+ message.info('请至少选择一条数据')
|
|
121
|
+ return
|
|
122
|
+ }
|
|
123
|
+ Modal.confirm({
|
|
124
|
+ title: `确认将所选的${contactList.length}条数据删除`,
|
|
125
|
+ okText: '确定',
|
|
126
|
+ cancelText: '取消',
|
|
127
|
+ onOk() {
|
|
128
|
+ request({ ...apis.fund.delContact, data: contactList,params: {contactType: 'promote'} }).then((data) => {
|
|
129
|
+ message.info("操作成功")
|
|
130
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
131
|
+ setContactList([])
|
|
132
|
+ }).catch((err) => {
|
|
133
|
+
|
|
134
|
+ })
|
|
135
|
+ },
|
|
136
|
+ onCancel() { },
|
|
137
|
+ });
|
|
138
|
+ }
|
154
|
139
|
const { getFieldDecorator } = props.form
|
155
|
140
|
return (
|
156
|
141
|
|
157
|
142
|
<>
|
158
|
|
- <div>
|
159
|
|
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
160
|
|
- <Form.Item>
|
161
|
|
- {getFieldDecorator('contactName')(
|
162
|
|
- <Input
|
163
|
|
- prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
164
|
|
- placeholder="姓名"
|
165
|
|
- />,
|
166
|
|
- )}
|
167
|
|
- </Form.Item>
|
168
|
|
- <Form.Item>
|
169
|
|
- {getFieldDecorator('telephone')(
|
170
|
|
- <Input style={{ width: '180px' }} placeholder="固话">
|
171
|
|
-
|
172
|
|
- </Input>,
|
173
|
|
- )}
|
174
|
|
- </Form.Item>
|
175
|
|
-
|
176
|
|
- <Form.Item>
|
177
|
|
- {getFieldDecorator('phone')(
|
178
|
|
- <Input
|
179
|
|
- prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
180
|
|
- placeholder="手机号"
|
181
|
|
- />,
|
182
|
|
- )}
|
183
|
|
- </Form.Item>
|
184
|
|
- <Form.Item>
|
185
|
|
- {getFieldDecorator('job')(
|
186
|
|
- <Input
|
187
|
|
- prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
188
|
|
- placeholder="内部岗位"
|
189
|
|
- />,
|
190
|
|
- )}
|
191
|
|
- </Form.Item>
|
192
|
|
- <Form.Item>
|
193
|
|
-
|
194
|
|
- <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
195
|
|
- 搜索
|
196
|
|
- </Button>
|
197
|
|
- {/* */}
|
198
|
|
- <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
199
|
|
- 重置
|
200
|
|
- </Button>
|
201
|
|
- </Form.Item>
|
202
|
|
- </Form>
|
203
|
|
-
|
204
|
|
- <Button type="danger" className={styles.addBtn} onClick={toAdd()}>选择联系人</Button>
|
205
|
|
-
|
206
|
|
- <Table rowSelection={rowSelection} rowKey={r => r.contactId} dataSource={data.records} columns={columns} pagination={false} />
|
207
|
|
-
|
208
|
|
- <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
209
|
|
- {<Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />}
|
210
|
|
- </div>
|
|
143
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)} >
|
|
144
|
+ <Form.Item>
|
|
145
|
+ {getFieldDecorator('contactName')(
|
|
146
|
+ <Input
|
|
147
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
148
|
+ placeholder="姓名"
|
|
149
|
+ />,
|
|
150
|
+ )}
|
|
151
|
+ </Form.Item>
|
|
152
|
+ <Form.Item>
|
|
153
|
+ {getFieldDecorator('telephone')(
|
|
154
|
+ <Input
|
|
155
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
156
|
+ placeholder="固话"
|
|
157
|
+ />,
|
|
158
|
+ )}
|
|
159
|
+ </Form.Item>
|
|
160
|
+ <Form.Item>
|
|
161
|
+ {getFieldDecorator('phone')(
|
|
162
|
+ <Input
|
|
163
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
164
|
+ placeholder="手机号"
|
|
165
|
+ />,
|
|
166
|
+ )}
|
|
167
|
+ </Form.Item>
|
|
168
|
+ <Form.Item>
|
|
169
|
+ {getFieldDecorator('appellation')(
|
|
170
|
+ <Input
|
|
171
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
172
|
+ placeholder="对外头衔"
|
|
173
|
+ />,
|
|
174
|
+ )}
|
|
175
|
+ </Form.Item>
|
|
176
|
+ <Form.Item>
|
|
177
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
178
|
+ 搜索
|
|
179
|
+ </Button>
|
|
180
|
+ <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
181
|
+ 重置
|
|
182
|
+ </Button>
|
|
183
|
+ </Form.Item>
|
|
184
|
+ </Form>
|
|
185
|
+ <div style={{ margin: '10px 0 16px 0', display: 'flex' }}>
|
|
186
|
+ <SelectContact type="danger" onClick={() => getList({ pageNum: 1, pageSize: 10 })} />
|
|
187
|
+ <Button type="primary" onClick={() => toDel()} style={{ marginLeft: '30px' }} >删除</Button>
|
|
188
|
+ </div>
|
|
189
|
+ <Table rowSelection={rowSelection} rowKey={r => r.contactId} dataSource={data.records} columns={columns} pagination={false} />
|
|
190
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
191
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
|
211
|
192
|
</div>
|
212
|
193
|
</>
|
213
|
194
|
)
|
214
|
195
|
}
|
215
|
|
-
|
216
|
196
|
const WrappedHeader = Form.create({ name: 'header' })(header);
|
217
|
197
|
|
218
|
198
|
export default WrappedHeader
|