Browse Source

新需求

傅行帆 5 years ago
parent
commit
dd811dbf91

+ 4
- 21
src/pages/staff/components/BatchAssistConsultant.jsx View File

31
   }
31
   }
32
 
32
 
33
   componentDidUpdate(preProps, preState) {
33
   componentDidUpdate(preProps, preState) {
34
-    console.log(this.props.preState,"111111111111111")
35
     if (this.props.visible !== preState.visibleData.visible) {
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
       this.setState({ visibleData: { visible: this.props.visible, buildingId: this.props.buildingId } });
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
   handleCancel() {
41
   handleCancel() {
49
     this.props.onCancel()
42
     this.props.onCancel()
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
   openNotificationWithIcon = (type, message) => {
58
   openNotificationWithIcon = (type, message) => {
76
     notification[type]({
59
     notification[type]({
77
       message,
60
       message,
88
 
71
 
89
   // 提交
72
   // 提交
90
   submitGm(record) {
73
   submitGm(record) {
91
-    console.log(record,"111111")
74
+    this.props.onCancel(record)
92
   }
75
   }
93
 
76
 
94
   render() {
77
   render() {
118
         dataIndex: 'personId',
101
         dataIndex: 'personId',
119
         key: 'personId',
102
         key: 'personId',
120
         // eslint-disable-next-line no-nested-ternary
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
     return (
106
     return (
124
       <>
107
       <>
130
             visible={this.state.visibleData.visible}
113
             visible={this.state.visibleData.visible}
131
             onCancel={(e) => this.handleCancel(e)}
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
           </Modal>
117
           </Modal>
135
       </>
118
       </>
136
     );
119
     );

+ 52
- 4
src/pages/staff/components/CustomerChange.jsx View File

11
 const CustomerChange = (props) => {
11
 const CustomerChange = (props) => {
12
   const [data, setData] = useState([])
12
   const [data, setData] = useState([])
13
   const [consultantVisible, setConsultantVisible] = useState(false)
13
   const [consultantVisible, setConsultantVisible] = useState(false)
14
+  const [selectIds, setSelectIds] = useState([])
14
 
15
 
15
   const rowSelection = {
16
   const rowSelection = {
17
+    selectedRowKeys: selectIds,
16
     onChange: (selectedRowKeys, selectedRows) => {
18
     onChange: (selectedRowKeys, selectedRows) => {
17
       console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
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
   const columns = [
67
   const columns = [
22
     {
68
     {
23
       title: '用户名',
69
       title: '用户名',
39
     },
85
     },
40
     {
86
     {
41
       title: '调整后归属',
87
       title: '调整后归属',
42
-      dataIndex: 'buildingId',
43
-      key: 'buildingId',
88
+      dataIndex: 'moveUserName',
89
+      key: 'moveUserName',
44
       align: 'center',
90
       align: 'center',
45
     }
91
     }
46
   ];
92
   ];
53
 
99
 
54
   return (
100
   return (
55
     <div>
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
         <Table rowSelection={rowSelection} dataSource={data} columns={columns} rowKey="customerId" pagination={false} scroll={{ y: 500 }}/>
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
     </div>
107
     </div>
60
   )
108
   )
61
 }
109
 }

+ 23
- 5
src/pages/staff/list/StaffList.jsx View File

40
     // console.log(data, "11111")
40
     // console.log(data, "11111")
41
     if (data.status === 1) {
41
     if (data.status === 1) {
42
       if(data.isConsultant){
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
             Modal.confirm({
45
             Modal.confirm({
46
               title: '此置业顾问下有私客,是否转移私客?',
46
               title: '此置业顾问下有私客,是否转移私客?',
47
               okText: '确认',
47
               okText: '确认',
50
                 setVisible(true)
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
       }else{
68
       }else{
59
           okText: '确认',
72
           okText: '确认',
60
           cancelText: '取消',
73
           cancelText: '取消',
61
           onOk () {
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
               message.info('操作成功')
76
               message.info('操作成功')
64
               props.onFresh()
77
               props.onFresh()
65
             })
78
             })
72
         okText: '确认',
85
         okText: '确认',
73
         cancelText: '取消',
86
         cancelText: '取消',
74
         onOk () {
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
             message.info('操作成功')
89
             message.info('操作成功')
77
             props.onFresh()
90
             props.onFresh()
78
           })
91
           })
81
     }
94
     }
82
   }
95
   }
83
 
96
 
97
+  //迁移私客成功回调
98
+  const moveSuccess = (e) => {
99
+    setVisible(false)
100
+  }
101
+
84
   // 员工离职
102
   // 员工离职
85
   const departure = row => {
103
   const departure = row => {
86
     // 是置业顾问
104
     // 是置业顾问
159
         footer={null}
177
         footer={null}
160
         width={900}
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
       </Modal>
181
       </Modal>
164
     </div>
182
     </div>
165
   )
183
   )

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

836
       method: 'GET',
836
       method: 'GET',
837
       action: 'admin.consultant.customer.list.put',
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
     departure: {
844
     departure: {
840
       url: `${prefix}/user/departure/:id`,
845
       url: `${prefix}/user/departure/:id`,
841
       method: 'PUT',
846
       method: 'PUT',