import React, { createContext, useEffect, useState } from 'react'; import { translateAttributes } from '../../utils/usefulFn'; import List from '../list'; import ToolBar from '../list/toolBar'; import ButtonGroup from '../list/buttonGroup'; import Style from './index.module.less'; import { useWidth } from '../../platforms/web/responsive/useWidth'; export const TableContext = createContext({ tableAttributes: undefined, entity: undefined, schema: undefined, setTableAttributes: undefined, setSchema: undefined, onReset: undefined, }); const ProList = (props) => { const { buttonGroup, entity, extraActions, onAction, disabledOp, attributes, data, loading, tablePagination, rowSelection, onReload, disableSerialNumber, title, hideDefaultButtons = false, extraContent, size = 'large', scroll, locale,opWidth } = props; const [tableAttributes, setTableAttributes] = useState([]); const [schema, setSchema] = useState(undefined); const width = useWidth(); const isMobile = width === 'xs'; const initTableAttributes = () => { if (schema) { const judgeAttributes = translateAttributes(schema, entity, attributes); const newTableAttributes = judgeAttributes.map((ele) => ({ attribute: ele, show: true, })); setTableAttributes(newTableAttributes); } }; useEffect(() => { initTableAttributes(); }, [attributes, schema]); return ( { initTableAttributes(); }, }}>
{!isMobile && !hideDefaultButtons && ()} {isMobile && }
); }; export default ProList;