feat: first commit

This commit is contained in:
2024-10-26 12:10:13 +08:00
parent b244826aa1
commit b064c4cb87
158 changed files with 18888 additions and 1 deletions

View File

@@ -0,0 +1,123 @@
import React, { useState } from 'react';
import {
Card,
Table,
Typography,
TableColumnProps,
Button,
Popconfirm,
Divider,
Space,
Message
} from '@arco-design/web-react';
import { useQuery } from 'react-query';
import Form from './form';
import { deleteMenu, getTreeMenu } from '@/api/menu';
const { Title } = Typography;
function ConfigManage() {
const [visible, setVisible] = useState(false);
const [record, setRecord] = useState(null);
const columns: TableColumnProps[] = [
{
title: '菜单id',
dataIndex: 'id',
align: 'center',
},
{
title: '菜单名称',
dataIndex: 'name',
align: 'center',
},
{
title: '菜单url',
dataIndex: 'url',
align: 'center',
},
{
title: '操作',
dataIndex: 'operations',
width:'25%',
render: (_, record) => (
<>
<Button onClick={() => showModal(record)} type="text" status="default"></Button>
<Divider type="vertical" />
<Popconfirm
focusLock
title="删除数据"
content="确认删除该条数据吗?"
onOk={() => onDelete(record)}
>
<Button type="text" status="danger"></Button>
</Popconfirm>
</>
),
align: 'center'
}
];
const onDelete = async ({ id }) => {
await deleteMenu(id);
Message.success('删除成功!');
await refetch();
};
const fetchData = async () => {
const { data } = await getTreeMenu();
return data
};
const {
data,
isLoading,
isFetching,
refetch
} = useQuery(
['menu'], fetchData, { refetchOnWindowFocus: false, keepPreviousData: true });
const showModal = (payload?) => {
payload && setRecord(payload);
setVisible(true);
};
const handleConfirm = async () => {
setRecord(null);
setVisible(false);
await refetch();
};
const handleCancel = () => {
setRecord(null);
setVisible(false);
};
return (
<>
<Card>
<Form
handleConfirm={handleConfirm}
handleCancel={handleCancel}
visible={visible}
record={record}
/>
<Title heading={6}></Title>
<Space style={{ marginBottom: 12 }}>
<Button type="primary" onClick={() => showModal()}></Button>
</Space>
<Table
rowKey="id"
loading={isLoading || isFetching}
columns={columns}
pagination={false}
data={data}
/>
</Card>
</>
);
}
export default ConfigManage;