Browse Source

调整归属

魏熙美 5 years ago
parent
commit
49e73f3399
2 changed files with 156 additions and 3 deletions
  1. 148
    3
      src/pages/customer/customerlist/index.jsx
  2. 8
    0
      src/services/apis.js

+ 148
- 3
src/pages/customer/customerlist/index.jsx View File

@@ -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, Radio } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
@@ -10,7 +10,134 @@ const { Option } = Select;
10 10
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
11 11
 const { Meta } = Card;
12 12
 
13
-const tempDate = [{ code: 's101' }]
13
+/**
14
+ * 调整归属
15
+ *  (废弃, 后面研究)
16
+ *
17
+ * @param {*} props
18
+ * @returns
19
+ */
20
+class ModalTable extends React.Component {
21
+  constructor(props) {
22
+    super(props);
23
+    this.state = {
24
+       dataSource: { records: [] },
25
+       visibleData: { visible: false, customerId: '', realtyConsultant: '' },
26
+    }
27
+  }
28
+
29
+  // 挂载之后
30
+  componentDidMount() {
31
+    this.getList({ pageNumber: 1, pageSize: 5 })
32
+  }
33
+
34
+  componentDidUpdate(preProps, preState) {
35
+    if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
36
+      this.getList({ pageNumber: 1, pageSize: 5 })
37
+      this.setState({ visibleData: this.props.visibleData });
38
+    }
39
+  }
40
+
41
+  // 弹框确定按钮
42
+  // eslint-disable-next-line react/sort-comp
43
+  handleOk() {
44
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
45
+  }
46
+
47
+  // 弹框取消按钮
48
+  handleCancel() {
49
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
50
+  }
51
+
52
+  getList(params) {
53
+    // 网路请求
54
+    request({ ...apis.customer.consultant, params: { ...params } }).then(res => {
55
+      this.setState({ dataSource: res })
56
+    }).catch(err => {
57
+      // eslint-disable-next-line no-unused-expressions
58
+      <Alert
59
+        style={{
60
+          marginBottom: 24,
61
+        }}
62
+        message={err}
63
+        type="error"
64
+        showIcon
65
+      />
66
+    })
67
+  }
68
+
69
+   // 分页
70
+  onChange(pageNum) {
71
+    this.getList({ pageNumber: pageNum, pageSize: 5 })
72
+  }
73
+
74
+  // 提交
75
+  submitGm() {
76
+    const { url, method } = apis.customer.recommendEdit
77
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
78
+
79
+    // 网路请求
80
+    request({ url: tempUrl, method, data: { ...this.state.visibleData } }).then(res => {
81
+      this.handleCancel()
82
+    }).catch(err => {
83
+      // eslint-disable-next-line no-unused-expressions
84
+      <Alert
85
+        style={{
86
+          marginBottom: 24,
87
+        }}
88
+        message={err}
89
+        type="error"
90
+        showIcon
91
+      />
92
+    })
93
+  }
94
+
95
+  render() {
96
+    const columns = [
97
+      {
98
+        title: '姓名',
99
+        dataIndex: 'name',
100
+        key: 'name',
101
+      },
102
+      {
103
+        title: '电话',
104
+        dataIndex: 'phone',
105
+        key: 'phone',
106
+      },
107
+      {
108
+        title: '部门',
109
+        dataIndex: 'department',
110
+        key: 'department',
111
+      },
112
+      {
113
+        title: '岗位',
114
+        dataIndex: 'post',
115
+        key: 'post',
116
+      },
117
+      {
118
+        title: '操作',
119
+        dataIndex: 'personId',
120
+        key: 'personId',
121
+        // eslint-disable-next-line no-nested-ternary
122
+        render: (_, record) => <><Button className={Styles.SubmitButton} onClick={() => this.submitGm()}>确定</Button></>,
123
+      },
124
+    ]
125
+    return (
126
+      <>
127
+        <Modal
128
+            title="选择置业顾问"
129
+            destroyOnClose="true"
130
+            footer={null}
131
+            visible={this.state.visibleData.visible}
132
+            // onOk={() => this.handleOk()}
133
+            onCancel={(e) => this.handleCancel(e)}
134
+          >
135
+            <Table dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
136
+          </Modal>
137
+      </>
138
+    );
139
+  }
140
+}
14 141
 
15 142
 /**
16 143
  *
@@ -28,6 +155,12 @@ function body(props) {
28 155
     // eslint-disable-next-line react-hooks/rules-of-hooks
29 156
   const [customerType, setCustomerType] = useState('private')
30 157
 
158
+  // 调整归属 ============  start
159
+  // eslint-disable-next-line react-hooks/rules-of-hooks
160
+  const [gVisibleData, setGVisibleData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
161
+
162
+  // 调整归属 ============= end
163
+
31 164
   // eslint-disable-next-line react-hooks/rules-of-hooks
32 165
   useEffect(() => {
33 166
     getList({ pageNumber: 1, pageSize: 10, customerType })
@@ -79,6 +212,13 @@ function body(props) {
79 212
     getList({ pageNumber: 1, pageSize: 10, customerType: value })
80 213
   }
81 214
 
215
+  // 调整归属 ============ start
216
+  // 调整归属 显示
217
+  function gM(row) {
218
+    setGVisibleData({ visible: true, customerId: row.customerId, realtyConsultant: row.realtyConsultant })
219
+  }
220
+  // 调整归属 ============ end
221
+
82 222
   const columns = [
83 223
     {
84 224
       title: '头像',
@@ -134,7 +274,7 @@ function body(props) {
134 274
         <>
135 275
           <sapn className={ customerType === 'private' ? Styles.text : Styles.displayS }>变更状态</sapn>
136 276
           &nbsp;&nbsp;
137
-          <sapn className={  customerType === 'private' ? Styles.text : Styles.displayS }>调整归属</sapn>
277
+          <sapn className={ customerType === 'private' ? Styles.text : Styles.displayS } onClick={() => gM(record)}>调整归属</sapn>
138 278
           <br/>
139 279
           <sapn className={ Styles.text }>查看详情</sapn>
140 280
           &nbsp;&nbsp;
@@ -203,9 +343,14 @@ function body(props) {
203 343
         </Radio.Group>
204 344
        </div>
205 345
       <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
346
+
347
+        {/* 调整归属 */}
348
+        <ModalTable visibleData={gVisibleData} />
349
+
206 350
     </>
207 351
   );
208 352
 }
353
+
209 354
 const WrappedBody = Form.create({ name: 'body' })(body);
210 355
 
211 356
 export default WrappedBody

+ 8
- 0
src/services/apis.js View File

@@ -80,5 +80,13 @@ export default {
80 80
       method: 'GET',
81 81
       url: `${prefix}/customer/recommend`,
82 82
     },
83
+    consultant: {
84
+      method: 'GET',
85
+      url: `${prefix}/consultant`,
86
+    },
87
+    recommendEdit: {
88
+      method: 'PUT',
89
+      url: `${prefix}/customer/recommend/edit/id`,
90
+    },
83 91
   },
84 92
 }