generated from liutk/owl-admin-base
107 lines
3.7 KiB
PHP
107 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\System;
|
|
|
|
use App\Admin\Controllers\AdminController;
|
|
use App\Admin\Services\WorkFlowService;
|
|
use App\Enums\CheckType;
|
|
use App\Models\Employee;
|
|
use App\Models\Keyword;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
|
|
/**
|
|
* 审核流程管理
|
|
*/
|
|
class WorkflowController extends AdminController
|
|
{
|
|
protected string $serviceName = WorkFlowService::class;
|
|
|
|
protected $jobOptions;
|
|
|
|
protected $employeeOptions;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
$this->createButton(),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->bulkActions([])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->TextControl()->name('search')->label(__('admin.keyword'))->placeholder(__('workflow.key').'/'.__('workflow.name'))->columnRatio(3)->clearable(),
|
|
]),
|
|
]))
|
|
->columns([
|
|
amisMake()->TableColumn()->name('id')->label(__('workflow.id')),
|
|
amisMake()->TableColumn()->name('key')->label(__('workflow.key')),
|
|
amisMake()->TableColumn()->name('name')->label(__('workflow.name')),
|
|
$this->rowActions([
|
|
$this->rowShowButton(),
|
|
$this->rowEditButton(),
|
|
$this->rowDeleteButton(),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form($edit): Form
|
|
{
|
|
return $this->baseForm()->title('')->body([
|
|
amisMake()->TextControl()->name('key')->label(__('workflow.key'))->required(),
|
|
amisMake()->TextControl()->name('name')->label(__('workflow.name'))->required(),
|
|
amisMake()->ArrayControl()->name('config')->label(__('workflow.config'))->items(amisMake()->ComboControl()->items([
|
|
amisMake()->SelectControl()->options(CheckType::options())->name('type')->label(__('workflow.type')),
|
|
amisMake()->SelectControl()
|
|
->options($this->getJobOptions())
|
|
->labelField('name')
|
|
->valueField('key')
|
|
->name('job')
|
|
// ->visibleOn('${config.type == '.CheckType::Job->value.'}')
|
|
->label(CheckType::Job->text()),
|
|
amisMake()->SelectControl()
|
|
->options($this->getEmployeeOptions())
|
|
->labelField('name')
|
|
->valueField('id')
|
|
->searchable()
|
|
->name('user')
|
|
// ->visibleOn('${config.type == '.CheckType::User->value.'}')
|
|
->label(CheckType::User->text()),
|
|
])),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
$detail = amisMake()->Property()->items([
|
|
['label' => __('workflow.key'), 'content' => '${key}'],
|
|
['label' => __('workflow.name'), 'content' => '${name}'],
|
|
['label' => __('workflow.config'), 'content' => amisMake()->Steps()->labelPlacement('horizontal')->source('${config}'), 'span' => 3],
|
|
]);
|
|
|
|
return $this->baseDetail()->title('')->body($detail);
|
|
}
|
|
|
|
public function getJobOptions()
|
|
{
|
|
if (! $this->jobOptions) {
|
|
$this->jobOptions = Keyword::where('parent_key', 'job')->get();
|
|
}
|
|
|
|
return $this->jobOptions;
|
|
}
|
|
|
|
public function getEmployeeOptions()
|
|
{
|
|
if (! $this->employeeOptions) {
|
|
$this->employeeOptions = Employee::enable()->get();
|
|
}
|
|
|
|
return $this->employeeOptions;
|
|
}
|
|
}
|