|
@@ -0,0 +1,156 @@
|
|
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
|
+
|
|
8
|
+
|
|
9
|
+const { Option } = Select;
|
|
10
|
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+const { Meta } = Card;
|
|
12
|
+
|
|
13
|
+const { TextArea } = Input;
|
|
14
|
+
|
|
15
|
+/**
|
|
16
|
+ * 图片信息
|
|
17
|
+ *
|
|
18
|
+ * @param {*} props
|
|
19
|
+ * @returns
|
|
20
|
+ */
|
|
21
|
+class PasswordText extends React.Component {
|
|
22
|
+ constructor(props) {
|
|
23
|
+ super(props);
|
|
24
|
+ this.state = {
|
|
25
|
+ visibleData: [{ visible: false, userId: '', oldPassword:'', newPassword: '', confirmPassword: '' }],
|
|
26
|
+ }
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ // 挂载之后
|
|
30
|
+ // componentDidMount() {
|
|
31
|
+ //
|
|
32
|
+ // }
|
|
33
|
+
|
|
34
|
+ componentDidUpdate(preProps, preState) {
|
|
35
|
+ if (this.props.visibleData.visible !== preState.visibleData.visible) {
|
|
36
|
+ console.log(this.props.visibleData)
|
|
37
|
+ this.setState({ visibleData: this.props.visibleData });
|
|
38
|
+ }
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ // 弹框确定按钮
|
|
42
|
+ // eslint-disable-next-line react/sort-comp
|
|
43
|
+ handleOk() {
|
|
44
|
+ this.setState({ visibleData: { visible: false, userId: '', oldPassword:'', newPassword: '', confirmPassword: '' } })
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ // 弹框取消按钮
|
|
48
|
+ handleCancel() {
|
|
49
|
+ this.setState({ visibleData: { visible: false, userId: '', oldPassword:'', newPassword: '', confirmPassword: '' } })
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ openNotificationWithIcon = (type, message) => {
|
|
53
|
+ notification[type]({
|
|
54
|
+ message,
|
|
55
|
+ description:
|
|
56
|
+ '',
|
|
57
|
+ });
|
|
58
|
+ };
|
|
59
|
+
|
|
60
|
+ // 提交
|
|
61
|
+ handleSubmit(e) {
|
|
62
|
+ e.preventDefault();
|
|
63
|
+ this.props.form.validateFields((err, values) => {
|
|
64
|
+ if (!err) {
|
|
65
|
+ this.submitData(values)
|
|
66
|
+ }
|
|
67
|
+ });
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ submitData(data) {
|
|
71
|
+ data.userId = this.props.visibleData.userId;
|
|
72
|
+ data.newPassword = data.newPassword
|
|
73
|
+ data.confirmPassword = data.confirmPassword
|
|
74
|
+ const api = apis.user.changePassword;
|
|
75
|
+
|
|
76
|
+ // 网路请求
|
|
77
|
+ request({ ...api, data: { ...data } }).then(() => {
|
|
78
|
+ console.log({...data});
|
|
79
|
+ // eslint-disable-next-line no-unused-expressions
|
|
80
|
+ // this.openNotificationWithIcon('success', '操作成功')
|
|
81
|
+ notification.success({message: '设置成功'})
|
|
82
|
+ // 传递父组件事件
|
|
83
|
+ // onSuccess() 是自定义
|
|
84
|
+ // this.props.onSuccess()
|
|
85
|
+
|
|
86
|
+ // this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } }, () => console.log('回调:', this.state.visibleData))
|
|
87
|
+ }).catch(err => {
|
|
88
|
+ console.log('123213123')
|
|
89
|
+ // eslint-disable-next-line no-unused-expressions
|
|
90
|
+ // notification.success({message: ''})
|
|
91
|
+ // this.openNotificationWithIcon('error', err)
|
|
92
|
+ })
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ /**
|
|
96
|
+ * 取消按钮
|
|
97
|
+ *
|
|
98
|
+ * @memberof ModalImage
|
|
99
|
+ */
|
|
100
|
+ closeModal() {
|
|
101
|
+ this.setState({ visible: false, userId: '', oldPassword:'', newPassword: '', confirmPassword: '' })
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ render() {
|
|
105
|
+ const { getFieldDecorator } = this.props.form;
|
|
106
|
+ return (
|
|
107
|
+ <>
|
|
108
|
+ <Modal
|
|
109
|
+ title="修改密码"
|
|
110
|
+ width={400}
|
|
111
|
+ destroyOnClose="true"
|
|
112
|
+ footer={null}
|
|
113
|
+ visible={this.state.visibleData.visible}
|
|
114
|
+ onOk={() => this.handleOk()}
|
|
115
|
+ onCancel={e => this.handleCancel(e)}
|
|
116
|
+ >
|
|
117
|
+ <Form onSubmit={e => this.handleSubmit(e)}>
|
|
118
|
+ <Form.Item label="登录人" style={{ display: 'none' }}>
|
|
119
|
+ {getFieldDecorator('userId')(<Input />)}
|
|
120
|
+ </Form.Item>
|
|
121
|
+ <Form.Item label="旧密码">
|
|
122
|
+ {getFieldDecorator('loginPassword', {
|
|
123
|
+ rules: [
|
|
124
|
+ { required: true, message: '请填写旧密码' },
|
|
125
|
+ ],
|
|
126
|
+ })(<Input />)}
|
|
127
|
+ </Form.Item>
|
|
128
|
+ <Form.Item label="新密码">
|
|
129
|
+ {getFieldDecorator('newPassword', {
|
|
130
|
+ rules: [
|
|
131
|
+ { required: true, message: '请填写新密码' }
|
|
132
|
+ ],
|
|
133
|
+ })(<Input />)}
|
|
134
|
+ </Form.Item>
|
|
135
|
+ <Form.Item label="确认密码">
|
|
136
|
+ {getFieldDecorator('confirmPassword', {
|
|
137
|
+ rules: [
|
|
138
|
+ { required: true, message: '请确认密码' }
|
|
139
|
+ ],
|
|
140
|
+ })(<Input />)}
|
|
141
|
+ </Form.Item>
|
|
142
|
+ <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
|
|
143
|
+ <Button type="primary" htmlType="submit">保存</Button>
|
|
144
|
+
|
|
145
|
+ <Button onClick={e => this.handleCancel(e)}>取消</Button>
|
|
146
|
+ </Form.Item>
|
|
147
|
+ </Form>
|
|
148
|
+ </Modal>
|
|
149
|
+ </>
|
|
150
|
+ );
|
|
151
|
+ }
|
|
152
|
+}
|
|
153
|
+
|
|
154
|
+const WrappedModalImageForm = Form.create({ name: 'passwordText' })(PasswordText);
|
|
155
|
+
|
|
156
|
+export default WrappedModalImageForm
|