| | |
| | | import Http from '@/utils/http'; |
| | | |
| | | const resetPwd = async (val) => { |
| | | const hide = message.loading('正在更新'); |
| | | const hide = message.loading('正在修改'); |
| | | try { |
| | | const resp = await Http.doPost('api/user/update', val); |
| | | const resp = await Http.doPost('api/user/reset/pwd', val); |
| | | if (resp.code === 200) { |
| | | message.success('更新成功'); |
| | | message.success('修改成功'); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('配置失败请重试!'); |
| | | message.error('修改失败请重试!'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | |
| | | const { currentUser } = initialState || {}; |
| | | |
| | | const handleFinish = (values) => { |
| | | resetPwd({...values, userId: currentUser.id}); |
| | | resetPwd({...values, id: currentUser.id}); |
| | | } |
| | | |
| | | return ( |
| | |
| | | > |
| | | <ProFormText.Password |
| | | width="md" |
| | | name="currentPwd" |
| | | name="oldPwd" |
| | | label="当前密码" |
| | | rules={[ |
| | | { |
| | |
| | | /> |
| | | <ProFormText.Password |
| | | width="md" |
| | | name="newPwd" |
| | | name="password" |
| | | label="新密码" |
| | | rules={[ |
| | | { |
| | |
| | | /> |
| | | <ProFormText.Password |
| | | width="md" |
| | | name="newPwdRepeat" |
| | | name="passwordRepeat" |
| | | label="确认密码" |
| | | rules={[ |
| | | { |
| | |
| | | }, |
| | | { |
| | | validator(_, value) { |
| | | if (form.getFieldValue('newPwd') === value) return Promise.resolve(); |
| | | if (form.getFieldValue('password') === value) return Promise.resolve(); |
| | | return Promise.reject(new Error('两次输入的密码不相符!')); |
| | | } |
| | | } |