Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@ant-design/compatible": "^1.0.2",
"@ant-design/icons": "^4.0.6",
"antd": "^4.1.2",
"axios": "^0.18.0",
"axios": "^0.21.1",
"classnames": "^2.2.5",
"history": "^4.7.2",
"lodash": "^4.17.10",
Expand Down
104 changes: 48 additions & 56 deletions 104 src/components/UpdatePasswordDialog/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import React, { PureComponent } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Input, Modal, message } from 'antd';
import { Form, Input, Modal, message } from 'antd';
import { updatePwd } from '@/services/login';
import { md5Hash } from '../../utils/utils';

@Form.create()
class UpdatePasswordDialog extends PureComponent {
formRef = React.createRef();

state = {
submitting: false,
};

onOKClick = () => {
const { form } = this.props;

form.validateFieldsAndScroll((err, values) => {
if (err) {
return;
}
if (values.new_password !== values.confirm_new_password) {
message.warning('新密码与确认新密码不一致!');
return;
}

this.setState({ submitting: true });
const formData = {
old_password: md5Hash(values.old_password),
new_password: md5Hash(values.new_password),
};
updatePwd(formData).then(res => {
if (res.status === 'OK') {
message.success('密码更新成功!');
this.handleCancel();
this.formRef.current
.validateFields()
.then(values => {
if (values.new_password !== values.confirm_new_password) {
message.warning('新密码与确认新密码不一致!');
return;
}

this.setState({ submitting: true });
const formData = {
old_password: md5Hash(values.old_password),
new_password: md5Hash(values.new_password),
};
updatePwd(formData).then(res => {
if (res.status === 'OK') {
message.success('密码更新成功!');
this.handleCancel();
}
this.setState({ submitting: false });
});
})
.catch(err => {
console.log(' ----- === err :', err);
this.setState({ submitting: false });
});
});
};

handleCancel = () => {
Expand All @@ -51,10 +52,7 @@ class UpdatePasswordDialog extends PureComponent {
};

render() {
const {
visible,
form: { getFieldDecorator },
} = this.props;
const { visible } = this.props;

const { submitting } = this.state;

Expand All @@ -80,36 +78,30 @@ class UpdatePasswordDialog extends PureComponent {
style={{ top: 20 }}
bodyStyle={{ maxHeight: 'calc( 100vh - 158px )', overflowY: 'auto' }}
>
<Form>
<Form.Item {...formItemLayout} label="旧密码">
{getFieldDecorator('old_password', {
rules: [
{
required: true,
message: '请输入旧密码',
},
],
})(<Input type="password" placeholder="请输入旧密码" />)}
<Form ref={this.formRef} initialValues={{}}>
<Form.Item
{...formItemLayout}
label="旧密码"
name="old_password"
rules={[{ required: true, message: '请输入旧密码' }]}
>
<Input type="password" placeholder="请输入旧密码" />
</Form.Item>
<Form.Item {...formItemLayout} label="新密码">
{getFieldDecorator('new_password', {
rules: [
{
required: true,
message: '请输入新密码',
},
],
})(<Input type="password" placeholder="请输入新密码" />)}
<Form.Item
{...formItemLayout}
label="新密码"
name="new_password"
rules={[{ required: true, message: '请输入新密码' }]}
>
<Input type="password" placeholder="请输入新密码" />
</Form.Item>
<Form.Item {...formItemLayout} label="确认新密码">
{getFieldDecorator('confirm_new_password', {
rules: [
{
required: true,
message: '请输入确认新密码',
},
],
})(<Input type="password" placeholder="请输入确认新密码" />)}
<Form.Item
{...formItemLayout}
label="确认新密码"
name="confirm_new_password"
rules={[{ required: true, message: '请输入确认新密码' }]}
>
<Input type="password" placeholder="请输入确认新密码" />
</Form.Item>
</Form>
</Modal>
Expand Down
25 changes: 23 additions & 2 deletions 25 src/models/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
submitting: false,
formTitle: '',
formID: '',
formModalVisible: false,
formVisible: false,
formData: {},
},
Expand Down Expand Up @@ -54,7 +55,7 @@ export default {
},
*loadForm({ payload }, { put }) {
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: true,
});

Expand Down Expand Up @@ -92,6 +93,13 @@ export default {
payload: { id: payload.id },
}),
];
} else {
yield [
put({
type: 'changeFormVisible',
payload: true,
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
Expand All @@ -101,6 +109,10 @@ export default {
type: 'saveFormData',
payload: response,
}),
put({
type: 'changeFormVisible',
payload: true,
}),
];
},
*submit({ payload }, { call, put, select }) {
Expand Down Expand Up @@ -133,7 +145,7 @@ export default {
if (success) {
message.success('保存成功');
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: false,
});
yield put({
Expand Down Expand Up @@ -191,8 +203,17 @@ export default {
return { ...state, pagination: payload };
},
changeFormVisible(state, { payload }) {
if (payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formVisible: payload };
},
changeModalFormVisible(state, { payload }) {
if (!payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formModalVisible: payload };
},
saveFormTitle(state, { payload }) {
return { ...state, formTitle: payload };
},
Expand Down
34 changes: 28 additions & 6 deletions 34 src/models/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
formType: '',
formTitle: '',
formID: '',
formModalVisible: false,
formVisible: false,
formData: {},
treeData: [],
Expand Down Expand Up @@ -59,7 +60,7 @@ export default {
},
*loadForm({ payload }, { put, select }) {
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: true,
});

Expand Down Expand Up @@ -104,14 +105,26 @@ export default {
type: 'saveFormData',
payload: { parent_id: search.parentID ? search.parentID : '' },
});
yield [
put({
type: 'changeFormVisible',
payload: true,
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
const response = yield call(menuService.get, payload.id);
yield put({
type: 'saveFormData',
payload: response,
});
yield [
put({
type: 'saveFormData',
payload: response,
}),
put({
type: 'changeFormVisible',
payload: true,
}),
];
},
*submit({ payload }, { call, put, select }) {
yield put({
Expand Down Expand Up @@ -143,7 +156,7 @@ export default {
if (success) {
message.success('保存成功');
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: false,
});

Expand Down Expand Up @@ -213,8 +226,17 @@ export default {
return { ...state, pagination: payload };
},
changeFormVisible(state, { payload }) {
if (payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formVisible: payload };
},
changeModalFormVisible(state, { payload }) {
if (!payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formModalVisible: payload };
},
saveFormType(state, { payload }) {
return { ...state, formType: payload };
},
Expand Down
25 changes: 23 additions & 2 deletions 25 src/models/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
submitting: false,
formTitle: '',
formID: '',
formModalVisible: false,
formVisible: false,
formData: {},
selectData: [],
Expand Down Expand Up @@ -55,7 +56,7 @@ export default {
},
*loadForm({ payload }, { put }) {
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: true,
});

Expand Down Expand Up @@ -93,6 +94,13 @@ export default {
payload: { id: payload.id },
}),
];
} else {
yield [
put({
type: 'changeFormVisible',
payload: true,
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
Expand Down Expand Up @@ -120,6 +128,10 @@ export default {
type: 'saveFormData',
payload: response,
}),
put({
type: 'changeFormVisible',
payload: true,
}),
];
},
*submit({ payload }, { call, put, select }) {
Expand Down Expand Up @@ -153,7 +165,7 @@ export default {
if (success) {
message.success('保存成功');
yield put({
type: 'changeFormVisible',
type: 'changeModalFormVisible',
payload: false,
});
yield put({
Expand Down Expand Up @@ -218,8 +230,17 @@ export default {
return { ...state, pagination: payload };
},
changeFormVisible(state, { payload }) {
if (payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formVisible: payload };
},
changeModalFormVisible(state, { payload }) {
if (!payload) {
return { ...state, formModalVisible: payload, formVisible: payload };
}
return { ...state, formModalVisible: payload };
},
saveFormTitle(state, { payload }) {
return { ...state, formTitle: payload };
},
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.