浏览代码

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager into dev

傅行帆 5 年前
父节点
当前提交
f992499416

+ 159
- 0
src/pages/customer/customerlist/components/BatchAssistConsultant.jsx 查看文件

@@ -0,0 +1,159 @@
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';
3
+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
+
9
+
10
+const { Option } = Select;
11
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+const { Meta } = Card;
13
+
14
+/**
15
+ * 分配置业顾问
16
+ *
17
+ * @param {*} props
18
+ * @returns
19
+ */
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
+  }
29
+
30
+  // 挂载之后
31
+  componentDidMount() {
32
+    // this.getList({ pageNumber: 1, pageSize: 5 })
33
+  }
34
+
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, customerId: this.props.visibleData.customerId })
39
+      this.setState({ visibleData: this.props.visibleData });
40
+    }
41
+  }
42
+
43
+  // 弹框确定按钮
44
+  // eslint-disable-next-line react/sort-comp
45
+  handleOk() {
46
+    this.props.onCancel()
47
+  }
48
+
49
+  // 弹框取消按钮
50
+  handleCancel() {
51
+    this.props.onCancel()
52
+  }
53
+
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
+  }
58
+
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
+      
69
+    })
70
+  }
71
+
72
+  getList(params) {
73
+    // 网路请求
74
+    request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
75
+      this.setState({ dataSource: res })
76
+    }).catch(err => {
77
+      
78
+    })
79
+  }
80
+
81
+  openNotificationWithIcon = (type, message) => {
82
+    notification[type]({
83
+      message,
84
+      description:
85
+        '',
86
+    });
87
+  };
88
+
89
+   // 分页
90
+  onChange(pageNum) {
91
+    this.getList({ pageNumber: pageNum, pageSize: 5, buildingId: this.state.visibleData.buildingName })
92
+  }
93
+
94
+  // 提交
95
+  submitGm(record) {
96
+    // 网路请求
97
+    request({ ...apis.customer.batchConsultantAssist, data: { userId: record.userId, personIds: this.state.visibleData.customerId } }).then(res => {
98
+      // eslint-disable-next-line no-unused-expressions
99
+      this.openNotificationWithIcon('success', '操作成功')
100
+      this.handleCancel()
101
+    }).catch(err => {
102
+      // eslint-disable-next-line no-unused-expressions
103
+      this.openNotificationWithIcon('error', err)
104
+    })
105
+  }
106
+
107
+  render() {
108
+    const columns = [
109
+      // {
110
+      //   title: '编号',
111
+      //   dataIndex: 'userId',
112
+      //   key: 'userId',
113
+      // },
114
+      {
115
+        title: '姓名',
116
+        dataIndex: 'userName',
117
+        key: 'userName',
118
+      },
119
+      {
120
+        title: '电话',
121
+        dataIndex: 'phone',
122
+        key: 'phone',
123
+      },
124
+      {
125
+        title: '部门',
126
+        dataIndex: 'department',
127
+        key: 'department',
128
+      },
129
+      {
130
+        title: '岗位',
131
+        dataIndex: 'position',
132
+        key: 'position',
133
+      },
134
+      {
135
+        title: '操作',
136
+        dataIndex: 'personId',
137
+        key: 'personId',
138
+        // eslint-disable-next-line no-nested-ternary
139
+        render: (_, record) => <>{ <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>, },
140
+    ]
141
+    return (
142
+      <>
143
+        <Modal
144
+            title="分配置业顾问"
145
+            width={800}
146
+            destroyOnClose="true"
147
+            footer={null}
148
+            visible={this.state.visibleData.visible}
149
+            onCancel={(e) => this.handleCancel(e)}
150
+          >
151
+            <BuildSelect onChange={this.changBuilding.bind(this)} value={this.state.visibleData.buildingName} />
152
+            <Table rowKey="BatchAssistConsultant" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
153
+          </Modal>
154
+      </>
155
+    );
156
+  }
157
+}
158
+
159
+export default ModalAttribution

+ 63
- 10
src/pages/customer/customerlist/index.jsx 查看文件

@@ -8,6 +8,7 @@ import router from 'umi/router';
8 8
 
9 9
 import Attribution from './components/attribution'
10 10
 import AssistConsultant from './components/assistConsultant'
11
+import BatchAssistConsultant from './components/BatchAssistConsultant'
11 12
 import IntegralRecord from './components/integralRecord'
12 13
 import ModalRecommendRecord from './components/recommend'
13 14
 import ChangeStatus from './components/changeStatus'
@@ -60,6 +61,11 @@ function body(props) {
60 61
 
61 62
   const [loadingStatus, setLoadingStatus] = useState(false)
62 63
 
64
+  // 选中的公客信息
65
+  const [personInfo, setPersonInfo] = useState([])
66
+
67
+  const [batchAssistVisibleData, setBatchAssistVisibleData] = useState({visible: false, customerId: []})
68
+
63 69
   // eslint-disable-next-line react-hooks/rules-of-hooks
64 70
   useEffect(() => {
65 71
     getList({ pageNumber: 1, pageSize: 10, customerType })
@@ -148,6 +154,7 @@ function body(props) {
148 154
     setRecordVisibleData({ visible: false, customerId: '' })
149 155
     setStatusVisibleData({ visible: false, customerId: '' })
150 156
     setRecommendVisibleData({ visible: false, customerId: '' })
157
+    setBatchAssistVisibleData({ visible: false, customerId: '' })
151 158
   }
152 159
 
153 160
   function showRecord(record) {
@@ -155,6 +162,7 @@ function body(props) {
155 162
     setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
156 163
     setStatusVisibleData({ visible: false, customerId: '' })
157 164
     setRecommendVisibleData({ visible: false, customerId: '' })
165
+    setBatchAssistVisibleData({ visible: false, customerId: '' })
158 166
   }
159 167
 
160 168
   function showStatus(record) {
@@ -162,6 +170,7 @@ function body(props) {
162 170
     setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
163 171
     setRecommendVisibleData({ visible: false, customerId: '' })
164 172
     setStatusVisibleData({ visible: true, customerId: record.customerId, status: record.status })
173
+    setBatchAssistVisibleData({ visible: false, customerId: '' })
165 174
   }
166 175
 
167 176
   // 推荐客户
@@ -170,6 +179,7 @@ function body(props) {
170 179
     setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
171 180
     setStatusVisibleData({ visible: false, customerId: '', status: '' })
172 181
     setRecommendVisibleData({ visible: true, customerId: personId })
182
+    setBatchAssistVisibleData({ visible: false, customerId: '' })
173 183
   }
174 184
 
175 185
   //分配置业顾问
@@ -179,6 +189,19 @@ function body(props) {
179 189
     setStatusVisibleData({ visible: false, customerId: '' })
180 190
     setRecommendVisibleData({ visible: false, customerId: '' })
181 191
     setAssistVisibleData({ visible: true, customerId: personId })
192
+    setBatchAssistVisibleData({ visible: false, customerId: '' })
193
+  }
194
+
195
+  function batchAssistConsultant(){
196
+    if (personInfo.length <= 0){
197
+      return message.info("请至少选择一条数据");
198
+    }
199
+    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
200
+    setRecordVisibleData({ visible: false, customerId: '' })
201
+    setStatusVisibleData({ visible: false, customerId: '' })
202
+    setRecommendVisibleData({ visible: false, customerId: '' })
203
+    setAssistVisibleData({ visible: false, customerId: '' })
204
+    setBatchAssistVisibleData({ visible: true, customerId: personInfo })
182 205
   }
183 206
 
184 207
   function toCustomerDateil(record) {
@@ -237,9 +260,17 @@ function body(props) {
237 260
     setStatusVisibleData({ visible: false, customerId: '', status: '' })
238 261
     setRecommendVisibleData({ visible: false, customerId: '' })
239 262
     setAssistVisibleData({ visible: false, customerId: ''})
263
+    setBatchAssistVisibleData({visible: false, customerId: ''})
240 264
     getList({ pageNum: 1, pageSize: 10, customerType, ...props.form.getFieldsValue() })
241 265
   }
242 266
 
267
+    const rowSelection = {
268
+      onChange: (selectedRowKeys, selectedRows) => {
269
+        console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
270
+        setPersonInfo(selectedRows)
271
+      },
272
+    };
273
+
243 274
   const publicColumns = [
244 275
     {
245 276
       title: '头像',
@@ -290,16 +321,19 @@ function body(props) {
290 321
       // eslint-disable-next-line no-nested-ternary
291 322
       render: (_, record) => (
292 323
         <>
293
-          <AuthButton name="admin.customer.public.detail" noRight={null}>
324
+          {/* <AuthButton name="admin.customer.public.detail" noRight={null}>
294 325
             <Button className={customerType === 'private' ? Styles.displayS : Styles.text } type="link" onClick={() => publicCustomerDetail(record)}>查看详情</Button>
295 326
           </AuthButton>
296
-          &nbsp;&nbsp;
327
+          &nbsp;&nbsp; */}
297 328
           <AuthButton name="admin.customer.recommend" noRight={null}>
298 329
             <Button className={customerType === 'private' ? Styles.displayS : Styles.text } type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
299 330
           </AuthButton>
300 331
           <AuthButton name="admin.customer.assign" noRight={null}>
301 332
             <Button className={customerType === 'private' ? Styles.displayS : Styles.text } type="link" onClick={() => assistConsultant(record.personId)}>分配置业顾问</Button>
302 333
           </AuthButton>
334
+          <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
335
+            <Button className={Styles.text} type="link" onClick={() => showRecord(record)}>积分记录</Button>
336
+          </AuthButton>
303 337
         </>
304 338
       ),
305 339
     },
@@ -393,10 +427,10 @@ function body(props) {
393 427
             <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showGM(record)}>调整归属</Button>
394 428
           </AuthButton>
395 429
             &nbsp;&nbsp;
396
-          <AuthButton name="admin.customer.recommend.get" noRight={null}>
430
+          {/* <AuthButton name="admin.customer.recommend.get" noRight={null}>
397 431
             <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => toCustomerDateil(record)}>查看详情</Button>
398 432
           </AuthButton>
399
-            &nbsp;&nbsp;
433
+            &nbsp;&nbsp; */}
400 434
           <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
401 435
             <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecord(record)}>积分记录</Button>
402 436
           </AuthButton>
@@ -480,11 +514,27 @@ function body(props) {
480 514
             </Button>
481 515
         </Form.Item>
482 516
       </Form>
483
-      <AuthButton name="admin.customer.import" noRight={null}>
484
-        <Button type="primary" loading={loadingStatus} onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
485
-          导出
486
-        </Button>
487
-      </AuthButton>
517
+      {
518
+        customerType === 'private' ? 
519
+        <AuthButton name="admin.customer.import" noRight={null}>
520
+          <Button type="primary" loading={loadingStatus} onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
521
+            导出
522
+          </Button>
523
+        </AuthButton> :
524
+        <>
525
+        <AuthButton name="admin.customer.import" noRight={null}>
526
+          <Button type="primary" onClick={() => batchAssistConsultant()} style={{ float: 'right', margin: '20px 0', marginLeft:'20px', zIndex: 1 }}>
527
+            批量分配置业顾问
528
+          </Button>
529
+        </AuthButton>
530
+        <AuthButton name="admin.customer.import" noRight={null}>
531
+          <Button type="primary" loading={loadingStatus} onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
532
+            导出
533
+          </Button>
534
+        </AuthButton>
535
+        </>
536
+      }
537
+      
488 538
 
489 539
       <div style={{ margin: '20px 0'}}>
490 540
           <Radio.Group value={customerType} onChange={radioButtonHandleSizeChange} buttonStyle="solid">
@@ -500,7 +550,7 @@ function body(props) {
500 550
         //   };
501 551
         // }}
502 552
         dataSource={dataSource.records} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
503
-        <Table 
553
+        <Table rowSelection={rowSelection}
504 554
         // onRow={record => {
505 555
         //   return {
506 556
         //     onClick: () => publicCustomerDetail(record),
@@ -523,6 +573,9 @@ function body(props) {
523 573
 
524 574
       {/* 分配置业顾问 */}
525 575
       <AssistConsultant visibleData={assistVisibleData} onCancel={() => closeAll()}/>
576
+
577
+      {/* 批量分配置业顾问 */}
578
+      <BatchAssistConsultant visibleData={batchAssistVisibleData} onCancel={() => closeAll()}/>
526 579
     </>
527 580
   );
528 581
 }

+ 5
- 0
src/services/apis.js 查看文件

@@ -263,6 +263,11 @@ export default {
263 263
       url: `${prefix}/customer/consultant/assist/:id`,
264 264
       action: 'admin.customer.consultant.assist.id.put',
265 265
     },
266
+    batchConsultantAssist: {
267
+      method: 'POST',
268
+      url: `${prefix}/customer/consultant/batchAssist`,
269
+      action: 'admin.customer.consultant.assist.id.put',
270
+    },
266 271
     taPointsRecords: {
267 272
       method: 'GET',
268 273
       url: `${prefix}/mine/taPointsRecords/:id`,