import { menu } from '@/services/system/api'; import { treeify } from '@/util/treeify'; import { FolderOpenOutlined, MenuOutlined, ProfileOutlined } from '@ant-design/icons'; import type { ProColumns } from '@ant-design/pro-components'; import { ProFormSelect } from '@ant-design/pro-components'; import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components'; import { Space, Tag, Typography } from 'antd'; import React, { useEffect, useState } from 'react'; const { Link } = Typography; const Generator: React.FC = () => { const [data, setData] = useState(); const query = async (params: Record) => { const menus = (await menu(params)) ?? []; const treeData = treeify(menus, {}); menus.forEach((node) => { if (node.children && node.children.length === 0) delete node.children; }); // debugger; setData(treeData); }; useEffect(() => { query({ tenantId: 'webApp' }); }, []); const columns: ProColumns[] = [ { title: '菜单名称', key: 'name', width: 80, render(dom, entity) { if (entity.type === 1) { if (entity.url?.startsWith('javascript')) { return ( {entity.name} ); } else { return ( {entity.name} ); } } else { return ( {entity.name} ); } }, }, { title: '菜单url', dataIndex: 'url', width: 100, }, { title: '菜单path', dataIndex: 'path', width: 100, ellipsis: true, }, { title: '样式', dataIndex: 'css', width: 80, }, { title: '排序号', dataIndex: 'sort', width: 50, }, { title: '类型', key: 'type', width: 50, render(_, entity) { if (entity.type === 1) { if (entity.url?.startsWith('javascript')) { return 目录; } else { return 菜单; } } else { return 资源; } }, }, { title: '操作', key: 'action', fixed: 'right', width: 80, render: (_, entity) => ( {}}>修改 {}}>删除 ), }, ]; return ( query(values)} // onReset={() => setParams({})} > rowKey="id" headerTitle="菜单管理" dataSource={data} columns={columns} search={false} pagination={false} /> ); }; export default Generator;