refactor: 修复知识库和操作指引

This commit is contained in:
2026-03-13 14:32:37 +08:00
parent bbe8e60646
commit 58f42de9df
88 changed files with 3387 additions and 2472 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Pages;
use App\Models\Document;
use App\Models\Group;
use App\Models\KnowledgeBase;
use App\Services\DocumentSearchService;
use App\Services\DocumentService;
use Filament\Forms\Components\Select;
@@ -41,6 +42,7 @@ class SearchPage extends Page implements HasForms, HasTable
public ?string $searchQuery = null;
public ?string $documentType = null;
public ?int $groupId = null;
public ?int $knowledgeBaseId = null;
// 搜索结果
public $searchResults = null;
@@ -55,6 +57,7 @@ class SearchPage extends Page implements HasForms, HasTable
'searchQuery' => '',
'documentType' => null,
'groupId' => null,
'knowledgeBaseId' => null,
]);
}
@@ -86,8 +89,15 @@ class SearchPage extends Page implements HasForms, HasTable
->options(Group::pluck('name', 'id'))
->searchable()
->native(false),
Select::make('knowledgeBaseId')
->label('知识库')
->placeholder('全部知识库')
->options(KnowledgeBase::pluck('name', 'id'))
->searchable()
->native(false),
])
->columns(3);
->columns(4);
}
/**
@@ -198,6 +208,9 @@ class SearchPage extends Page implements HasForms, HasTable
if ($this->groupId) {
$filters['group_id'] = $this->groupId;
}
if ($this->knowledgeBaseId) {
$filters['knowledge_base_id'] = $this->knowledgeBaseId;
}
// 执行搜索
$results = $searchService->search($this->searchQuery, $user, $filters);
@@ -236,6 +249,7 @@ class SearchPage extends Page implements HasForms, HasTable
$this->searchQuery = $data['searchQuery'];
$this->documentType = $data['documentType'];
$this->groupId = $data['groupId'];
$this->knowledgeBaseId = $data['knowledgeBaseId'] ?? null;
$this->hasSearched = true;
// 重置表格分页
@@ -256,11 +270,13 @@ class SearchPage extends Page implements HasForms, HasTable
'searchQuery' => '',
'documentType' => null,
'groupId' => null,
'knowledgeBaseId' => null,
]);
$this->searchQuery = null;
$this->documentType = null;
$this->groupId = null;
$this->knowledgeBaseId = null;
$this->hasSearched = false;
$this->resetTable();