index.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {Card} from 'antd';
  2. import {FC} from 'react';
  3. import {ColumnsType} from 'antd/es/table';
  4. import {StockListData} from '@models';
  5. import {Table, TableTools} from '@components';
  6. import {context, pageContext, searchContext} from '../context';
  7. import {
  8. HUGE_TABLE_WIDTH,
  9. LARGE_TABLE_WIDTH,
  10. NORMAL_TABLE_WIDTH,
  11. SMALL_TABLE_WIDTH,
  12. } from '@utils';
  13. import {exportStockList, getStockList} from '@apis';
  14. import {
  15. useContextSection,
  16. useQueryTableList,
  17. useTableExportEvent,
  18. } from '@hooks';
  19. const columns: ColumnsType<StockListData> = [
  20. {title: '物料编号', dataIndex: 'code', width: LARGE_TABLE_WIDTH},
  21. {title: '物料名称', dataIndex: 'name', width: HUGE_TABLE_WIDTH},
  22. {
  23. title: '库位名称',
  24. dataIndex: 'storageLocationName',
  25. width: NORMAL_TABLE_WIDTH,
  26. },
  27. {title: '数量', dataIndex: 'sum', width: SMALL_TABLE_WIDTH, align: 'right'},
  28. {title: '计量单位', dataIndex: 'unitOfMeasurement', width: SMALL_TABLE_WIDTH},
  29. {title: '物料类型', dataIndex: 'wllbClass', width: NORMAL_TABLE_WIDTH},
  30. {title: '物料类别', dataIndex: 'partType', width: NORMAL_TABLE_WIDTH},
  31. {title: '所属仓库', dataIndex: 'warehouseName', width: LARGE_TABLE_WIDTH},
  32. {title: '所属公司', dataIndex: 'companyName', width: LARGE_TABLE_WIDTH},
  33. {title: '公司编号', dataIndex: 'accountSleeve', width: SMALL_TABLE_WIDTH},
  34. {title: '供应商', dataIndex: 'supplierName', width: LARGE_TABLE_WIDTH},
  35. {title: 'WBS编号', dataIndex: 'wbs', width: NORMAL_TABLE_WIDTH},
  36. {
  37. title: '安全库存',
  38. dataIndex: 'maxNum',
  39. width: SMALL_TABLE_WIDTH,
  40. align: 'right',
  41. },
  42. {
  43. title: '库龄(天)',
  44. dataIndex: 'day',
  45. width: SMALL_TABLE_WIDTH,
  46. align: 'right',
  47. },
  48. ];
  49. const TableList: FC = function () {
  50. const params = useContextSection(context, state => state[0]);
  51. const [{data, count, isFetching}, {refetch}] = useQueryTableList({
  52. queryFn: getStockList,
  53. params,
  54. pageContext,
  55. searchContext,
  56. });
  57. const [isExporting, onExport] = useTableExportEvent({
  58. pageContext,
  59. context,
  60. fn: exportStockList,
  61. });
  62. return (
  63. <Card className='table-wrapper'>
  64. <TableTools
  65. onRefresh={refetch}
  66. isRefreshing={isFetching}
  67. isExporting={isExporting}
  68. onExport={onExport}
  69. />
  70. <Table
  71. data-testid='stock_table'
  72. data={data}
  73. count={count}
  74. pageContext={pageContext}
  75. searchContext={searchContext}
  76. columns={columns}
  77. />
  78. </Card>
  79. );
  80. };
  81. export default TableList;