Commit ce56df68 authored by littleforest's avatar littleforest

feat:add delete api

parent 0bc59ceb
import Icon from '@ant-design/icons';
const ExclamtionSvg = () => (
<svg
width="24px"
height="24px"
viewBox="0 0 24 24"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<title>exclamation-circle</title>
<g id="页面-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd" opacity="0.65">
<g
id="10-3-删除账号"
transform="translate(-542.000000, -405.000000)"
fill="#FF8F00"
fillRule="nonzero"
>
<g id="编辑账号" transform="translate(470.000000, 321.000000)">
<g id="exclamation-circle" transform="translate(72.000000, 84.000000)">
<path
d="M12,0 C5.371875,0 0,5.371875 0,12 C0,18.628125 5.371875,24 12,24 C18.628125,24 24,18.628125 24,12 C24,5.371875 18.628125,0 12,0 Z M11.0625,5.4140625 C11.0625,4.89609375 11.4820312,4.4765625 12,4.4765625 C12.5179688,4.4765625 12.9375,4.89609375 12.9375,5.4140625 L12.9375,14.0625 C12.9375,14.5804688 12.5179688,15 12,15 C11.4820312,15 11.0625,14.5804688 11.0625,14.0625 L11.0625,5.4140625 Z M12,18.609375 C11.4164063,18.609375 10.9453125,18.1382812 10.9453125,17.5546875 C10.9453125,16.9710938 11.4164063,16.5 12,16.5 C12.5835937,16.5 13.0546875,16.9710938 13.0546875,17.5546875 C13.0546875,18.1359375 12.5835937,18.609375 12,18.609375 Z"
id="Shape"
/>
</g>
</g>
</g>
</g>
</svg>
);
export const Exclamtion = (props: any) => {
return <Icon component={ExclamtionSvg} {...props} />;
};
......@@ -16,3 +16,28 @@
.red {
background-color: #f5222d;
}
.deleteTitle {
display: flex;
height: 22px;
margin-bottom: 10px;
color: rgba(0, 0, 0, 0.85);
font-weight: 600;
font-size: 16px;
font-family: PingFangSC-Semibold, PingFang SC;
line-height: 22px;
& svg {
width: 24px;
height: 24px;
margin-right: 10px;
}
}
.deleteContent {
width: 322px;
height: 44px;
margin-left: 34px;
color: rgba(0, 0, 0, 0.65);
font-weight: 400;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
line-height: 22px;
}
......@@ -14,13 +14,19 @@ import classNames from 'classnames';
import { isEmpty } from 'lodash';
import { useRef, useState } from 'react';
import styles from './index.less';
import { Exclamtion } from '@/components/Icons/Icons';
const { Item } = Form;
const UserManage = () => {
const actionRef = useRef<ActionType>();
const [isModalAccountOpen, setIsModalAccountOpen] = useState(false);
const [isModalDeleteAccountOpen, setIsModalDeleteAccountOpen] = useState(false);
const [deleteMessage, setDeleteMessage] = useState({
name: '',
id: ' ',
});
const [resetPassword, setResetPassword] = useState({});
const [roles, setRoles] = useState([]);
const [loading, setLoading] = useState(false);
const [accountModalName, setAccountModalName] = useState('新建账号');
......@@ -122,9 +128,8 @@ const UserManage = () => {
<a
key="remove"
onClick={() => {
postDeleteUser({
id: record.id,
});
setDeleteMessage(record);
setIsModalDeleteAccountOpen(true);
}}
>
删除
......@@ -199,8 +204,74 @@ const UserManage = () => {
return Promise.reject(new Error('密码格式不正确!'));
};
const handleClickOpenModalDelete = () => {
postDeleteUser({
id: deleteMessage.id,
})
.then((res) => {
setIsModalDeleteAccountOpen(false);
})
.catch((err) => {
setIsModalDeleteAccountOpen(false);
});
};
return (
<PageContainer>
<Modal
title="删除账号"
destroyOnClose={true}
open={isModalDeleteAccountOpen}
onOk={handleClickOpenModalDelete}
>
<div className={styles.deleteTitle}>
<Exclamtion /> 确定要删除 {deleteMessage.name} 的账号吗?
</div>
<div className={styles.deleteContent}>
一旦删除账号,则无法再使用且该账号下所有信息会被清除,请谨慎操作。
</div>
</Modal>
<Modal
title="重置密码"
destroyOnClose={true}
open={isModalDeleteAccountOpen}
onOk={handleClickOpenModalDelete}
>
<Form name="resetPassword">
<Item
name={'newPassword'}
label={'新密码'}
rules={[
{
required: true,
message: '请输入你的密码',
},
]}
>
<Input placeholder="请输入6-12位的数字或者字母" />
</Item>
<Item
name={'confirmNewPassword'}
label={'确认新密码'}
rules={[
{
required: true,
message: '请确认你的密码',
},
({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('newPassword') === value) {
return Promise.resolve();
}
return Promise.reject(new Error('两次密码输入不一致!'));
},
}),
]}
>
<Input placeholder="请确认你的新密码" />
</Item>
</Form>
</Modal>
<Modal
title={`${accountModalName}`}
open={isModalAccountOpen}
......@@ -208,6 +279,7 @@ const UserManage = () => {
onCancel={handleModalCancel}
footer={null}
maskClosable={false}
destroyOnClose={true}
>
<Form
{...layout}
......
......@@ -72,7 +72,7 @@ export const getUserMessage = (params?: any): Promise<string> => {
export const postDeleteUser = (params?: any): Promise<string>=> {
return request('https://glm-mangement-api.baibaomen.com/User/delete', {
method: 'POST',
data: params
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