index.tsx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {Button, Card, Space} from 'antd';
  2. import {FC, useMemo} from 'react';
  3. import css from './index.module.css';
  4. import {FormField, FormSelect} from '@components';
  5. import {useFormState} from './hooks';
  6. import {useDictionaryWidthCode, useMaterialOptions, useStorageOptions} from '@hooks';
  7. const OtherStockOut: FC = function () {
  8. const [{control, isLoading}, {onSubmit, onReset, watch}] = useFormState();
  9. const {data: materialOptions, isFetching} = useMaterialOptions();
  10. const [{data: warehouseOptions, isFetching: isWarehouseFetching}] = useDictionaryWidthCode(
  11. '仓库',
  12. {enabled: true},
  13. );
  14. const halfWarehouseOptions = useMemo(
  15. function () {
  16. return warehouseOptions.filter(val => val.type === '1');
  17. },
  18. [warehouseOptions],
  19. );
  20. const warehouseId = watch('warehouse');
  21. const {data: locationOptions, isFetching: isLocationFetching} = useStorageOptions(
  22. false,
  23. state => state.storageLocationCode,
  24. {
  25. id: warehouseId,
  26. },
  27. );
  28. const [{data: corporationOptions, isFetching: isCorporationFetching}] = useDictionaryWidthCode(
  29. '公司',
  30. {enabled: true, findValue: state => state.code},
  31. );
  32. return (
  33. <section className='content-main ant-card-title-reset'>
  34. <Card title='半成品其他出库'>
  35. <form className={css.form} onSubmit={onSubmit} onReset={onReset}>
  36. <Space direction='vertical' className='width-full'>
  37. <FormSelect
  38. loading={isFetching}
  39. options={materialOptions}
  40. control={control}
  41. label='出库物料'
  42. name='wllbCode'
  43. showSearch
  44. placeholder='请输入物料编号'
  45. />
  46. <FormSelect
  47. loading={isWarehouseFetching}
  48. options={halfWarehouseOptions}
  49. control={control}
  50. label='所属仓库'
  51. name='warehouse'
  52. showSearch
  53. />
  54. <FormSelect
  55. loading={isLocationFetching}
  56. options={locationOptions}
  57. control={control}
  58. label='所属库位'
  59. name='storageLocationCode'
  60. showSearch
  61. />{' '}
  62. <FormSelect
  63. loading={isCorporationFetching}
  64. options={corporationOptions}
  65. control={control}
  66. label='所属公司'
  67. name='accountSleeve'
  68. />
  69. <FormField control={control} name='wbs' label='WBS编号' />
  70. <FormField control={control} name='num' label='出库数量' type='number' />
  71. <Space className='width-full' style={{justifyContent: 'flex-end'}}>
  72. <Button htmlType='reset' disabled={isLoading}>
  73. 重置
  74. </Button>
  75. <Button htmlType='submit' type='primary' loading={isLoading}>
  76. 确认出库
  77. </Button>
  78. </Space>
  79. </Space>
  80. </form>
  81. </Card>
  82. </section>
  83. );
  84. };
  85. export default OtherStockOut;