import React from 'react';
import {
DeleteOutlined,
EditOutlined,
PlusOutlined,
SearchOutlined,
RedoOutlined,
DownOutlined,
ExclamationCircleFilled,
UpOutlined,
InfoCircleFilled,
QuestionCircleFilled,
DownloadOutlined
} from '@ant-design/icons';
import {connect, history} from '@umijs/max';
import {Button, Card, Divider, Dropdown, message, Modal, Popconfirm, Space, Switch, Tag, Row, Col, Tree} from 'antd';
import StandardTable from '@/components/StandardTable';
import { MyIcon } from "@/components/Icon"
import style from "@/global.less";
import styles from './SystemMenuList.less';
import datadictionary from "@/utils/dataDictionary";
import {formatDate} from "@/utils/formatUtils";
import { formatDictText, checkButtonAuthority } from "@/utils/globalCommon";
const { confirm } = Modal;
// 菜单类型
const menu_type = datadictionary.menu_type || [];
const menu_status = datadictionary.menu_status || [];
const menu_level = datadictionary.menu_level || [];
const mockData = {
list: [
{
id: '1',
name: '效率管理',
code: 'hrefficiency',
type: '1',
level: '1',
status: '1',
path: '/topnavbar00/hrefficiency',
component: '',
icon: 'setting',
createTime: '2023-01-01 10:00:00',
createUser: 'admin',
children: [
{
id: '2',
name: '工时仪表盘',
code: 'timesheet',
type: '2',
level: '2',
status: '1',
path: '/topnavbar00/hrefficiency/timesheet',
component: './hrefficiency_timesheet/TimeSheetList',
icon: 'dashboard',
createTime: '2023-01-01 10:05:00',
createUser: 'admin'
},
{
id: '3',
name: '员工仪表盘',
code: 'staffsheet',
type: '2',
level: '2',
status: '1',
path: '/topnavbar00/hrefficiency/staffsheet',
component: './hrefficiency_staffsheet/StaffSheetList',
icon: 'user',
createTime: '2023-01-01 10:10:00',
createUser: 'admin'
}
]
},
{
id: '4',
name: '系统管理',
code: 'system',
type: '1',
level: '1',
status: '1',
path: '/topnavbar00/hrefficiency/system',
component: './nav_system_content/SystemContentList',
icon: 'control',
createTime: '2023-01-02 14:30:00',
createUser: 'admin'
}
],
pagination: {
total: 2,
pageSize: 10,
current: 1
}
};
@connect(({ systemMenu }) => ({
systemMenu
}))
export default class SystemMenuList extends React.Component {
state = {
selectedRows: [],
advancedFormVisible: false,
filterData: {},
pagination: {
pageSize: 10,
current: 1
},
tableData: mockData.list,
treeData: [],
expandedKeys: []
};
componentDidMount() {
this.getMenuList();
this.buildTreeData();
}
// 获取菜单列表
getMenuList = () => {
const { dispatch } = this.props;
const { pagination, filterData } = this.state;
try {
dispatch({
type: 'systemMenu/fetchList',
payload: {
pageNum: pagination.current,
pageSize: pagination.pageSize,
...filterData
},
callback: (res) => {
this.setState({
tableData: res?.list || mockData.list,
pagination: {
...pagination,
total: res?.total || mockData.pagination.total
}
}, () => {
this.buildTreeData();
});
}
});
} catch (error) {
console.error('获取菜单列表失败:', error);
this.setState({
tableData: mockData.list,
pagination: mockData.pagination
}, () => {
this.buildTreeData();
});
}
};
// 构建树数据
buildTreeData = () => {
const { tableData } = this.state;
const treeData = this.transformToTree(tableData);
this.setState({ treeData });
};
// 转换为树结构
transformToTree = (data) => {
return data.map(item => {
const node = {
title: item.name,
key: item.id,
dataRef: item
};
if (item.children && item.children.length > 0) {
node.children = this.transformToTree(item.children);
}
return node;
});
};
// 表格选择变化
handleSelectChange = (selectedRowKeys, selectedRows) => {
this.setState({ selectedRows });
};
// 分页变化
handleTableChange = (pagination) => {
this.setState({
pagination: {
...this.state.pagination,
current: pagination.current
}
}, () => {
this.getMenuList();
});
};
// 新增菜单
handleAdd = () => {
// 新增逻辑
message.success('新增菜单功能');
};
// 编辑菜单
handleEdit = (record) => {
// 编辑逻辑
message.success('编辑菜单功能');
};
// 删除菜单
handleDelete = (record) => {
confirm({
title: '确定要删除这个菜单吗?',
icon: