|
@@ -1,5 +1,61 @@
|
1
|
|
-import React, { useMemo } from 'react';
|
2
|
|
-import { Avatar, Dropdown, Menu, Space } from 'antd';
|
|
1
|
+import React, { useState, forwardRef, useRef } from 'react';
|
|
2
|
+import { Avatar, Dropdown, Menu, Form, Input, Modal } from 'antd';
|
|
3
|
+
|
|
4
|
+const ChangePassword = forwardRef((props, ref) => {
|
|
5
|
+ const [visible, setVisible] = useState(false);
|
|
6
|
+
|
|
7
|
+ const onFinish = (values) => {
|
|
8
|
+ console.log('Success:', values);
|
|
9
|
+ };
|
|
10
|
+
|
|
11
|
+ useImperativeHandle(ref, () => {
|
|
12
|
+ return {
|
|
13
|
+ show: () => setVisible(true),
|
|
14
|
+ }
|
|
15
|
+ });
|
|
16
|
+
|
|
17
|
+ return (
|
|
18
|
+ <Modal title="修改密码" visible={visible}>
|
|
19
|
+ <Form
|
|
20
|
+ labelCol={{ span: 8 }}
|
|
21
|
+ wrapperCol={{ span: 16 }}
|
|
22
|
+ onFinish={onFinish}
|
|
23
|
+ onFinishFailed={onFinishFailed}
|
|
24
|
+ autoComplete="off"
|
|
25
|
+ >
|
|
26
|
+ <Form.Item
|
|
27
|
+ label="原始密码"
|
|
28
|
+ name="password"
|
|
29
|
+ rules={[{ required: true, message: '请输入原始密码!' }]}
|
|
30
|
+ >
|
|
31
|
+ <Input.Password />
|
|
32
|
+ </Form.Item>
|
|
33
|
+
|
|
34
|
+ <Form.Item
|
|
35
|
+ label="新密码"
|
|
36
|
+ name="newPassword"
|
|
37
|
+ rules={[{ required: true, message: '请输入新密码!' }]}
|
|
38
|
+ >
|
|
39
|
+ <Input.Password />
|
|
40
|
+ </Form.Item>
|
|
41
|
+
|
|
42
|
+ <Form.Item
|
|
43
|
+ label="确认新密码"
|
|
44
|
+ name="newPassword2"
|
|
45
|
+ rules={[{ required: true, message: '请输入新密码!' }]}
|
|
46
|
+ >
|
|
47
|
+ <Input.Password />
|
|
48
|
+ </Form.Item>
|
|
49
|
+
|
|
50
|
+ <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
|
|
51
|
+ <Button type="primary" htmlType="submit">
|
|
52
|
+ 提交
|
|
53
|
+ </Button>
|
|
54
|
+ </Form.Item>
|
|
55
|
+ </Form>
|
|
56
|
+ </Modal>
|
|
57
|
+ )
|
|
58
|
+});
|
3
|
59
|
|
4
|
60
|
export default (props) => {
|
5
|
61
|
const menuItems = [
|
|
@@ -9,7 +65,15 @@ export default (props) => {
|
9
|
65
|
}
|
10
|
66
|
];
|
11
|
67
|
|
12
|
|
- const menu = <Menu items={menuItems} />;
|
|
68
|
+ const passRef = useRef();
|
|
69
|
+
|
|
70
|
+ const onClick = ({ key }) => {
|
|
71
|
+ if (key === 'changePassword') {
|
|
72
|
+ passRef.current.show();
|
|
73
|
+ }
|
|
74
|
+ };
|
|
75
|
+
|
|
76
|
+ const menu = <Menu items={menuItems} onClick={onClick} />;
|
13
|
77
|
|
14
|
78
|
return (
|
15
|
79
|
<Dropdown overlay={menu}>
|
|
@@ -17,6 +81,7 @@ export default (props) => {
|
17
|
81
|
<Avatar src="https://joeschmoe.io/api/v1/random" />
|
18
|
82
|
<span className='font'>张延森</span>
|
19
|
83
|
</div>
|
|
84
|
+ <ChangePassword ref={passRef} />
|
20
|
85
|
</Dropdown>
|
21
|
86
|
)
|
22
|
87
|
}
|