generated from liutk/owl-admin-base
admin workflow
parent
3039ffe27e
commit
98c979ac6b
|
|
@ -32,16 +32,40 @@ class AgreementController extends AdminController
|
||||||
...$this->baseHeaderToolBar(),
|
...$this->baseHeaderToolBar(),
|
||||||
])
|
])
|
||||||
->bulkActions([])
|
->bulkActions([])
|
||||||
|
->filter($this->baseFilter()->body([
|
||||||
|
amis()->GroupControl()->mode('horizontal')->body([
|
||||||
|
amisMake()->TextControl()
|
||||||
|
->name('name')
|
||||||
|
->label(__('agreement.name'))
|
||||||
|
->columnRatio(3)
|
||||||
|
->clearable(),
|
||||||
|
amisMake()->TextControl()->name('employee_search')
|
||||||
|
->label(__('agreement.employee_id'))
|
||||||
|
->placeholder(__('employee.name').'/'.__('employee.phone'))
|
||||||
|
->columnRatio(3)
|
||||||
|
->clearable(),
|
||||||
|
amisMake()->DateRangeControl()
|
||||||
|
->name('date_range')
|
||||||
|
->label(__('agreement.created_at'))
|
||||||
|
->columnRatio(3)
|
||||||
|
->clearable(),
|
||||||
|
]),
|
||||||
|
]))
|
||||||
->columns([
|
->columns([
|
||||||
amisMake()->TableColumn()->name('id')->label(__('agreement.id')),
|
amisMake()->TableColumn()->name('id')->label(__('agreement.id')),
|
||||||
amisMake()->TableColumn()->name('name')->label(__('agreement.name')),
|
amisMake()->TableColumn()->name('name')->label(__('agreement.name')),
|
||||||
amisMake()->TableColumn()->name('employee.name')->label(__('agreement.employee_id')),
|
amisMake()->TableColumn()->name('employee.name')->label(__('agreement.employee_id')),
|
||||||
amisMake()->TableColumn()->name('created_at')->label(__('agreement.created_at')),
|
|
||||||
amisMake()->TableColumn()->name('workflow.check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()),
|
amisMake()->TableColumn()->name('workflow.check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()),
|
||||||
|
amisMake()->TableColumn()->name('created_at')->label(__('agreement.created_at')),
|
||||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||||
$this->rowShowTypeButton('drawer', 'xl')->visible($user->can('admin.agreement.view')),
|
$this->rowShowTypeButton('drawer', 'xl')
|
||||||
$this->rowEditTypeButton('drawer', 'xl')->visible($user->can('admin.agreement.update')),
|
->visible($user->can('admin.agreement.view')),
|
||||||
$this->rowDeleteButton()->visible($user->can('admin.agreement.delete')),
|
$this->rowEditTypeButton('drawer', 'xl')
|
||||||
|
->visible($user->can('admin.agreement.update'))
|
||||||
|
->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'),
|
||||||
|
$this->rowDeleteButton()
|
||||||
|
->visible($user->can('admin.agreement.delete'))
|
||||||
|
->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'),
|
||||||
$this->applyAction(),
|
$this->applyAction(),
|
||||||
$this->cancelAction(),
|
$this->cancelAction(),
|
||||||
amisMake()->AjaxAction()
|
amisMake()->AjaxAction()
|
||||||
|
|
|
||||||
|
|
@ -56,29 +56,54 @@ class WorkflowController extends AdminController
|
||||||
return $this->baseList($crud);
|
return $this->baseList($crud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$this->isCreate = true;
|
||||||
|
|
||||||
|
$form = amis()->Card()
|
||||||
|
->className('base-form')
|
||||||
|
->header(['title' => __('admin.create')])
|
||||||
|
->toolbar([$this->backButton()])
|
||||||
|
->body($this->form(false)->api($this->getStorePath()));
|
||||||
|
|
||||||
|
$page = $this->basePage()->id('workflow-form-page')->body($form);
|
||||||
|
|
||||||
|
return $this->response()->success($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$this->isEdit = true;
|
||||||
|
|
||||||
|
if ($this->actionOfGetData()) {
|
||||||
|
return $this->response()->success($this->service->getEditData($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = amis()->Card()
|
||||||
|
->className('base-form')
|
||||||
|
->header(['title' => __('admin.edit')])
|
||||||
|
->toolbar([$this->backButton()])
|
||||||
|
->body(
|
||||||
|
$this->form(true)->api($this->getUpdatePath())->initApi($this->getEditGetDataPath())
|
||||||
|
);
|
||||||
|
|
||||||
|
$page = $this->basePage()->id('workflow-form-page')->body($form);
|
||||||
|
|
||||||
|
return $this->response()->success($page);
|
||||||
|
}
|
||||||
|
|
||||||
public function form($edit): Form
|
public function form($edit): Form
|
||||||
{
|
{
|
||||||
return $this->baseForm()->title('')->body([
|
return $this->baseForm()->title('')->body([
|
||||||
amisMake()->TextControl()->name('key')->label(__('workflow.key'))->required(),
|
amisMake()->TextControl()->name('key')->label(__('workflow.key'))->required(),
|
||||||
amisMake()->TextControl()->name('name')->label(__('workflow.name'))->required(),
|
amisMake()->TextControl()->name('name')->label(__('workflow.name'))->required(),
|
||||||
amisMake()->ArrayControl()->name('config')->label(__('workflow.config'))->items(amisMake()->ComboControl()->items([
|
amisMake()->TableControl()->name('config')->label(__('workflow.config'))->showIndex()->addable()->removable()->needConfirm(false)->draggable()->columns([
|
||||||
amisMake()->SelectControl()->options(CheckType::options())->name('type')->label(__('workflow.type')),
|
amisMake()->SelectControl()->options(CheckType::options())->name('type')->label(__('workflow.type')),
|
||||||
amisMake()->SelectControl()
|
amisMake()->SelectControl()
|
||||||
->options($this->getJobOptions())
|
->source(admin_url('api/workflow/value-options?type=${type}'))
|
||||||
->labelField('name')
|
->name('value')
|
||||||
->valueField('key')
|
->label(__('workflow.value')),
|
||||||
->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()),
|
|
||||||
])),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +118,17 @@ class WorkflowController extends AdminController
|
||||||
return $this->baseDetail()->title('')->body($detail);
|
return $this->baseDetail()->title('')->body($detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getValueOptions(Request $request)
|
||||||
|
{
|
||||||
|
$type = $request->input('type');
|
||||||
|
$options = match($type) {
|
||||||
|
CheckType::Job->value => $this->getJobOptions(),
|
||||||
|
CheckType::User->value => $this->getEmployeeOptions(),
|
||||||
|
default => []
|
||||||
|
};
|
||||||
|
return $this->response()->success($options);
|
||||||
|
}
|
||||||
|
|
||||||
public function apply(Request $request)
|
public function apply(Request $request)
|
||||||
{
|
{
|
||||||
$model = WorkflowCheck::findOrFail($request->input('id'));
|
$model = WorkflowCheck::findOrFail($request->input('id'));
|
||||||
|
|
@ -202,7 +238,7 @@ class WorkflowController extends AdminController
|
||||||
public function getJobOptions()
|
public function getJobOptions()
|
||||||
{
|
{
|
||||||
if (! $this->jobOptions) {
|
if (! $this->jobOptions) {
|
||||||
$this->jobOptions = Keyword::where('parent_key', 'job')->get();
|
$this->jobOptions = Keyword::where('parent_key', 'job')->select(['key as value', 'name as label'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->jobOptions;
|
return $this->jobOptions;
|
||||||
|
|
@ -211,7 +247,7 @@ class WorkflowController extends AdminController
|
||||||
public function getEmployeeOptions()
|
public function getEmployeeOptions()
|
||||||
{
|
{
|
||||||
if (! $this->employeeOptions) {
|
if (! $this->employeeOptions) {
|
||||||
$this->employeeOptions = Employee::enable()->get();
|
$this->employeeOptions = Employee::enable()->select(['id as value', 'name as label'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->employeeOptions;
|
return $this->employeeOptions;
|
||||||
|
|
|
||||||
|
|
@ -224,12 +224,8 @@ class WorkFlowService extends BaseService
|
||||||
CheckType::User->value => CheckType::User->text(),
|
CheckType::User->value => CheckType::User->text(),
|
||||||
};
|
};
|
||||||
$item['subTitle'] = match ($item['type']) {
|
$item['subTitle'] = match ($item['type']) {
|
||||||
CheckType::Job->value => Keyword::where('key', $item['job'])->value('name'),
|
CheckType::Job->value => Keyword::where('key', $item['value'])->value('name'),
|
||||||
CheckType::User->value => Employee::where('id', $item['user'])->value('name'),
|
CheckType::User->value => Employee::where('id', $item['value'])->value('name'),
|
||||||
};
|
|
||||||
$item['value'] = match ($item['type']) {
|
|
||||||
CheckType::Job->value => $item['job'],
|
|
||||||
CheckType::User->value => $item['user'],
|
|
||||||
};
|
};
|
||||||
$item['sort'] = $key + 1;
|
$item['sort'] = $key + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@ Route::group([
|
||||||
$router->get('employee-sign-logs', [SignLogController::class, 'shareList']);
|
$router->get('employee-sign-logs', [SignLogController::class, 'shareList']);
|
||||||
$router->get('keywords/tree-list', [KeywordController::class, 'getTreeList'])->name('api.keywords.tree-list');
|
$router->get('keywords/tree-list', [KeywordController::class, 'getTreeList'])->name('api.keywords.tree-list');
|
||||||
|
|
||||||
|
$router->get('workflow/value-options', [WorkflowController::class, 'getValueOptions']);
|
||||||
$router->post('workflow/apply', [WorkflowController::class, 'apply']);
|
$router->post('workflow/apply', [WorkflowController::class, 'apply']);
|
||||||
$router->post('workflow/cancel', [WorkflowController::class, 'cancel']);
|
$router->post('workflow/cancel', [WorkflowController::class, 'cancel']);
|
||||||
$router->post('workflow/success', [WorkflowController::class, 'success']);
|
$router->post('workflow/success', [WorkflowController::class, 'success']);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ class Workflow extends Model
|
||||||
protected $fillable = ['key', 'name', 'config'];
|
protected $fillable = ['key', 'name', 'config'];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
// [{type, value, sort, title, subTitle}]
|
||||||
'config' => 'array',
|
'config' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue