index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {FC} from 'react';
  2. import {Card} from 'antd';
  3. import {Table} from '@components';
  4. import {context, pageContext, searchContext} from '../context';
  5. import {SemiDrawListData} from '@models';
  6. import {NORMAL_TABLE_WIDTH, MIDDLE_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
  7. import {ColumnsType} from 'antd/es/table';
  8. import {getSemiManufacturesDrawList} from '@apis';
  9. import {useContextSection, useQueryTableList} from '@hooks';
  10. const columns: ColumnsType<SemiDrawListData> = [
  11. {title: '要货单编号', dataIndex: 'askGoodsId', key: 'askGoodsId', width: NORMAL_TABLE_WIDTH},
  12. {title: '物料编号', dataIndex: 'materialCode', key: 'materialCode', width: NORMAL_TABLE_WIDTH},
  13. {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: MIDDLE_TABLE_WIDTH},
  14. {title: '数量', dataIndex: 'num', key: 'num', width: SMALL_TABLE_WIDTH},
  15. {
  16. title: '生产订单号',
  17. dataIndex: 'productionCode',
  18. key: 'productionCode',
  19. width: NORMAL_TABLE_WIDTH,
  20. },
  21. {title: '要料部门', dataIndex: 'department', key: 'department', width: NORMAL_TABLE_WIDTH},
  22. {
  23. title: '状态',
  24. dataIndex: 'type',
  25. key: 'type',
  26. render(_, {type}) {
  27. return type === '0' ? '未出库' : '已出库';
  28. },
  29. width: SMALL_TABLE_WIDTH,
  30. },
  31. ];
  32. const TableList: FC = function () {
  33. const params = useContextSection(context, function ([{code, type}]) {
  34. return {
  35. partType: '产成品' as const,
  36. productionCode: code,
  37. type,
  38. askGoodsId: '',
  39. };
  40. });
  41. const [{data, count}] = useQueryTableList({
  42. queryFn: getSemiManufacturesDrawList,
  43. params: params as any,
  44. pageContext,
  45. searchContext,
  46. });
  47. return (
  48. <>
  49. <Card className='table-wrapper'>
  50. <Table
  51. data-testid='semi_draw_table'
  52. data={data}
  53. columns={columns}
  54. count={count}
  55. pageContext={pageContext}
  56. searchContext={searchContext}
  57. />
  58. </Card>
  59. </>
  60. );
  61. };
  62. export default TableList;