schema([ Section::make('题目内容') ->schema([ TextInput::make('question_code')->required()->maxLength(128), Select::make('question_type') ->options([ 'choice' => '选择题', 'fill' => '填空题', 'short' => '解答题', 'calc' => '计算题', ]) ->required(), Textarea::make('stem')->required()->rows(6), Textarea::make('answer')->rows(3), Textarea::make('solution')->rows(6), TextInput::make('difficulty')->numeric()->minValue(1)->maxValue(5), ]) ->columns(2), ]); } public static function table(Tables\Table $table): Tables\Table { return $table ->columns([ TextColumn::make('question_code')->label('编码')->searchable(), TextColumn::make('question_type')->label('题型')->sortable(), TextColumn::make('stem')->label('题干')->limit(60)->wrap()->searchable(), TextColumn::make('difficulty')->label('难度')->sortable(), TextColumn::make('updated_at')->label('更新')->dateTime(), ]) ->filters([ SelectFilter::make('question_type') ->options([ 'choice' => '选择题', 'fill' => '填空题', 'short' => '解答题', 'calc' => '计算题', ]), Filter::make('difficulty_range') ->form([ TextInput::make('min')->numeric(), TextInput::make('max')->numeric(), ]) ->query(function (Builder $query, array $data) { if ($data['min'] !== null && $data['max'] !== null) { $query->whereBetween('difficulty', [$data['min'], $data['max']]); } }), ]) ->actions([ ViewAction::make(), EditAction::make(), ]) ->bulkActions([ BulkActionGroup::make([ BulkAction::make('queue_solution') ->label('生成解析') ->action(fn ($records) => $records->each(fn ($record) => GenerateSolutionJob::dispatch($record->id))), BulkAction::make('match_knowledge') ->label('匹配知识点') ->action(fn ($records) => $records->each(fn ($record) => MatchKnowledgeJob::dispatch($record->id))), BulkAction::make('generate_svg') ->label('生成SVG') ->action(fn ($records) => $records->each(fn ($record) => GenerateSvgJob::dispatch($record->id))), ]), ]); } public static function getPages(): array { return [ 'index' => Pages\ListQuestions::route('/'), 'create' => Pages\CreateQuestion::route('/create'), 'view' => Pages\ViewQuestion::route('/{record}'), 'edit' => Pages\EditQuestion::route('/{record}/edit'), ]; } }