index.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {useContextSection, useQueryTableList} from '@hooks';
  2. import {FC} from 'react';
  3. import {context, pageContext, searchContext} from '../context';
  4. import {getInventoryMainList} from '@apis';
  5. import {Card} from 'antd';
  6. import {Table, TableTools} from '@components';
  7. import {useBoolean} from 'ahooks';
  8. import AddModal from './modal';
  9. import {useColumn} from './hooks';
  10. import DetailModal from './detail-modal';
  11. import LogModal from './log-modal';
  12. const TableList: FC = function () {
  13. const params = useContextSection(context, state => state[0]);
  14. const [{isFetching, data, count}, {refetch}] = useQueryTableList({
  15. queryFn: getInventoryMainList,
  16. params,
  17. pageContext,
  18. searchContext,
  19. });
  20. const [visible, {setTrue, setFalse}] = useBoolean();
  21. const [
  22. {columns, detailVisible, detailId, logVisible, logId},
  23. {onDetailDetailClose, onLogClose},
  24. ] = useColumn();
  25. return (
  26. <>
  27. <Card className='table-wrapper'>
  28. <TableTools
  29. onRefresh={refetch}
  30. isRefreshing={isFetching}
  31. onAdd={setTrue}
  32. />
  33. <Table
  34. columns={columns}
  35. data={data}
  36. count={count}
  37. pageContext={pageContext}
  38. searchContext={searchContext}
  39. data-testid='inventory_table'
  40. />
  41. </Card>
  42. <AddModal visible={visible} onClose={setFalse} onFetch={refetch} />
  43. <DetailModal
  44. visible={detailVisible}
  45. onClose={onDetailDetailClose}
  46. uuid={detailId}
  47. />
  48. <LogModal visible={logVisible} uuid={logId} onClose={onLogClose} />
  49. </>
  50. );
  51. };
  52. export default TableList;