- 创建发布 Action(PublishSopTemplateAction) - 创建归档 Action(ArchiveSopTemplateAction) - 创建预览 Action(PreviewSopTemplateAction) - 发布前验证模板是否有步骤 - 发布时自动创建版本快照 - 预览模式显示完整模板内容
91 lines
3.4 KiB
PHP
91 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Actions;
|
|
|
|
use App\Models\SopTemplate;
|
|
use Filament\Actions\Action;
|
|
use Filament\Infolists;
|
|
use Filament\Infolists\Infolist;
|
|
|
|
class PreviewSopTemplateAction extends Action
|
|
{
|
|
public static function getDefaultName(): ?string
|
|
{
|
|
return 'preview';
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('预览模板');
|
|
|
|
$this->icon('heroicon-o-eye');
|
|
|
|
$this->color('info');
|
|
|
|
$this->modalHeading('SOP 模板预览');
|
|
|
|
$this->modalWidth('7xl');
|
|
|
|
$this->modalSubmitAction(false);
|
|
|
|
$this->modalCancelActionLabel('关闭');
|
|
|
|
$this->infolist(function (SopTemplate $record): Infolist {
|
|
return Infolist::make()
|
|
->record($record)
|
|
->schema([
|
|
Infolists\Components\Section::make('模板信息')
|
|
->schema([
|
|
Infolists\Components\TextEntry::make('name')
|
|
->label('模板名称')
|
|
->size(Infolists\Components\TextEntry\TextEntrySize::Large)
|
|
->weight('bold'),
|
|
|
|
Infolists\Components\TextEntry::make('description')
|
|
->label('模板描述')
|
|
->columnSpanFull(),
|
|
|
|
Infolists\Components\TextEntry::make('category')
|
|
->label('分类')
|
|
->badge(),
|
|
|
|
Infolists\Components\TextEntry::make('version')
|
|
->label('版本'),
|
|
])
|
|
->columns(2),
|
|
|
|
Infolists\Components\Section::make('操作步骤')
|
|
->schema([
|
|
Infolists\Components\RepeatableEntry::make('steps')
|
|
->label('')
|
|
->schema([
|
|
Infolists\Components\TextEntry::make('step_number')
|
|
->label('步骤')
|
|
->badge()
|
|
->color('primary'),
|
|
|
|
Infolists\Components\TextEntry::make('title')
|
|
->label('标题')
|
|
->weight('bold'),
|
|
|
|
Infolists\Components\TextEntry::make('content')
|
|
->label('内容')
|
|
->html()
|
|
->columnSpanFull(),
|
|
|
|
Infolists\Components\TextEntry::make('is_required')
|
|
->label('必需')
|
|
->badge()
|
|
->formatStateUsing(fn (bool $state): string => $state ? '是' : '否')
|
|
->color(fn (bool $state): string => $state ? 'success' : 'gray'),
|
|
])
|
|
->columns(3)
|
|
->contained(false),
|
|
]),
|
|
]);
|
|
});
|
|
}
|
|
}
|