魏超 5 years ago
parent
commit
99d12ae728

+ 14
- 1
src/components/GlobalHeader/AvatarDropdown.jsx View File

18
     const { key } = event;
18
     const { key } = event;
19
 
19
 
20
     if (key === 'logout') {
20
     if (key === 'logout') {
21
+      console.log(this.props)
21
       const { dispatch } = this.props;
22
       const { dispatch } = this.props;
22
 
23
 
23
       if (dispatch) {
24
       if (dispatch) {
40
   onCancel = (e) => {
41
   onCancel = (e) => {
41
     this.setState({ visible: false })
42
     this.setState({ visible: false })
42
   }
43
   }
44
+
45
+  onReset = (e) => {
46
+    const { dispatch } = this.props;
47
+
48
+      if (dispatch) {
49
+        dispatch({
50
+          type: 'login/logout',
51
+        });
52
+      }
53
+
54
+      return;
55
+  }
43
   
56
   
44
   render() {
57
   render() {
45
     const {
58
     const {
82
             <span className={styles.name}>{currentUser.userName}</span>
95
             <span className={styles.name}>{currentUser.userName}</span>
83
           </span>
96
           </span>
84
         </HeaderDropdown>
97
         </HeaderDropdown>
85
-        <ShowPassword visible={this.state.visible} onCancel={(e) => this.onCancel(e)} />
98
+        <ShowPassword visible={this.state.visible} onCancel={(e) => this.onCancel(e)} onReset={(e => this.onReset(e))} />
86
       </>  
99
       </>  
87
     ) : (
100
     ) : (
88
       <Spin
101
       <Spin

+ 4
- 9
src/components/GlobalHeader/ShowPassword.jsx View File

26
       if (!err) {
26
       if (!err) {
27
         request({ ...apis.user.changePassword, params: { ...values } }).then(() => {
27
         request({ ...apis.user.changePassword, params: { ...values } }).then(() => {
28
           openNotificationWithIcon('success', '操作成功!')
28
           openNotificationWithIcon('success', '操作成功!')
29
-          window.localStorage.removeItem('test-foobar-center')      
30
-          router.push({
31
-            pathname: '/user/login',
32
-          });
33
-          props.form.resetFields()
34
           props.onSuccess()
29
           props.onSuccess()
35
         }).catch(error => {
30
         }).catch(error => {
36
           // openNotificationWithIcon('error', error.message)
31
           // openNotificationWithIcon('error', error.message)
41
 
36
 
42
   // 弹框取消按钮
37
   // 弹框取消按钮
43
   function handlePopCancel(e) {
38
   function handlePopCancel(e) {
44
-    props.onSuccess()
39
+    props.onCancel()
45
   }
40
   }
46
 
41
 
47
   const { getFieldDecorator } = props.form
42
   const { getFieldDecorator } = props.form
111
   }
106
   }
112
 
107
 
113
   handleOk = e => {
108
   handleOk = e => {
114
-    console.log('关闭了')
115
-    this.props.onCancel()
109
+    console.log('修改密码成功')
110
+    this.props.onReset()
116
   };
111
   };
117
 
112
 
118
   handleCancel = e => {
113
   handleCancel = e => {
128
           visible={this.state.visible}
123
           visible={this.state.visible}
129
           onCancel={this.handleCancel}
124
           onCancel={this.handleCancel}
130
           footer={null}>
125
           footer={null}>
131
-          <WrappedShowPasswordForm onSuccess={(e) => this.handleCancel(e)} />
126
+          <WrappedShowPasswordForm onSuccess={(e) => this.handleOk(e)} onCancel={(e) => this.handleCancel(e)}/>
132
         </Modal>
127
         </Modal>
133
       </>
128
       </>
134
     );
129
     );

+ 4
- 2
src/pages/UserManage/Editor/User.jsx View File

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Button, notification, Tree, message } from 'antd';
2
+import { Button, notification, Tree, message, Spin } from 'antd';
3
 import md5 from 'md5';
3
 import md5 from 'md5';
4
 import moment from 'moment';
4
 import moment from 'moment';
5
 import router from 'umi/router';
5
 import router from 'umi/router';
177
       message.error('维护项目数量必须大于0')
177
       message.error('维护项目数量必须大于0')
178
       return
178
       return
179
     }
179
     }
180
+    
180
     setSubmitting(true)
181
     setSubmitting(true)
181
     if (user && user.userId) {
182
     if (user && user.userId) {
182
       updateUser({ urlData: { id: user.userId }, data }).then((user) => {
183
       updateUser({ urlData: { id: user.userId }, data }).then((user) => {
203
     }
204
     }
204
   }
205
   }
205
 
206
 
206
-  return (<XForm onSubmit={handleSubmit} onCancel={handleCancel} fields={fields} submitting={submitting}></XForm>)
207
+  return (
208
+  <><Spin spinning={ submitting } size="large"><XForm onSubmit={handleSubmit} onCancel={handleCancel} fields={fields} submitting={submitting}></XForm></Spin></>)
207
 }
209
 }

+ 1
- 1
src/utils/request.js View File

92
           throw new Error('请登录系统');
92
           throw new Error('请登录系统');
93
         } else {
93
         } else {
94
           notification.error({
94
           notification.error({
95
-            message: `请登录系统`,
95
+            message: message,
96
             // description: message,
96
             // description: message,
97
           });
97
           });
98
           throw new Error(message);
98
           throw new Error(message);