feat(阶段四): 实现 SOP 模板状态管理功能

- 创建发布 Action(PublishSopTemplateAction)
- 创建归档 Action(ArchiveSopTemplateAction)
- 创建预览 Action(PreviewSopTemplateAction)
- 发布前验证模板是否有步骤
- 发布时自动创建版本快照
- 预览模式显示完整模板内容
This commit is contained in:
2026-03-09 13:24:14 +08:00
parent c4ab592fd5
commit 6102ec95d2
3 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Filament\Actions;
use App\Models\SopTemplate;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
class ArchiveSopTemplateAction extends Action
{
public static function getDefaultName(): ?string
{
return 'archive';
}
protected function setUp(): void
{
parent::setUp();
$this->label('归档模板');
$this->icon('heroicon-o-archive-box');
$this->color('warning');
$this->requiresConfirmation();
$this->modalHeading('归档 SOP 模板');
$this->modalDescription('归档后,模板将不再对用户显示。确定要归档吗?');
$this->modalSubmitActionLabel('确认归档');
$this->visible(function ($record) {
return $record instanceof SopTemplate && $record->status === 'published';
});
$this->action(function (SopTemplate $record) {
$record->update([
'status' => 'archived',
]);
Notification::make()
->title('归档成功')
->body('SOP 模板已成功归档')
->success()
->send();
});
}
}