upload-form.blade.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <div>
  2. <div class="bg-white shadow-md rounded-lg p-6">
  3. <h2 class="text-xl font-semibold text-gray-900 mb-4">上传试卷照片</h2>
  4. <form wire:submit.prevent="handleSubmit">
  5. {{-- 图片上传 --}}
  6. <div class="mb-6">
  7. <label class="block text-sm font-medium text-gray-700 mb-2">
  8. 试卷图片 <span class="text-red-500">*</span>
  9. </label>
  10. <div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md hover:border-gray-400 transition-colors">
  11. <div class="space-y-1 text-center">
  12. <svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
  13. <path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
  14. </svg>
  15. <div class="flex text-sm text-gray-600">
  16. <label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-blue-600 hover:text-blue-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-blue-500">
  17. <span>点击上传</span>
  18. <input id="file-upload" name="file-upload" type="file" class="sr-only" multiple accept="image/*" wire:model="uploadedImages">
  19. </label>
  20. <p class="pl-1">或拖拽文件到此处</p>
  21. </div>
  22. <p class="text-xs text-gray-500">支持 PNG、JPG、JPEG 格式,最多 10 张图片</p>
  23. </div>
  24. </div>
  25. {{-- 预览图片 --}}
  26. @if(count($uploadedImages) > 0)
  27. <div class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-4">
  28. @foreach($uploadedImages as $index => $image)
  29. <div class="relative">
  30. <img src="{{ $image->temporaryUrl() }}" alt="预览" class="h-24 w-full object-cover rounded-md">
  31. <button type="button" wire:click="removeImage({{ $index }})" class="absolute top-1 right-1 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600">
  32. ×
  33. </button>
  34. </div>
  35. @endforeach
  36. </div>
  37. @endif
  38. </div>
  39. {{-- 提交按钮 --}}
  40. <div class="flex justify-end space-x-3">
  41. <button type="button" wire:click="resetForm" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors">
  42. 重置
  43. </button>
  44. <button type="submit" wire:loading.attr="disabled" class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
  45. @if($mode === 'chatgpt')
  46. <span wire:loading.remove>开始 GPT 识别</span>
  47. <span wire:loading>分析中...</span>
  48. @else
  49. <span wire:loading.remove>开始 OCR 识别</span>
  50. <span wire:loading>上传中...</span>
  51. @endif
  52. </button>
  53. </div>
  54. </form>
  55. </div>
  56. </div>