zlisen 3 years ago
parent
commit
d7313589b8

+ 1
- 1
src/pages/customer/Customer/PublicCustomer/components/AssistConsultant.jsx View File

@@ -109,7 +109,7 @@ const AssistConsultant = props => {
109 109
       render: (_, record) => (
110 110
         <>
111 111
           {
112
-            <Button type="danger" onClick={() => submitGm(record)}>
112
+            <Button type="primary" onClick={() => submitGm(record)}>
113 113
               确定
114 114
             </Button>
115 115
           }

+ 353
- 137
src/pages/customer/Customer/PublicCustomer/components/BatchAssistConsultant.jsx View File

@@ -1,11 +1,27 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
2
+import {
3
+  Form,
4
+  Icon,
5
+  Input,
6
+  Button,
7
+  DatePicker,
8
+  Select,
9
+  Card,
10
+  Row,
11
+  Col,
12
+  Pagination,
13
+  Alert,
14
+  Table,
15
+  Avatar,
16
+  Radio,
17
+  Modal,
18
+  Descriptions,
19
+  notification,
20
+} from 'antd';
3 21
 import moment from 'moment';
4
-import request from '../../../../utils/request';
5
-import apis from '../../../../services/apis';
6
-import Styles from '../style.less';
7
-import BuildSelect from '../../../../components/SelectButton/BuildSelect'
8
-
22
+import request from '@/utils/request';
23
+import apis from '@/services/apis';
24
+import BuildSelect from '@/components/SelectButton/BuildSelect';
9 25
 
10 26
 const { Option } = Select;
11 27
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -17,154 +33,354 @@ const { Meta } = Card;
17 33
  * @param {*} props
18 34
  * @returns
19 35
  */
20
-class ModalAttribution extends React.Component {
21
-  constructor(props) {
22
-    super(props);
23
-    console.log(props, 'props')
24
-    this.state = {
25
-       dataSource: { records: [] },
26
-       visibleData: { visible: false, customerId: [], buildingName: '' },
27
-    }
28
-  }
36
+const BatchAssistConsultant = props => {
37
+  const { visible, data } = props.modelProps || {};
38
+  console.log(data, '-------------');
39
+  const [tableData, setTableData] = useState({});
40
+  const [buildingId, setBuildingId] = useState();
41
+  const [loading, setLoading] = useState(false);
42
+
43
+  const openNotificationWithIcon = (type, message) => {
44
+    notification[type]({
45
+      message,
46
+      description: '',
47
+    });
48
+  };
29 49
 
30
-  // 挂载之后
31
-  componentDidMount() {
32
-    // this.getList({ pageNumber: 1, pageSize: 5 })
50
+  function getList(params) {
51
+    // 网路请求
52
+    setLoading(true);
53
+    request({
54
+      ...apis.customer.buildingConsultant,
55
+      params: { ...params },
56
+    })
57
+      .then(res => {
58
+        console.log(res, 'res');
59
+        setTableData(res);
60
+        setLoading(false);
61
+      })
62
+      .catch(err => {
63
+        openNotificationWithIcon('error', err);
64
+        setLoading(false);
65
+      });
33 66
   }
34 67
 
35
-  componentDidUpdate(preProps, preState) {
36
-    console.log(this.props.visibleData)
37
-    if (this.props.visibleData.visible !== preState.visibleData.visible) {
38
-      this.getList({ pageNumber: 1, pageSize: 5,buildingId: this.props.visibleData.buildingId})
39
-      this.setState({ visibleData: this.props.visibleData });
68
+  useEffect(() => {
69
+    if (visible) {
70
+      getList({ pageNumber: 1, pageSize: 5, buildingId: data.buildingId });
71
+    } else {
72
+      setTableData({});
40 73
     }
41
-  }
74
+  }, [visible]);
42 75
 
43
-  // 弹框确定按钮
44
-  // eslint-disable-next-line react/sort-comp
45
-  handleOk() {
46
-    this.props.onCancel()
76
+  // 分页
77
+  function onChange(pageNum) {
78
+    getList({ pageNumber: pageNum, pageSize: 5,buildingId: buildingId||data.buildingId });
47 79
   }
48 80
 
49
-  // 弹框取消按钮
50
-  handleCancel() {
51
-    this.props.onCancel()
81
+  function changBuilding(buildingId) {
82
+    if (buildingId) {
83
+      setBuildingId(buildingId);
84
+      getList({ pageNumber: 1, pageSize: 5, buildingId: buildingId });
85
+    }
52 86
   }
53 87
 
54
-  changBuilding(buildingId){
55
-    this.getUserList({ pageNumber: 1, pageSize: 5, buildingId: buildingId })
56
-    this.setState({ visibleData: { visible: this.props.visibleData.visible, customerId: this.props.visibleData.customerId, buildingName: buildingId } });
57
-  }
88
+  //   // 提交
89
+  //  function submitGm(record) {
90
+  //   // 网路请求
91
+  //   request({
92
+  //     ...apis.customer.consultantAssist,
93
+  //     urlData: { id: data.customerId },
94
+  //     data: { userId: record.userId, buildingId: data.buildingName || data.buildingId },
95
+  //   })
96
+  //     .then(res => {
97
+  //       // eslint-disable-next-line no-unused-expressions
58 98
 
59
-  getUserList(params){
60
-    console.log('params: ', params)
61
-    if (params.buildingId === '' || params.buildingId === null || params.buildingId === undefined) {
62
-      return
63
-    }
64
-    // 网路请求
65
-    request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
66
-      this.setState({ dataSource: res })
67
-    }).catch(err => {
68
-      message.err(err)
69
-    })
70
-  }
99
+  //       openNotificationWithIcon('success', '操作成功');
100
+  //       props.handleCancel();
101
+  //     })
102
+  //     .catch(err => {
103
+  //       // eslint-disable-next-line no-unused-expressions
104
+  //     });
105
+  // }
71 106
 
72
-  getList(params) {
107
+  // 提交
108
+  function submitGm(record) {
73 109
     // 网路请求
74
-    console.log('params: ', params)
75
-    request({ ...apis.customer.buildingConsultant , params: { ...params }}).then(res => {
76
-      this.setState({ dataSource: res })
77
-    }).catch(err => {
78
-      
110
+    request({
111
+      ...apis.customer.batchConsultantAssist,
112
+      data: {
113
+        userId: record.userId,
114
+        buildingId: buildingId || data.buildingId,
115
+        customerIds: data.customerId,
116
+      },
79 117
     })
118
+      .then(res => {
119
+        if (res != null && res.failNum > 0) {
120
+          openNotificationWithIcon(
121
+            'success',
122
+            '共' + res.totalNum + '条数据,失败操作' + res.failNum + '条',
123
+          );
124
+        } else {
125
+          openNotificationWithIcon('success', '操作成功');
126
+        }
127
+        props.handleCancel();
128
+      })
129
+      .catch(err => {
130
+        // eslint-disable-next-line no-unused-expressions
131
+      });
80 132
   }
81 133
 
82
-  openNotificationWithIcon = (type, message) => {
83
-    notification[type]({
84
-      message,
85
-      description:
86
-        '',
87
-    });
88
-  };
134
+  const columns = [
135
+    {
136
+      title: '姓名',
137
+      dataIndex: 'userName',
138
+      key: 'userName',
139
+    },
140
+    {
141
+      title: '电话',
142
+      dataIndex: 'phone',
143
+      key: 'phone',
144
+    },
145
+    {
146
+      title: '部门',
147
+      dataIndex: 'department',
148
+      key: 'department',
149
+    },
150
+    {
151
+      title: '岗位',
152
+      dataIndex: 'position',
153
+      key: 'position',
154
+    },
155
+    {
156
+      title: '操作',
157
+      dataIndex: 'personId',
158
+      key: 'personId',
159
+      // eslint-disable-next-line no-nested-ternary
160
+      render: (_, record) => (
161
+        <>
162
+          {
163
+            <Button type="primary" onClick={() => submitGm(record)}>
164
+              确定
165
+            </Button>
166
+          }
167
+        </>
168
+      ),
169
+    },
170
+  ];
89 171
 
90
-   // 分页
91
-  onChange(pageNum) {
92
-    this.getList({ pageNumber: pageNum, pageSize: 5, buildingId: this.state.visibleData.buildingName ||this.props.visibleData.buildingId})
172
+  return (
173
+    <>
174
+      <Modal
175
+        title={'分配置业顾问'}
176
+        width={800}
177
+        destroyOnClose="true"
178
+        footer={null}
179
+        visible={visible}
180
+        onCancel={() => props.onCancel()}
181
+      >
182
+        {data && (
183
+          <>
184
+            {data.customerId?.length > 0 && (
185
+              <>
186
+                <span>你正在为{data.customerId.length}位公客分配置业顾问</span>
187
+                <br />
188
+                <br />
189
+              </>
190
+            )}
191
+            {data?.buildingId == null && (
192
+              <div style={{marginBottom:'20px'}}>
193
+                <BuildSelect
194
+                onChange={e => changBuilding(e)}
195
+                value={buildingId || data?.buildingId}
196
+              />
197
+              </div>
198
+            )}
199
+            <Table
200
+              dataSource={tableData.records}
201
+              columns={columns}
202
+              loading={loading}
203
+              key={'userId'}
204
+              pagination={{
205
+                pageSize: tableData.pageSize,
206
+                total: tableData.total,
207
+                onChange: e => onChange(e),
208
+              }}
209
+            />
210
+          </>
211
+        )}
212
+      </Modal>
213
+    </>
214
+  );
215
+};
93 216
 
94
-    // this.getUserList({ pageNumber: pageNum, pageSize: 5, buildingId: this.state.visibleData.buildingName })
95
-  }
217
+export default BatchAssistConsultant;
96 218
 
97
-  // 提交
98
-  submitGm(record) {
99
-    // 网路请求
100
-    request({ ...apis.customer.batchConsultantAssist, data: { userId: record.userId
101
-      ,buildingId:this.state.visibleData.buildingName  || this.props.visibleData.buildingId
102
-      , customerIds: this.state.visibleData.customerId } }).then(res => {
103
-      // eslint-disable-next-line no-unused-expressions
104
-      debugger
105
-      if(res!= null && res.failNum > 0 ){
106
-        this.openNotificationWithIcon('success', '共'+res.totalNum+'条数据,失败操作'+res.failNum+'条')
107
-      }else{
108
-        this.openNotificationWithIcon('success', '操作成功')
109
-      }
110
-      this.handleCancel()
111
-    }).catch(err => {
112
-      // eslint-disable-next-line no-unused-expressions
113
-  
114
-    })
115
-  }
219
+// import React, { useState, useEffect } from 'react';
220
+// import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
221
+// import moment from 'moment';
222
+// import request from '@/utils/request';
223
+// import apis from '@/services/apis';
224
+// import BuildSelect from '@/components/SelectButton/BuildSelect'
116 225
 
117
-  render() {
118
-    const columns = [
119
-      // {
120
-      //   title: '编号',
121
-      //   dataIndex: 'userId',
122
-      //   key: 'userId',
123
-      // },
124
-      {
125
-        title: '姓名',
126
-        dataIndex: 'userName',
127
-        key: 'userName',
128
-      },
129
-      {
130
-        title: '电话',
131
-        dataIndex: 'phone',
132
-        key: 'phone',
133
-      },
134
-      {
135
-        title: '部门',
136
-        dataIndex: 'department',
137
-        key: 'department',
138
-      },
139
-      {
140
-        title: '岗位',
141
-        dataIndex: 'position',
142
-        key: 'position',
143
-      },
144
-      {
145
-        title: '操作',
146
-        dataIndex: 'personId',
147
-        key: 'personId',
148
-        // eslint-disable-next-line no-nested-ternary
149
-        render: (_, record) => <>{ <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>, },
150
-    ]
151
-    return (
152
-      <>
153
-        <Modal
154
-            title="分配置业顾问"
155
-            width={800}
156
-            destroyOnClose="true"
157
-            footer={null}
158
-            visible={this.state.visibleData.visible}
159
-            onCancel={(e) => this.handleCancel(e)}
160
-          >
161
-            <span>你正在为{this.props.visibleData.customerId.length}位公客分配置业顾问</span><br/><br/>
162
-            {this.props.visibleData.buildingId == null && <BuildSelect onChange={this.changBuilding.bind(this)} value={this.state.visibleData.buildingName} />}
163
-            <Table rowKey="BatchAssistConsultant" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
164
-          </Modal>
165
-      </>
166
-    );
167
-  }
168
-}
226
+// const { Option } = Select;
227
+// // eslint-disable-next-line @typescript-eslint/no-unused-vars
228
+// const { Meta } = Card;
229
+
230
+// /**
231
+//  * 分配置业顾问
232
+//  *
233
+//  * @param {*} props
234
+//  * @returns
235
+//  */
236
+// class ModalAttribution extends React.Component {
237
+//   constructor(props) {
238
+//     super(props);
239
+//     console.log(props, 'props')
240
+//     this.state = {
241
+//        dataSource: { records: [] },
242
+//        visibleData: { visible: false, customerId: [], buildingName: '' },
243
+//     }
244
+//   }
245
+
246
+//   // 挂载之后
247
+//   componentDidMount() {
248
+//     // this.getList({ pageNumber: 1, pageSize: 5 })
249
+//   }
250
+
251
+//   componentDidUpdate(preProps, preState) {
252
+//     console.log(this.props.visibleData)
253
+//     if (this.props.visibleData.visible !== preState.visibleData.visible) {
254
+//       this.getList({ pageNumber: 1, pageSize: 5,buildingId: this.props.visibleData.buildingId})
255
+//       this.setState({ visibleData: this.props.visibleData });
256
+//     }
257
+//   }
258
+
259
+//   // 弹框确定按钮
260
+//   // eslint-disable-next-line react/sort-comp
261
+//   handleOk() {
262
+//     this.props.onCancel()
263
+//   }
264
+
265
+//   // 弹框取消按钮
266
+//   handleCancel() {
267
+//     this.props.onCancel()
268
+//   }
269
+
270
+//   changBuilding(buildingId){
271
+//     this.getUserList({ pageNumber: 1, pageSize: 5, buildingId: buildingId })
272
+//     this.setState({ visibleData: { visible: this.props.visibleData.visible, customerId: this.props.visibleData.customerId, buildingName: buildingId } });
273
+//   }
274
+
275
+//   getUserList(params){
276
+//     console.log('params: ', params)
277
+//     if (params.buildingId === '' || params.buildingId === null || params.buildingId === undefined) {
278
+//       return
279
+//     }
280
+//     // 网路请求
281
+//     request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
282
+//       this.setState({ dataSource: res })
283
+//     }).catch(err => {
284
+//       message.err(err)
285
+//     })
286
+//   }
287
+
288
+//   getList(params) {
289
+//     // 网路请求
290
+//     console.log('params: ', params)
291
+//     request({ ...apis.customer.buildingConsultant , params: { ...params }}).then(res => {
292
+//       this.setState({ dataSource: res })
293
+//     }).catch(err => {
294
+
295
+//     })
296
+//   }
297
+
298
+//   openNotificationWithIcon = (type, message) => {
299
+//     notification[type]({
300
+//       message,
301
+//       description:
302
+//         '',
303
+//     });
304
+//   };
305
+
306
+//    // 分页
307
+//   onChange(pageNum) {
308
+//     this.getList({ pageNumber: pageNum, pageSize: 5, buildingId: this.state.visibleData.buildingName ||this.props.visibleData.buildingId})
309
+
310
+//     // this.getUserList({ pageNumber: pageNum, pageSize: 5, buildingId: this.state.visibleData.buildingName })
311
+//   }
312
+
313
+//   // 提交
314
+//   submitGm(record) {
315
+//     // 网路请求
316
+//     request({ ...apis.customer.batchConsultantAssist, data: { userId: record.userId
317
+//       ,buildingId:this.state.visibleData.buildingName  || this.props.visibleData.buildingId
318
+//       , customerIds: this.state.visibleData.customerId } }).then(res => {
319
+//       // eslint-disable-next-line no-unused-expressions
320
+//       debugger
321
+//       if(res!= null && res.failNum > 0 ){
322
+//         this.openNotificationWithIcon('success', '共'+res.totalNum+'条数据,失败操作'+res.failNum+'条')
323
+//       }else{
324
+//         this.openNotificationWithIcon('success', '操作成功')
325
+//       }
326
+//       this.handleCancel()
327
+//     }).catch(err => {
328
+//       // eslint-disable-next-line no-unused-expressions
329
+
330
+//     })
331
+//   }
332
+
333
+//   render() {
334
+//     const columns = [
335
+//       // {
336
+//       //   title: '编号',
337
+//       //   dataIndex: 'userId',
338
+//       //   key: 'userId',
339
+//       // },
340
+//       {
341
+//         title: '姓名',
342
+//         dataIndex: 'userName',
343
+//         key: 'userName',
344
+//       },
345
+//       {
346
+//         title: '电话',
347
+//         dataIndex: 'phone',
348
+//         key: 'phone',
349
+//       },
350
+//       {
351
+//         title: '部门',
352
+//         dataIndex: 'department',
353
+//         key: 'department',
354
+//       },
355
+//       {
356
+//         title: '岗位',
357
+//         dataIndex: 'position',
358
+//         key: 'position',
359
+//       },
360
+//       {
361
+//         title: '操作',
362
+//         dataIndex: 'personId',
363
+//         key: 'personId',
364
+//         // eslint-disable-next-line no-nested-ternary
365
+//         render: (_, record) => <>{ <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>, },
366
+//     ]
367
+//     return (
368
+//       <>
369
+//         <Modal
370
+//             title="分配置业顾问"
371
+//             width={800}
372
+//             destroyOnClose="true"
373
+//             footer={null}
374
+//             visible={this.state.visibleData.visible}
375
+//             onCancel={(e) => this.handleCancel(e)}
376
+//           >
377
+//             <span>你正在为{this.props.visibleData.customerId.length}位公客分配置业顾问</span><br/><br/>
378
+//             {this.props.visibleData.buildingId == null && <BuildSelect onChange={this.changBuilding.bind(this)} value={this.state.visibleData.buildingName} />}
379
+//             <Table rowKey="BatchAssistConsultant" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
380
+//           </Modal>
381
+//       </>
382
+//     );
383
+//   }
384
+// }
169 385
 
170
-export default ModalAttribution
386
+// export default ModalAttribution