index.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {View, Image, Text} from '@tarojs/components';
  2. import icon from '@assets/goods/complate.svg';
  3. import {TextGroup} from '@components';
  4. import {useScanOrder} from '@hooks';
  5. import {Button} from '@antmjs/vantui';
  6. import {useAnomaly, useInfo, useSubmit, useUpload} from './hooks';
  7. import Upload from './upload';
  8. import Exception from './exception';
  9. import {BTN_LOADING_SIZE} from '@utils';
  10. export default function Receive() {
  11. const [{goodsList, customerNo, truckNo}, onScan] = useScanOrder();
  12. const [files, {onRemove, onAdd, setFiles}] = useUpload();
  13. const [{anomaly, note}, {setAnomaly, setNote}] = useAnomaly();
  14. const [isLoading, onSubmit] = useSubmit({
  15. customerNo,
  16. truckNo,
  17. anomaly,
  18. note,
  19. imgs: files,
  20. });
  21. useInfo(customerNo, truckNo, {setFiles, setAnomaly, setNote});
  22. return (
  23. <View className='h-screen overflow-auto bg-gray-100 flex flex-col'>
  24. <View className='py-4 bg-white'>
  25. <Image src={icon} mode='widthFix' className='w-14 mx-auto' />
  26. <Text className='px-3 text-center mt-2 block text-lg font-semibold text-[#333]'>
  27. 确认收货单
  28. </Text>
  29. </View>
  30. <View className='mt-px bg-white px-4 py-2'>
  31. <TextGroup title='卡车号' content={truckNo} />
  32. <TextGroup title='客户号' content={customerNo} />
  33. </View>
  34. {goodsList.length > 0 ? (
  35. <View className='mt-px bg-white p-4'>
  36. <Text className='text-lg font-semibold'>货品信息</Text>
  37. <View className='mt-3'>
  38. {goodsList.map(function ({no, num}) {
  39. return (
  40. <View
  41. key={no}
  42. className='border-0 border-b border-dashed border-gray-100 last:border-none'
  43. >
  44. <TextGroup title='品号' content={no} />
  45. <TextGroup title='数量' content={num} />
  46. </View>
  47. );
  48. })}
  49. </View>
  50. </View>
  51. ) : null}
  52. <View className='mt-3 bg-white px-4 py-2'>
  53. <Upload files={files} onDelete={onRemove} onAdd={onAdd} />
  54. </View>
  55. <View className='mt-3 bg-white px-4 py-2 mb-10'>
  56. <Exception
  57. checked={anomaly}
  58. onChange={setAnomaly}
  59. note={note}
  60. onNoteChange={setNote}
  61. />
  62. </View>
  63. <View className='flex mt-auto justify-around pb-12'>
  64. <Button disabled={isLoading} className='w-36' onClick={onScan} round>
  65. 扫码
  66. </Button>
  67. <Button
  68. type='primary'
  69. className='w-36'
  70. color='#58C6EA'
  71. round
  72. onClick={onSubmit}
  73. loading={isLoading}
  74. loadingSize={BTN_LOADING_SIZE}
  75. >
  76. 确认收货
  77. </Button>
  78. </View>
  79. </View>
  80. );
  81. }