File size: 1,957 Bytes
af3ef26 6b8fc2c af3ef26 6b8fc2c af3ef26 6b8fc2c af3ef26 6b8fc2c af3ef26 6b8fc2c af3ef26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
import { rsaPsw } from '@/utils';
import { Form, Input, Modal } from 'antd';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'umi';
type FieldType = {
newPassword?: string;
password?: string;
};
const CpwModal = () => {
const dispatch = useDispatch();
const settingModel = useSelector((state: any) => state.settingModel);
const { isShowPSwModal } = settingModel;
const { t } = useTranslation();
const [form] = Form.useForm();
const handleCancel = () => {
dispatch({
type: 'settingModel/updateState',
payload: {
isShowPSwModal: false,
},
});
};
const handleOk = async () => {
try {
const values = await form.validateFields();
var password = rsaPsw(values.password);
var new_password = rsaPsw(values.newPassword);
dispatch({
type: 'settingModel/setting',
payload: {
password,
new_password,
},
});
} catch (errorInfo) {
console.log('Failed:', errorInfo);
}
};
return (
<Modal
title="Basic Modal"
open={isShowPSwModal}
onOk={handleOk}
onCancel={handleCancel}
>
<Form
form={form}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
style={{ maxWidth: 600 }}
autoComplete="off"
>
<Form.Item<FieldType>
label="旧密码"
name="password"
rules={[{ required: true, message: 'Please input value' }]}
>
<Input.Password />
</Form.Item>
<Form.Item<FieldType>
label="新密码"
name="newPassword"
rules={[
{ required: true, message: 'Please input your newPassword!' },
]}
>
<Input.Password />
</Form.Item>
</Form>
</Modal>
);
};
export default CpwModal;
|