import { PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import type { TabsProps } from 'antd'; import { Tabs } from 'antd'; import { useCallback, useRef, useState } from 'react'; import ConfigurableDrawerForm, { type ConfigurableDrawerFormRef, } from '@/components/DrawerForm'; import EnhancedProTable from '@/components/EnhancedProTable'; import type { ToolbarAction } from '@/components/EnhancedProTable/types'; import { formStatusType } from '@/constants'; import { getCategoryList } from '@/services/prodApi/category'; import { baseTenantColumns, formColumns } from './config'; const ProdCategory = () => { const tableRef = useRef(null); const [type, setType] = useState<'create' | 'update' | 'test'>('create'); const [grade, setGrade] = useState(''); const configurableDrawerRef = useRef(null); const onChange = useCallback( (key: string) => { setGrade(key); }, [grade], ); const onFetch = async (params: API.getProductCategoryCategoryListParams) => { const data = await getCategoryList({ ...params, grade: grade ? Number(grade) : undefined, }); return { data: data, success: true, }; }; const handleAdd = () => { setType('create'); configurableDrawerRef.current?.open(); }; const toolbarActions: ToolbarAction[] = [ { key: 'add', label: '新建', type: 'primary', icon: , onClick: handleAdd, }, ]; const handleEdit = async (row: API.CategoryDO) => { setType('update'); configurableDrawerRef.current?.open(row); }; const handleSubmit = async (values: API.CategoryDO) => { console.log('values', values); // const success = await handleAdd(values as API.CategoryDO); // if (success) { // handleClose(); // } return true; }; const actionColumns: ProColumns = { title: '操作', dataIndex: 'option', valueType: 'option', fixed: 'right', width: 120, render: (_text: React.ReactNode, record: API.CategoryDO, _: number) => [ handleEdit(record)}> 编辑 , 详情, ], }; const columns = [...baseTenantColumns, actionColumns]; const renderChildren = () => { return ( <> ref={tableRef} columns={columns} rowKey="categoryId" request={onFetch} toolbarActions={toolbarActions} headerTitle="短信渠道" showIndex={false} showSelection={false} /> ); }; const items: TabsProps['items'] = [ { key: '', label: '全部分类', children: renderChildren(), }, { key: '3', label: '三级分类', children: renderChildren(), }, { key: '2', label: '二级分类', children: renderChildren(), }, { key: '1', label: '一级分类', children: renderChildren(), }, ]; return ; }; export default ProdCategory;