Commit 77abf4f9 authored by littleforest's avatar littleforest

feat: add reset funciton

parent c177cecb
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
getUserMessage, getUserMessage,
postDelete, postDelete,
postDeleteUser, postDeleteUser,
postResetUser,
} from '@/services/chatGLM/api'; } from '@/services/chatGLM/api';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import type { ActionType } from '@ant-design/pro-components'; import type { ActionType } from '@ant-design/pro-components';
...@@ -17,6 +18,14 @@ import styles from './index.less'; ...@@ -17,6 +18,14 @@ import styles from './index.less';
import { Exclamtion } from '@/components/Icons/Icons'; import { Exclamtion } from '@/components/Icons/Icons';
const { Item } = Form; const { Item } = Form;
const layout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
};
const resetLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 16 },
};
const UserManage = () => { const UserManage = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
...@@ -26,16 +35,15 @@ const UserManage = () => { ...@@ -26,16 +35,15 @@ const UserManage = () => {
name: '', name: '',
id: ' ', id: ' ',
}); });
const [isModalResetPassword, setisModalResetPassword] = useState(false); const [isModalResetPassword, setIsModalResetPassword] = useState(false);
const [resetPassword, setResetPassword] = useState({}); const [resetPassword, setResetPassword] = useState({
id: '',
});
const [roles, setRoles] = useState([]); const [roles, setRoles] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [ressetLoading, setResetLoading] = useState(false);
const [accountModalName, setAccountModalName] = useState('新建账号'); const [accountModalName, setAccountModalName] = useState('新建账号');
const [accountForm] = Form.useForm(); const [accountForm] = Form.useForm();
const layout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
};
const showModal = () => { const showModal = () => {
getRole() getRole()
...@@ -117,10 +125,10 @@ const UserManage = () => { ...@@ -117,10 +125,10 @@ const UserManage = () => {
</a>, </a>,
<a <a
onClick={() => { onClick={() => {
// postDeleteUser({ setResetPassword({
// id: record.id, id: record.id,
// Password: });
// }); setIsModalResetPassword(true);
}} }}
key="reset" key="reset"
> >
...@@ -211,12 +219,32 @@ const UserManage = () => { ...@@ -211,12 +219,32 @@ const UserManage = () => {
}) })
.then((res) => { .then((res) => {
setIsModalDeleteAccountOpen(false); setIsModalDeleteAccountOpen(false);
actionRef.current?.reload();
message.success('删除成功');
}) })
.catch((err) => { .catch((err) => {
setIsModalDeleteAccountOpen(false); setIsModalDeleteAccountOpen(false);
}); });
}; };
const handleClickOpenModalReset = (values: any) => {
setResetLoading(true);
const data = {
id: resetPassword.id,
Password: values?.newPassword,
};
postResetUser(data)
.then((res) => {
setResetLoading(false);
setIsModalResetPassword(false);
actionRef.current?.reload();
message.success('重置成功');
})
.catch((err) => {
setResetLoading(false);
});
};
return ( return (
<PageContainer> <PageContainer>
<Modal <Modal
...@@ -224,6 +252,9 @@ const UserManage = () => { ...@@ -224,6 +252,9 @@ const UserManage = () => {
destroyOnClose={true} destroyOnClose={true}
open={isModalDeleteAccountOpen} open={isModalDeleteAccountOpen}
onOk={handleClickOpenModalDelete} onOk={handleClickOpenModalDelete}
onCancel={() => {
setIsModalDeleteAccountOpen(false);
}}
> >
<div className={styles.deleteTitle}> <div className={styles.deleteTitle}>
<Exclamtion /> 确定要删除 {deleteMessage.name} 的账号吗? <Exclamtion /> 确定要删除 {deleteMessage.name} 的账号吗?
...@@ -233,21 +264,20 @@ const UserManage = () => { ...@@ -233,21 +264,20 @@ const UserManage = () => {
</div> </div>
</Modal> </Modal>
<Modal <Modal
closable={true}
title="重置密码" title="重置密码"
destroyOnClose={true} destroyOnClose={true}
open={isModalDeleteAccountOpen} open={isModalResetPassword}
onOk={handleClickOpenModalDelete} onCancel={() => {
setIsModalResetPassword(false);
}}
footer={null}
> >
<Form name="resetPassword"> <Form {...resetLayout} onFinish={handleClickOpenModalReset} name="resetPassword">
<Item <Item
name={'newPassword'} name={'newPassword'}
label={'新密码'} label={'新密码'}
rules={[ rules={[{ required: true, message: '请输入密码!' }, { validator: validatePassword }]}
{
required: true,
message: '请输入你的密码',
},
]}
> >
<Input placeholder="请输入6-12位的数字或者字母" /> <Input placeholder="请输入6-12位的数字或者字母" />
</Item> </Item>
...@@ -271,6 +301,16 @@ const UserManage = () => { ...@@ -271,6 +301,16 @@ const UserManage = () => {
> >
<Input placeholder="请确认你的新密码" /> <Input placeholder="请确认你的新密码" />
</Item> </Item>
<Divider />
<Row justify={'center'}>
<Col>
<Item key={'saveButton'} noStyle={true}>
<Button key="submit" type="primary" loading={ressetLoading} htmlType="submit">
重置
</Button>
</Item>
</Col>
</Row>
</Form> </Form>
</Modal> </Modal>
<Modal <Modal
...@@ -378,7 +418,6 @@ const UserManage = () => { ...@@ -378,7 +418,6 @@ const UserManage = () => {
onClick={() => { onClick={() => {
setAccountModalName('添加账号'); setAccountModalName('添加账号');
showModal(); showModal();
actionRef.current?.reload();
}} }}
type="primary" type="primary"
> >
......
...@@ -100,7 +100,7 @@ export const postDeleteUser = (params?: any): Promise<string> => { ...@@ -100,7 +100,7 @@ export const postDeleteUser = (params?: any): Promise<string> => {
}; };
export const postResetUser = (params?: any): Promise<string> => { export const postResetUser = (params?: any): Promise<string> => {
return request('https://glm-mangement-api.baibaomen.com/User/delete', { return request('https://glm-mangement-api.baibaomen.com/User/reset', {
method: 'POST', method: 'POST',
data: params, data: params,
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment