Commit 77abf4f9 authored by littleforest's avatar littleforest

feat: add reset funciton

parent c177cecb
......@@ -4,6 +4,7 @@ import {
getUserMessage,
postDelete,
postDeleteUser,
postResetUser,
} from '@/services/chatGLM/api';
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType } from '@ant-design/pro-components';
......@@ -17,6 +18,14 @@ import styles from './index.less';
import { Exclamtion } from '@/components/Icons/Icons';
const { Item } = Form;
const layout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
};
const resetLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 16 },
};
const UserManage = () => {
const actionRef = useRef<ActionType>();
......@@ -26,16 +35,15 @@ const UserManage = () => {
name: '',
id: ' ',
});
const [isModalResetPassword, setisModalResetPassword] = useState(false);
const [resetPassword, setResetPassword] = useState({});
const [isModalResetPassword, setIsModalResetPassword] = useState(false);
const [resetPassword, setResetPassword] = useState({
id: '',
});
const [roles, setRoles] = useState([]);
const [loading, setLoading] = useState(false);
const [ressetLoading, setResetLoading] = useState(false);
const [accountModalName, setAccountModalName] = useState('新建账号');
const [accountForm] = Form.useForm();
const layout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
};
const showModal = () => {
getRole()
......@@ -117,10 +125,10 @@ const UserManage = () => {
</a>,
<a
onClick={() => {
// postDeleteUser({
// id: record.id,
// Password:
// });
setResetPassword({
id: record.id,
});
setIsModalResetPassword(true);
}}
key="reset"
>
......@@ -211,12 +219,32 @@ const UserManage = () => {
})
.then((res) => {
setIsModalDeleteAccountOpen(false);
actionRef.current?.reload();
message.success('删除成功');
})
.catch((err) => {
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 (
<PageContainer>
<Modal
......@@ -224,6 +252,9 @@ const UserManage = () => {
destroyOnClose={true}
open={isModalDeleteAccountOpen}
onOk={handleClickOpenModalDelete}
onCancel={() => {
setIsModalDeleteAccountOpen(false);
}}
>
<div className={styles.deleteTitle}>
<Exclamtion /> 确定要删除 {deleteMessage.name} 的账号吗?
......@@ -233,21 +264,20 @@ const UserManage = () => {
</div>
</Modal>
<Modal
closable={true}
title="重置密码"
destroyOnClose={true}
open={isModalDeleteAccountOpen}
onOk={handleClickOpenModalDelete}
open={isModalResetPassword}
onCancel={() => {
setIsModalResetPassword(false);
}}
footer={null}
>
<Form name="resetPassword">
<Form {...resetLayout} onFinish={handleClickOpenModalReset} name="resetPassword">
<Item
name={'newPassword'}
label={'新密码'}
rules={[
{
required: true,
message: '请输入你的密码',
},
]}
rules={[{ required: true, message: '请输入密码!' }, { validator: validatePassword }]}
>
<Input placeholder="请输入6-12位的数字或者字母" />
</Item>
......@@ -271,6 +301,16 @@ const UserManage = () => {
>
<Input placeholder="请确认你的新密码" />
</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>
</Modal>
<Modal
......@@ -378,7 +418,6 @@ const UserManage = () => {
onClick={() => {
setAccountModalName('添加账号');
showModal();
actionRef.current?.reload();
}}
type="primary"
>
......
......@@ -100,7 +100,7 @@ export const postDeleteUser = (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',
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