浏览代码

新需求

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

+ 4
- 21
src/pages/staff/components/BatchAssistConsultant.jsx 查看文件

@@ -31,19 +31,12 @@ class ModalAttribution extends React.Component {
31 31
   }
32 32
 
33 33
   componentDidUpdate(preProps, preState) {
34
-    console.log(this.props.preState,"111111111111111")
35 34
     if (this.props.visible !== preState.visibleData.visible) {
36
-      this.getList({ pageNumber: 1, pageSize: 5, buildingId: this.props.buildingId })
35
+      this.getUserList({ pageNumber: 1, pageSize: 5, buildingId: this.props.buildingId })
37 36
       this.setState({ visibleData: { visible: this.props.visible, buildingId: this.props.buildingId } });
38 37
     }
39 38
   }
40 39
 
41
-  // 弹框确定按钮
42
-  // eslint-disable-next-line react/sort-comp
43
-  handleOk() {
44
-    this.props.onCancel()
45
-  }
46
-
47 40
   // 弹框取消按钮
48 41
   handleCancel() {
49 42
     this.props.onCancel()
@@ -62,16 +55,6 @@ class ModalAttribution extends React.Component {
62 55
     })
63 56
   }
64 57
 
65
-  getList(params) {
66
-    // 网路请求
67
-    console.log('params: ', params)
68
-    request({ ...apis.customer.buildingConsultant }).then(res => {
69
-      this.setState({ dataSource: res })
70
-    }).catch(err => {
71
-      
72
-    })
73
-  }
74
-
75 58
   openNotificationWithIcon = (type, message) => {
76 59
     notification[type]({
77 60
       message,
@@ -88,7 +71,7 @@ class ModalAttribution extends React.Component {
88 71
 
89 72
   // 提交
90 73
   submitGm(record) {
91
-    console.log(record,"111111")
74
+    this.props.onCancel(record)
92 75
   }
93 76
 
94 77
   render() {
@@ -118,7 +101,7 @@ class ModalAttribution extends React.Component {
118 101
         dataIndex: 'personId',
119 102
         key: 'personId',
120 103
         // eslint-disable-next-line no-nested-ternary
121
-        render: (_, record) => <>{ <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>, },
104
+        render: (_, record) => <>{record.userId !== this.props.userId ? <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button> : ''}</>, },
122 105
     ]
123 106
     return (
124 107
       <>
@@ -130,7 +113,7 @@ class ModalAttribution extends React.Component {
130 113
             visible={this.state.visibleData.visible}
131 114
             onCancel={(e) => this.handleCancel(e)}
132 115
           >
133
-            <Table rowKey="BatchAssistConsultant" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
116
+            <Table rowKey="userId" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
134 117
           </Modal>
135 118
       </>
136 119
     );

+ 52
- 4
src/pages/staff/components/CustomerChange.jsx 查看文件

@@ -11,13 +11,59 @@ import BatchAssistConsultant from './BatchAssistConsultant'
11 11
 const CustomerChange = (props) => {
12 12
   const [data, setData] = useState([])
13 13
   const [consultantVisible, setConsultantVisible] = useState(false)
14
+  const [selectIds, setSelectIds] = useState([])
14 15
 
15 16
   const rowSelection = {
17
+    selectedRowKeys: selectIds,
16 18
     onChange: (selectedRowKeys, selectedRows) => {
17 19
       console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
20
+      setSelectIds(selectedRowKeys)
18 21
     },
19 22
   };
20 23
 
24
+  const batchAssistConsultant = () => {
25
+    if(selectIds.length < 1){
26
+      message.info("请至少选择一条数据");
27
+      return
28
+    }
29
+    setConsultantVisible(true)
30
+  }
31
+
32
+  const consulatanChange = (e) => {
33
+    if(e){
34
+      data.map(x =>{ 
35
+        selectIds.map(y => {
36
+          if(x.customerId === y){
37
+            x.realtyConsultant = e.userId
38
+            x.moveUserId = e.userId
39
+            x.moveUserName = e.userName
40
+          }
41
+        })
42
+      })
43
+    }
44
+    setConsultantVisible(false)
45
+    setSelectIds([])
46
+  }
47
+
48
+  //批量保存
49
+  const batchSaveConsultant = () =>{
50
+    const unMoveData = data.filter(x => !x.moveUserId)
51
+    if(unMoveData.length > 0){
52
+      message.info("存在未分配归属客户");
53
+      return
54
+    }
55
+    request({ ...apis.staff.move, data }).then(data => {
56
+      message.info('操作成功')
57
+      props.onSuccess('success')
58
+    })
59
+  }
60
+
61
+  //取消按钮
62
+  const cancelConsultant = () => {
63
+    props.onSuccess('cancel')
64
+  }
65
+
66
+
21 67
   const columns = [
22 68
     {
23 69
       title: '用户名',
@@ -39,8 +85,8 @@ const CustomerChange = (props) => {
39 85
     },
40 86
     {
41 87
       title: '调整后归属',
42
-      dataIndex: 'buildingId',
43
-      key: 'buildingId',
88
+      dataIndex: 'moveUserName',
89
+      key: 'moveUserName',
44 90
       align: 'center',
45 91
     }
46 92
   ];
@@ -53,9 +99,11 @@ const CustomerChange = (props) => {
53 99
 
54 100
   return (
55 101
     <div>
56
-        <Button type="primary" onClick={() => setConsultantVisible(true)} style={{ float: 'right', margin: '20px 0', marginLeft: '20px', zIndex: 1 }}>分配置业顾问</Button>
102
+        <Button type="primary" onClick={() => batchAssistConsultant()} style={{ float: 'right', margin: '20px 0', marginLeft: '20px', zIndex: 1 }}>分配置业顾问</Button>
57 103
         <Table rowSelection={rowSelection} dataSource={data} columns={columns} rowKey="customerId" pagination={false} scroll={{ y: 500 }}/>
58
-        <BatchAssistConsultant visible={consultantVisible} buildingId={props.buildingId} />
104
+        <BatchAssistConsultant visible={consultantVisible} userId={props.userId} buildingId={props.buildingId} onCancel={consulatanChange} />
105
+        <Button type="primary" onClick={() => batchSaveConsultant()} style={{}}>保存</Button>
106
+        <Button onClick={() => cancelConsultant()} style={{}}>取消</Button>
59 107
     </div>
60 108
   )
61 109
 }

+ 23
- 5
src/pages/staff/list/StaffList.jsx 查看文件

@@ -40,8 +40,8 @@ const CartBody = props => {
40 40
     // console.log(data, "11111")
41 41
     if (data.status === 1) {
42 42
       if(data.isConsultant){
43
-        request({ ...apis.staff.check, params: { userId: data.userId, personId: data.consultantPersonId, buildingId: data.buildingId } }).then(data => {
44
-          if(data){
43
+        request({ ...apis.staff.check, params: { userId: data.userId, personId: data.consultantPersonId, buildingId: data.buildingId } }).then(res => {
44
+          if(res.length > 0){
45 45
             Modal.confirm({
46 46
               title: '此置业顾问下有私客,是否转移私客?',
47 47
               okText: '确认',
@@ -50,6 +50,19 @@ const CartBody = props => {
50 50
                 setVisible(true)
51 51
               },
52 52
             });
53
+          }else{
54
+            const titleMessahe = data.isConsultant ? '停用后此员工无法继续登录后台(若为置业顾问停用后在小程序端将成为普通用户)确认进行停用操作?' : '停用后此员工无法继续登录后台,确认进行停用操作?';
55
+            Modal.confirm({
56
+              title: titleMessahe,
57
+              okText: '确认',
58
+              cancelText: '取消',
59
+              onOk () {
60
+                request({ ...apis.staff.change, urlData: { id: data.userId, type: 'off' } }).then(res => {
61
+                  message.info('操作成功')
62
+                  props.onFresh()
63
+                })
64
+              },
65
+            });
53 66
           }
54 67
        })
55 68
       }else{
@@ -59,7 +72,7 @@ const CartBody = props => {
59 72
           okText: '确认',
60 73
           cancelText: '取消',
61 74
           onOk () {
62
-            request({ ...apis.staff.change, urlData: { id: data.userId, type: 'off' } }).then(data => {
75
+            request({ ...apis.staff.change, urlData: { id: data.userId, type: 'off' } }).then(res => {
63 76
               message.info('操作成功')
64 77
               props.onFresh()
65 78
             })
@@ -72,7 +85,7 @@ const CartBody = props => {
72 85
         okText: '确认',
73 86
         cancelText: '取消',
74 87
         onOk () {
75
-          request({ ...apis.staff.change, urlData: { id: data.userId, type: 'on' } }).then(data => {
88
+          request({ ...apis.staff.change, urlData: { id: data.userId, type: 'on' } }).then(res => {
76 89
             message.info('操作成功')
77 90
             props.onFresh()
78 91
           })
@@ -81,6 +94,11 @@ const CartBody = props => {
81 94
     }
82 95
   }
83 96
 
97
+  //迁移私客成功回调
98
+  const moveSuccess = (e) => {
99
+    setVisible(false)
100
+  }
101
+
84 102
   // 员工离职
85 103
   const departure = row => {
86 104
     // 是置业顾问
@@ -159,7 +177,7 @@ const CartBody = props => {
159 177
         footer={null}
160 178
         width={900}
161 179
       >
162
-          <CustomerChange userId={data.userId} consultantPersonId={data.consultantPersonId} buildingId={data.buildingId} />
180
+          <CustomerChange userId={data.userId} consultantPersonId={data.consultantPersonId} buildingId={data.buildingId} onSuccess={moveSuccess} />
163 181
       </Modal>
164 182
     </div>
165 183
   )

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

@@ -836,6 +836,11 @@ export default {
836 836
       method: 'GET',
837 837
       action: 'admin.consultant.customer.list.put',
838 838
     },
839
+    move: {
840
+      url: `${prefix}/consultant/customer/move`,
841
+      method: 'PUT',
842
+      action: 'admin.user.departure.put',
843
+    },
839 844
     departure: {
840 845
       url: `${prefix}/user/departure/:id`,
841 846
       method: 'PUT',