feat(阶段四): 实现 SOP 模板状态管理功能
- 创建发布 Action(PublishSopTemplateAction) - 创建归档 Action(ArchiveSopTemplateAction) - 创建预览 Action(PreviewSopTemplateAction) - 发布前验证模板是否有步骤 - 发布时自动创建版本快照 - 预览模式显示完整模板内容
This commit is contained in:
50
app/Filament/Actions/ArchiveSopTemplateAction.php
Normal file
50
app/Filament/Actions/ArchiveSopTemplateAction.php
Normal 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user