| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <x-filament-panels::page>
- <div class="space-y-6">
- {{-- 上传表单卡片 --}}
- <div class="card bg-base-100 shadow-lg border">
- <div class="card-body">
- <h2 class="card-title text-xl mb-4">
- <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path>
- </svg>
- 上传考试卷子
- </h2>
- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
- {{-- 左侧:选择老师和学生 --}}
- <div class="space-y-4">
- {{-- 选择老师 --}}
- <div class="form-control w-full">
- <label class="label">
- <span class="label-text font-medium">选择老师 <span class="text-error">*</span></span>
- </label>
- <select
- wire:model.live="teacherId"
- class="select select-bordered w-full"
- >
- <option value="">请选择老师...</option>
- @foreach($this->teachers as $teacher)
- <option value="{{ $teacher->teacher_id }}">
- {{ trim($teacher->name ?? $teacher->teacher_id) . ($teacher->subject ? " ({$teacher->subject})" : '') }}
- </option>
- @endforeach
- </select>
- </div>
- {{-- 选择学生 --}}
- <div class="form-control w-full">
- <label class="label">
- <span class="label-text font-medium">选择学生 <span class="text-error">*</span></span>
- </label>
- <select
- wire:model.live="studentId"
- class="select select-bordered w-full"
- @if(empty($teacherId)) disabled @endif
- >
- <option value="">
- @if(empty($teacherId))
- 请先选择老师
- @else
- 请选择学生...
- @endif
- </option>
- @foreach($this->students as $student)
- <option value="{{ $student->student_id }}">
- {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
- </option>
- @endforeach
- </select>
- </div>
- </div>
- {{-- 右侧:上传图片 --}}
- <div class="form-control w-full">
- <label class="label">
- <span class="label-text font-medium">卷子图片 <span class="text-error">*</span></span>
- </label>
- @if($uploadedImage)
- {{-- 图片预览 --}}
- <div class="relative">
- <img
- src="{{ $uploadedImage->temporaryUrl() }}"
- class="w-full h-48 object-cover rounded-lg border"
- alt="预览"
- >
- <button
- type="button"
- wire:click="removeImage"
- class="btn btn-circle btn-sm btn-error absolute top-2 right-2"
- >
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
- </svg>
- </button>
- </div>
- <label class="label">
- <span class="label-text-alt text-success">
- {{ $uploadedImage->getClientOriginalName() }}
- ({{ number_format($uploadedImage->getSize() / 1024, 1) }} KB)
- </span>
- </label>
- @else
- {{-- 上传区域 --}}
- <div
- x-data="{ uploading: false, progress: 0 }"
- x-on:livewire-upload-start="uploading = true"
- x-on:livewire-upload-finish="uploading = false"
- x-on:livewire-upload-error="uploading = false"
- x-on:livewire-upload-progress="progress = $event.detail.progress"
- class="relative"
- >
- <input
- type="file"
- id="uploadedImage"
- wire:model.live="uploadedImage"
- class="hidden"
- accept="image/jpeg,image/png,image/webp"
- >
- <label
- for="uploadedImage"
- class="flex flex-col items-center justify-center w-full h-48 border-2 border-dashed rounded-lg cursor-pointer hover:bg-base-200 transition-colors"
- x-bind:class="{ 'border-primary bg-primary/5': uploading }"
- >
- {{-- 上传进度 --}}
- <div x-show="uploading" class="flex flex-col items-center justify-center">
- <div class="radial-progress text-primary" x-bind:style="'--value:' + progress + '; --size: 5rem; --thickness: 4px;'" role="progressbar">
- <span class="text-sm font-bold" x-text="progress + '%'"></span>
- </div>
- <p class="mt-3 text-base font-semibold text-primary">正在上传...</p>
- </div>
- {{-- 默认上传提示 --}}
- <div x-show="!uploading" class="flex flex-col items-center justify-center pt-5 pb-6">
- <svg class="w-10 h-10 mb-3 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
- </svg>
- <p class="mb-2 text-sm text-gray-500">
- <span class="font-semibold">点击上传</span> 或拖拽文件
- </p>
- <p class="text-xs text-gray-400">
- 支持 JPG、PNG、WebP (最大 10MB)
- </p>
- </div>
- </label>
- </div>
- @endif
- </div>
- </div>
- {{-- 提交按钮 --}}
- <div class="card-actions justify-end mt-6">
- <button
- type="button"
- wire:click="submitUpload"
- class="btn btn-primary"
- @if($isUploading) disabled @endif
- >
- @if($isUploading)
- <span class="loading loading-spinner"></span>
- 上传中...
- @else
- <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path>
- </svg>
- 上传并识别
- @endif
- </button>
- </div>
- </div>
- </div>
- {{-- 最近上传记录 --}}
- <div class="card bg-base-100 shadow-lg border">
- <div class="card-body">
- <h2 class="card-title text-lg mb-4">
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
- </svg>
- 最近上传记录
- </h2>
- @if(count($this->recentRecords) > 0)
- <div class="overflow-x-auto">
- <table class="table table-zebra">
- <thead>
- <tr>
- <th>学生</th>
- <th>文件名</th>
- <th>状态</th>
- <th>进度</th>
- <th>上传时间</th>
- </tr>
- </thead>
- <tbody>
- @foreach($this->recentRecords as $record)
- <tr
- class="hover:bg-base-200 cursor-pointer transition-colors"
- onclick="window.location.href='{{ route('filament.admin.resources.ocr-records-legacy.view', ['record' => $record['id']]) }}'"
- >
- <td>{{ $record['student']['name'] ?? '未知' }}</td>
- <td class="max-w-xs truncate">{{ $record['image_filename'] }}</td>
- <td>
- @php
- $statusClass = match($record['status']) {
- 'pending' => 'badge-ghost',
- 'processing' => 'badge-info',
- 'completed' => 'badge-success',
- 'failed' => 'badge-error',
- default => 'badge-ghost',
- };
- $statusText = match($record['status']) {
- 'pending' => '待处理',
- 'processing' => '处理中',
- 'completed' => '已完成',
- 'failed' => '失败',
- default => $record['status'],
- };
- @endphp
- <span class="badge {{ $statusClass }}">{{ $statusText }}</span>
- </td>
- <td>
- @if($record['total_questions'] > 0)
- <progress
- class="progress progress-primary w-20"
- value="{{ $record['processed_questions'] }}"
- max="{{ $record['total_questions'] }}"
- ></progress>
- <span class="text-xs ml-1">
- {{ $record['processed_questions'] }}/{{ $record['total_questions'] }}
- </span>
- @else
- <span class="text-gray-400">-</span>
- @endif
- </td>
- <td class="text-sm">
- {{ \Carbon\Carbon::parse($record['created_at'])->format('m-d H:i') }}
- </td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
- @else
- <div class="text-center py-8 text-gray-500">
- <svg class="w-12 h-12 mx-auto mb-3 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
- </svg>
- <p>暂无上传记录</p>
- </div>
- @endif
- </div>
- </div>
- </div>
- </x-filament-panels::page>
|