index.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {
  2. useContextSection,
  3. useQueryTableList,
  4. useTableExportEvent,
  5. } from '@hooks';
  6. import {FC} from 'react';
  7. import {PRELAOD_KEY, 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}] = 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. pageContext={pageContext}
  56. searchContext={searchContext}
  57. isExporting={isExporting}
  58. onExport={onExport}
  59. preloadKey={PRELAOD_KEY}
  60. />
  61. <Table
  62. data={data}
  63. count={count}
  64. pageContext={pageContext}
  65. searchContext={searchContext}
  66. columns={columns}
  67. data-testid='inventory_log_table'
  68. pageSizeList={MODAL_PAGE_SIZE_LIST}
  69. preloadKey={PRELAOD_KEY}
  70. isSecondLevel
  71. />
  72. </Card>
  73. );
  74. };
  75. export default TableList;