import React, { useEffect, useState } from 'react'; import styles from './style/compGrid.module.less'; import CompNode from './compNode'; import { complexData } from './test/tempData'; import { Input, Grid, Pagination } from '@arco-design/web-react'; import { getMyFlowList, getPubFlowList } from '@/api/flow'; const InputSearch = Input.Search; const Row = Grid.Row; const Col = Grid.Col; interface CompGridProps { componentType: 'minePage' | 'publicList'; } const CompGrid: React.FC = ({ componentType }) => { const [compData, setCompData] = useState([]); const [paginationData, setPaginationData] = useState({ totalCount: 0, currPage: 1, pageSize: 11 }); const [searchKeyword, setSearchKeyword] = useState(''); useEffect(() => { if (componentType) getComponentData(componentType); }, [componentType]); const getComponentData = async (key: 'minePage' | 'publicList') => { const apiList = { minePage: getMyFlowList, publicList: getPubFlowList }; const res: any = await apiList[key]({ currPage: paginationData.currPage, pageSize: paginationData.pageSize, name: searchKeyword }); if (res.code === 200) { setCompData(res.data.list); setPaginationData({ totalCount: res.data.totalCount, currPage: res.data.currPage, pageSize: res.data.pageSize }); } }; useEffect(() => { getComponentData(componentType); }, [paginationData.currPage, searchKeyword]); const handleSearch = (value: string) => { setSearchKeyword(value); setPaginationData({ ...paginationData, currPage: 1 }); }; return ( <>
{compData.map((v, i) => { return ( ); })}
{ setPaginationData({ ...paginationData, currPage: number }); }} />
); }; export default CompGrid;