feat: 高级列表

This commit is contained in:
2025-09-13 17:56:13 +08:00
parent e42e1c01fb
commit 9d5a289929
18 changed files with 1301 additions and 6739 deletions

View File

@@ -0,0 +1,58 @@
// utils/tableHelpers.ts
import { TableDropdownMenuItem } from "@/components/EnhancedProTable/types";
/**
* 构建 TableDropdown 菜单项
*/
export const buildTableDropdownMenuItems = (
actions: Array<{
key: string;
label: string;
icon?: React.ReactNode;
danger?: boolean;
disabled?: boolean;
}>
): TableDropdownMenuItem[] => {
return actions.map((action) => ({
key: action.key,
name: action.label,
icon: action.icon,
danger: action.danger,
disabled: action.disabled,
}));
};
/**
* 处理 TableDropdown 选择事件
*/
export const handleTableDropdownSelect = <T>(
key: string | number,
actions: Array<{
key: string;
onClick: (record: T, action?: any) => void;
}>,
record: T,
action?: any
) => {
const selectedAction = actions.find((item) => item.key === key);
if (selectedAction) {
selectedAction.onClick(record, action);
}
};
/**
* 格式化分页显示文本
*/
export const formatPaginationTotal = (
total: number,
range: [number, number]
) => {
return `${range[0]}-${range[1]} 条/总共 ${total}`;
};
/**
* 生成唯一的表格键
*/
export const generateTableKey = (prefix: string) => {
return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
};