feat: tagEditor
Some checks failed
coverage CI / build (push) Has been cancelled

This commit is contained in:
2025-09-24 11:09:02 +08:00
parent 67b9a74212
commit 12495b6d85
11 changed files with 461 additions and 87 deletions

View File

@@ -4,30 +4,12 @@ import { PlusOutlined } from '@ant-design/icons';
import {
type ActionType,
type ParamsType,
ProColumns,
ProTable,
TableDropdown,
} from '@ant-design/pro-components';
import { Button, Space } from 'antd';
import React, {
act,
forwardRef,
useCallback,
useMemo,
useRef,
useState,
} from 'react';
import {
buildTableDropdownMenuItems,
formatPaginationTotal,
handleTableDropdownSelect,
} from '@/utils/antd/tableHelpers';
import {
type BaseRecord,
type EnhancedProTableProps,
TableAction,
ToolbarAction,
} from './types';
import React, { forwardRef, useCallback, useMemo, useState } from 'react';
import { formatPaginationTotal } from '@/utils/antd/tableHelpers';
import type { BaseRecord, EnhancedProTableProps } from './types';
function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
props: EnhancedProTableProps<T, U>,
@@ -36,21 +18,22 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
const {
columns,
request,
actions = [],
permissions = [],
// actions = [],
// permissions = [],
checkPermission = () => true,
toolbarActions,
showIndex = true,
showSelection = true,
showActions = true,
maxActionCount = 2,
onAdd,
onEdit,
onDelete,
onView,
onExport,
customToolbarRender,
// showActions = true,
// maxActionCount = 2,
// onAdd,
// onEdit,
// onDelete,
// onView,
// onExport,
// customToolbarRender,
customActionRender,
rowKey,
...restProps
} = props;
@@ -91,14 +74,13 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
[showSelection],
);
const toolBarRender = useCallback(
(
action: ActionType | undefined,
rows: {
selectedRowKeys?: (string | number)[] | undefined;
selectedRows?: T[] | undefined;
},
) => {
const toolBarRender = useCallback(() =>
// action: ActionType | undefined,
// rows: {
// selectedRowKeys?: (string | number)[] | undefined;
// selectedRows?: T[] | undefined;
// }
{
const toolbarElements =
toolbarActions?.map((action) => {
return (
@@ -125,22 +107,19 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
// </Button>,
// ];
return toolbarElements;
},
[toolbarActions],
);
}, [toolbarActions]);
return (
<ProTable<T, U>
{...restProps}
columns={columns}
actionRef={ref}
request={request}
rowKey="id"
rowKey={rowKey || 'id'}
rowSelection={rowSelection}
toolBarRender={toolBarRender}
manualRequest={false}
showSorterTooltip
tableAlertRender={tableAlertRender}
// tableAlertOptionRender={tableAlertOptionRender}
scroll={{ x: 'max-content' }}
search={{
labelWidth: 'auto',