index.jsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {Image, Text, View, Picker} from '@tarojs/components';
  2. import icon from '@assets/goods/sending.svg';
  3. import {Button} from '@antmjs/vantui';
  4. import {TextGroup as Item, Upload} from '@components';
  5. import {useSubmit} from './hooks';
  6. import dayjs from 'dayjs';
  7. import {useScanOrder, useUpload} from '@hooks';
  8. import {BTN_LOADING_SIZE} from '@utils';
  9. export default function DeliverGoods() {
  10. const [
  11. {goodsList, customerNo, truckNo, date},
  12. {onScan, setDate: onDateChange},
  13. ] = useScanOrder();
  14. const [files, {onAdd, onRemove}] = useUpload();
  15. const [isLoading, onSubmit] = useSubmit({
  16. goodsList,
  17. customerNo,
  18. truckNo,
  19. date,
  20. files,
  21. });
  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. <Item title='卡车号' content={truckNo} />
  32. <Item title='客户号' content={customerNo} />
  33. <Picker
  34. mode='date'
  35. value={date}
  36. onChange={onDateChange}
  37. start={dayjs().format('YYYY-MM-DD')}
  38. >
  39. <Item title='到货时间' content={date} />
  40. </Picker>
  41. </View>
  42. {goodsList.length > 0 ? (
  43. <View className='mt-px bg-white p-4'>
  44. <Text className='text-lg font-semibold'>货品信息</Text>
  45. <View className='mt-3'>
  46. {goodsList.map(function({no, num}) {
  47. return (
  48. <View
  49. key={no}
  50. className='border-0 border-b border-dashed border-gray-100 last:border-none'
  51. >
  52. <Item title='品号' content={no} />
  53. <Item title='数量' content={num} />
  54. </View>
  55. );
  56. })}
  57. </View>
  58. </View>
  59. ) : null}
  60. <Upload files={files} onAdd={onAdd} onDelete={onRemove} />
  61. <View className='flex mt-auto justify-around pb-12'>
  62. <Button className='w-36' onClick={onScan} round disabled={isLoading}>
  63. 扫码
  64. </Button>
  65. <Button
  66. onClick={onSubmit}
  67. loading={isLoading}
  68. type='primary'
  69. className='w-36'
  70. color='#58C6EA'
  71. round
  72. loadingSize={BTN_LOADING_SIZE}
  73. >
  74. 发货
  75. </Button>
  76. </View>
  77. </View>
  78. );
  79. }