|
@@ -1,5 +1,5 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar } from 'antd';
|
|
2
|
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Modal } from 'antd';
|
3
|
3
|
import moment from 'moment';
|
4
|
4
|
import request from '../../../utils/request';
|
5
|
5
|
import apis from '../../../services/apis';
|
|
@@ -11,6 +11,127 @@ const { Option } = Select;
|
11
|
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
12
|
12
|
const { Meta } = Card;
|
13
|
13
|
|
|
14
|
+class ModalTable extends React.Component {
|
|
15
|
+ constructor(props) {
|
|
16
|
+ super(props);
|
|
17
|
+ this.state = {
|
|
18
|
+ dataSource: { records: [] },
|
|
19
|
+ visibleData: { visible: false, customerId: '', realtyConsultant: '' },
|
|
20
|
+ }
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ // 挂载之后
|
|
24
|
+ componentDidMount() {
|
|
25
|
+ this.getList({ pageNumber: 1, pageSize: 5 })
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ componentDidUpdate(preProps, preState) {
|
|
29
|
+ if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
|
|
30
|
+ this.getList({ pageNumber: 1, pageSize: 5 })
|
|
31
|
+ this.setState({ visibleData: this.props.visibleData });
|
|
32
|
+ }
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ // 弹框确定按钮
|
|
36
|
+ // eslint-disable-next-line react/sort-comp
|
|
37
|
+ handleOk() {
|
|
38
|
+ this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ // 弹框取消按钮
|
|
42
|
+ handleCancel() {
|
|
43
|
+ this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ getList(params) {
|
|
47
|
+ // 网路请求
|
|
48
|
+ request({ ...apis.customer.consultant, params: { ...params } }).then(res => {
|
|
49
|
+ this.setState({ dataSource: res })
|
|
50
|
+ }).catch(err => {
|
|
51
|
+ // eslint-disable-next-line no-unused-expressions
|
|
52
|
+ <Alert
|
|
53
|
+ style={{
|
|
54
|
+ marginBottom: 24,
|
|
55
|
+ }}
|
|
56
|
+ message={err}
|
|
57
|
+ type="error"
|
|
58
|
+ showIcon
|
|
59
|
+ />
|
|
60
|
+ })
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ // 分页
|
|
64
|
+ onChange(pageNum) {
|
|
65
|
+ this.getList({ pageNumber: pageNum, pageSize: 5 })
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ // 提交
|
|
69
|
+ submitGm() {
|
|
70
|
+ const { url, method } = apis.customer.recommendEdit
|
|
71
|
+ const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
|
|
72
|
+
|
|
73
|
+ // 网路请求
|
|
74
|
+ request({ url: tempUrl, method, data: { ...this.state.visibleData } }).then(res => {
|
|
75
|
+ this.handleCancel()
|
|
76
|
+ }).catch(err => {
|
|
77
|
+ // eslint-disable-next-line no-unused-expressions
|
|
78
|
+ <Alert
|
|
79
|
+ style={{
|
|
80
|
+ marginBottom: 24,
|
|
81
|
+ }}
|
|
82
|
+ message={err}
|
|
83
|
+ type="error"
|
|
84
|
+ showIcon
|
|
85
|
+ />
|
|
86
|
+ })
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ render() {
|
|
90
|
+ const columns = [
|
|
91
|
+ {
|
|
92
|
+ title: '姓名',
|
|
93
|
+ dataIndex: 'name',
|
|
94
|
+ key: 'name',
|
|
95
|
+ },
|
|
96
|
+ {
|
|
97
|
+ title: '电话',
|
|
98
|
+ dataIndex: 'phone',
|
|
99
|
+ key: 'phone',
|
|
100
|
+ },
|
|
101
|
+ {
|
|
102
|
+ title: '部门',
|
|
103
|
+ dataIndex: 'department',
|
|
104
|
+ key: 'department',
|
|
105
|
+ },
|
|
106
|
+ {
|
|
107
|
+ title: '岗位',
|
|
108
|
+ dataIndex: 'post',
|
|
109
|
+ key: 'post',
|
|
110
|
+ },
|
|
111
|
+ {
|
|
112
|
+ title: '操作',
|
|
113
|
+ dataIndex: 'personId',
|
|
114
|
+ key: 'personId',
|
|
115
|
+ // eslint-disable-next-line no-nested-ternary
|
|
116
|
+ render: (_, record) => <><Button className={Styles.SubmitButton} onClick={() => this.submitGm()}>确定</Button></>,
|
|
117
|
+ },
|
|
118
|
+ ]
|
|
119
|
+ return (
|
|
120
|
+ <>
|
|
121
|
+ <Modal
|
|
122
|
+ title="选择置业顾问"
|
|
123
|
+ destroyOnClose="true"
|
|
124
|
+ footer={null}
|
|
125
|
+ visible={this.state.visibleData.visible}
|
|
126
|
+ // onOk={() => this.handleOk()}
|
|
127
|
+ onCancel={(e) => this.handleCancel(e)}
|
|
128
|
+ >
|
|
129
|
+ <Table dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
|
|
130
|
+ </Modal>
|
|
131
|
+ </>
|
|
132
|
+ );
|
|
133
|
+ }
|
|
134
|
+}
|
14
|
135
|
/**
|
15
|
136
|
*
|
16
|
137
|
*
|
|
@@ -54,12 +175,16 @@ function body(props) {
|
54
|
175
|
}
|
55
|
176
|
});
|
56
|
177
|
}
|
57
|
|
-
|
|
178
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
179
|
+ const [gVisibleData, setGVisibleData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
|
58
|
180
|
// Change 事件
|
59
|
181
|
function handleSelectChange(e) {
|
60
|
182
|
// eslint-disable-next-line no-console
|
61
|
183
|
console.log(e)
|
62
|
184
|
}
|
|
185
|
+ function gM(row) {
|
|
186
|
+ setGVisibleData({ visible: true, customerId: row.customerId, realtyConsultant: row.realtyConsultant })
|
|
187
|
+ }
|
63
|
188
|
|
64
|
189
|
// 分页
|
65
|
190
|
function onChange(pageNum) {
|
|
@@ -123,7 +248,7 @@ function body(props) {
|
123
|
248
|
|
124
|
249
|
<sapn style={{ color: 'rgba(239,39,58,1)' }}>邀请经纪人</sapn>
|
125
|
250
|
|
126
|
|
- <sapn style={{ color: 'rgba(239,39,58,1)' }}>推荐客户</sapn>
|
|
251
|
+ <sapn style={{ color: 'rgba(239,39,58,1)' }} onClick={() => gM(record)}>推荐客户</sapn>
|
127
|
252
|
</>
|
128
|
253
|
}
|
129
|
254
|
</>
|
|
@@ -158,6 +283,8 @@ function body(props) {
|
158
|
283
|
</Form>
|
159
|
284
|
|
160
|
285
|
<Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
|
|
286
|
+ {/* 调整归属 */}
|
|
287
|
+ <ModalTable visibleData={gVisibleData} />
|
161
|
288
|
</>
|
162
|
289
|
);
|
163
|
290
|
}
|