index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {
  2. useContextSection,
  3. useQueryTableList,
  4. useTableExportEvent,
  5. } from '@hooks';
  6. import {FC} from 'react';
  7. import {context, pageContext, searchContext} from '../context';
  8. import {exportInventoryLog, getInventoryDetailedList} from '@apis';
  9. import {Card} from 'antd';
  10. import {Table, TableTools} from '@components';
  11. import {ColumnsType} from 'antd/es/table';
  12. import {InventoryLogListData} from '@models';
  13. import {
  14. HUGE_TABLE_WIDTH,
  15. MODAL_PAGE_SIZE_LIST,
  16. NORMAL_TABLE_WIDTH,
  17. } from '@utils';
  18. const columns: ColumnsType<InventoryLogListData> = [
  19. {title: '物料编号', dataIndex: 'wllbCode', width: NORMAL_TABLE_WIDTH},
  20. {title: '物料名称', dataIndex: 'name', width: HUGE_TABLE_WIDTH},
  21. {
  22. title: '库位名称',
  23. dataIndex: 'storageLocationName',
  24. width: NORMAL_TABLE_WIDTH,
  25. },
  26. {
  27. title: '系统库存',
  28. dataIndex: 'total',
  29. width: NORMAL_TABLE_WIDTH,
  30. align: 'right',
  31. },
  32. {
  33. title: '实际库存',
  34. dataIndex: 'amount',
  35. width: NORMAL_TABLE_WIDTH,
  36. align: 'right',
  37. },
  38. ];
  39. const TableList: FC = function () {
  40. const params = useContextSection(context, state => state[0]);
  41. const [{data, count, isFetching}, {refetch}] = useQueryTableList({
  42. queryFn: getInventoryDetailedList,
  43. pageContext,
  44. searchContext,
  45. params,
  46. });
  47. const [isExporting, onExport] = useTableExportEvent({
  48. fn: exportInventoryLog,
  49. pageContext,
  50. context,
  51. });
  52. return (
  53. <Card className='table-wrapper'>
  54. <TableTools
  55. onRefresh={refetch}
  56. isRefreshing={isFetching}
  57. isExporting={isExporting}
  58. onExport={onExport}
  59. />
  60. <Table
  61. data={data}
  62. count={count}
  63. pageContext={pageContext}
  64. searchContext={searchContext}
  65. columns={columns}
  66. data-testid='inventory_log_table'
  67. pageSizeList={MODAL_PAGE_SIZE_LIST}
  68. />
  69. </Card>
  70. );
  71. };
  72. export default TableList;