| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <x-filament-panels::page>
- <div class="space-y-6">
- @php
- $questionsData = $this->questions;
- $metaData = $this->meta;
- $statisticsData = $this->statistics;
- @endphp
- <div class="flex justify-end">
- <button
- type="button"
- wire:click="$dispatch('ai-generate')"
- class="filament-button filament-button-size-sm filament-button-color-success filament-button-icon-start inline-flex items-center justify-center px-4 py-2 text-sm font-medium transition-colors border border-transparent rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
- >
- <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
- </svg>
- 生成题目
- </button>
- </div>
- <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
- <div class="bg-white p-4 rounded-lg border">
- <div class="text-sm text-gray-500">题目总数</div>
- <div class="text-2xl font-bold text-primary-600">{{ $statisticsData['total'] ?? 0 }}</div>
- </div>
- <div class="bg-white p-4 rounded-lg border">
- <div class="text-sm text-gray-500">基础难度</div>
- <div class="text-2xl font-bold text-green-600">{{ $statisticsData['by_difficulty']['0.3'] ?? 0 }}</div>
- </div>
- <div class="bg-white p-4 rounded-lg border">
- <div class="text-sm text-gray-500">中等难度</div>
- <div class="text-2xl font-bold text-yellow-600">{{ $statisticsData['by_difficulty']['0.6'] ?? 0 }}</div>
- </div>
- <div class="bg-white p-4 rounded-lg border">
- <div class="text-sm text-gray-500">拔高难度</div>
- <div class="text-2xl font-bold text-red-600">{{ $statisticsData['by_difficulty']['0.85'] ?? 0 }}</div>
- </div>
- </div>
- <div class="bg-white p-4 rounded-lg border">
- <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-2">搜索题目</label>
- <input type="text" wire:model.live.debounce.300ms="search" placeholder="输入关键词" class="w-full border rounded p-2">
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-2">知识点筛选</label>
- <input type="text" wire:model.live="selectedKpCode" placeholder="KP1001" class="w-full border rounded p-2">
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-2">难度筛选</label>
- <input type="text" wire:model.live="selectedDifficulty" placeholder="0.3/0.6/0.85" class="w-full border rounded p-2">
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-2">每页显示</label>
- <input type="number" wire:model.live="perPage" min="10" max="100" step="5" class="w-full border rounded p-2">
- </div>
- </div>
- </div>
- <div class="bg-white rounded-lg border overflow-hidden">
- <table class="min-w-full divide-y divide-gray-200">
- <thead class="bg-gray-50">
- <tr>
- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题目编号</th>
- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">知识点</th>
- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题干</th>
- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">难度</th>
- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">操作</th>
- </tr>
- </thead>
- <tbody class="bg-white divide-y divide-gray-200">
- @forelse($questionsData as $question)
- <tr class="hover:bg-gray-50">
- <td class="px-6 py-4 whitespace-nowrap">{{ $question['question_code'] ?? 'N/A' }}</td>
- <td class="px-6 py-4 whitespace-nowrap">{{ $question['kp_code'] ?? 'N/A' }}</td>
- <td class="px-6 py-4">{{ \Illuminate\Support\Str::limit($question['stem'] ?? 'N/A', 50) }}</td>
- <td class="px-6 py-4">
- @php
- $difficulty = $question['difficulty'] ?? null;
- $label = match (true) {
- !$difficulty => 'N/A',
- (float)$difficulty <= 0.4 => '基础',
- (float)$difficulty <= 0.7 => '中等',
- default => '拔高',
- };
- @endphp
- {{ $label }}
- </td>
- <td class="px-6 py-4 whitespace-nowrap">
- <button wire:click="deleteQuestion('{{ $question['question_code'] }}')" class="text-red-600 hover:underline">删除</button>
- </td>
- </tr>
- @empty
- <tr><td colspan="5" class="px-6 py-12 text-center">暂无数据</td></tr>
- @endforelse
- </tbody>
- </table>
- @if(!empty($metaData) && ($metaData['total'] ?? 0) > 0)
- <div class="px-4 py-3 border-t border-gray-200 flex items-center justify-between">
- <div class="text-sm text-gray-700">共 {{ $metaData['total'] ?? 0 }} 条记录</div>
- <div class="flex items-center gap-2">
- <button wire:click="previousPage" @disabled($currentPage <= 1) class="px-3 py-1 border rounded">上一页</button>
- @foreach($this->getPages() as $page)
- <button wire:click="gotoPage({{ $page }})" class="px-3 py-1 border rounded {{ $page === $currentPage ? 'bg-blue-50 text-blue-700' : '' }}">{{ $page }}</button>
- @endforeach
- <button wire:click="nextPage" @disabled($currentPage >= ($metaData['total_pages'] ?? 1)) class="px-3 py-1 border rounded">下一页</button>
- </div>
- </div>
- @endif
- </div>
- @if($showGenerateModal)
- <div class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
- <div class="bg-white rounded-lg p-6 max-w-2xl w-full">
- <h3 class="text-lg font-semibold mb-4">生成题目</h3>
- <div class="space-y-4">
- <div>
- <label class="block text-sm font-medium mb-2">知识点 <span class="text-red-500">*</span></label>
- <select wire:model.live="generateKpCode" class="w-full border rounded p-2">
- <option value="">选择知识点</option>
- @foreach($this->knowledgePointOptions as $code => $name)
- <option value="{{ $code }}">{{ $code }} - {{ $name }}</option>
- @endforeach
- </select>
- </div>
- @if(!empty($this->skillsOptions))
- <div>
- <div class="flex items-center justify-between mb-2">
- <label class="block text-sm font-medium">选择技能 <span class="text-red-500">*</span></label>
- <button type="button" class="text-sm text-blue-600 hover:underline" wire:click="toggleAllSkills">
- {{ count($selectedSkills) === count($this->skillsOptions) ? '取消全选' : '全选' }}
- </button>
- </div>
- <div class="max-h-48 overflow-y-auto border rounded p-3 space-y-2">
- @foreach($this->skillsOptions as $skill)
- <label class="flex items-center space-x-2">
- <input type="checkbox" value="{{ $skill['code'] }}" wire:model="selectedSkills" class="rounded border-gray-300">
- <span class="text-sm">
- <span class="font-medium">{{ $skill['code'] }}</span>
- <span class="text-gray-600 ml-2">{{ $skill['name'] }}</span>
- <span class="text-xs text-gray-400 ml-2">(权重: {{ $skill['weight'] ?? 1 }})</span>
- </span>
- </label>
- @endforeach
- </div>
- </div>
- @else
- <div class="text-sm text-gray-500 italic">
- 请先选择知识点以加载技能列表
- </div>
- @endif
- <div>
- <label class="block text-sm font-medium mb-2">题目数量</label>
- <input type="number" wire:model="questionCount" min="1" max="500" class="w-full border rounded p-2">
- </div>
- </div>
- <div class="flex justify-end gap-3 mt-6">
- <button type="button" wire:click="closeGenerateModal" class="px-4 py-2 border rounded">取消</button>
- <button type="button" wire:click="executeGenerate" class="px-4 py-2 bg-blue-600 text-white rounded">开始生成</button>
- </div>
- </div>
- </div>
- @endif
- <script>
- document.addEventListener('livewire:init', () => {
- Livewire.on('ai-generate', () => {
- @this.call('openGenerateModal');
- });
- });
- </script>
- </div>
- </x-filament-panels::page>
|