generated from liutk/owl-admin-base
137 lines
6.4 KiB
PHP
137 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\Hr;
|
|
|
|
use App\Admin\Controllers\AdminController;
|
|
use App\Admin\Services\EmployeePromotionService;
|
|
use App\Enums\EmployeeStatus;
|
|
use App\Enums\PromotionStatus;
|
|
use App\Traits\HasCheckActions;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
|
|
/**
|
|
* 升职申请
|
|
*/
|
|
class PromotionController extends AdminController
|
|
{
|
|
use HasCheckActions;
|
|
|
|
protected string $serviceName = EmployeePromotionService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
$this->createTypeButton('drawer', 'xl')->visible(Admin::user()->can('admin.hr.promotion.create')),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->bulkActions([])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->SelectControl()->name('store_id')->label(__('employee_promotion.store_id'))
|
|
->source(admin_url('api/stores?_all=1'))
|
|
->labelField('title')
|
|
->valueField('id')
|
|
->searchable()
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->TextControl()->name('employee_search')->label(__('employee_promotion.employee_id'))
|
|
->placeholder(__('employee.name').'/'.__('employee.phone'))
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->SelectControl()->name('job_id')->label(__('employee_promotion.job_id'))
|
|
->source(admin_url('api/keywords/tree-list').'?parent_key=job')
|
|
->labelField('name')
|
|
->valueField('key')
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->TextControl()->name('invitor_search')->label(__('employee_promotion.invitor_id'))
|
|
->placeholder(__('employee.name').'/'.__('employee.phone'))
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
]),
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->SelectControl()->name('promotion_status')->label(__('employee_promotion.promotion_status'))
|
|
->options(PromotionStatus::options())
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
]),
|
|
]))
|
|
->columns([
|
|
amisMake()->TableColumn()->name('store.title')->label(__('employee_promotion.store_id')),
|
|
amisMake()->TableColumn()->name('employee.name')->label(__('employee_promotion.employee_id')),
|
|
amisMake()->TableColumn()->name('job.name')->label(__('employee_promotion.job_id')),
|
|
amisMake()->TableColumn()->name('invitor.name')->label(__('employee_promotion.invitor_id')),
|
|
amisMake()->TableColumn()->name('promotion_status')->label(__('employee_promotion.promotion_status'))->set('type', 'mapping')->map(PromotionStatus::options()),
|
|
amisMake()->TableColumn()->name('created_at')->label(__('employee_promotion.created_at')),
|
|
$this->rowActions([
|
|
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.promotion.view')),
|
|
$this->rowEditTypeButton('drawer', 'xl')
|
|
->visible(Admin::user()->can('admin.hr.promotion.update')),
|
|
$this->rowDeleteButton()
|
|
->visible(Admin::user()->can('admin.hr.promotion.delete')),
|
|
$this->cancelAction()->visibleOn('${promotion_status == '.PromotionStatus::Processing->value.'}'),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form($edit): Form
|
|
{
|
|
return $this->baseForm()->title('')->body([
|
|
amisMake()->SelectControl()->name('employee_id')->label(__('employee_promotion.employee_id'))
|
|
->source(admin_url('api/employees?_all=1&store_id_gt=0&employee_status='.EmployeeStatus::Online->value))
|
|
->labelField('name')
|
|
->valueField('id')
|
|
->searchable()
|
|
->joinValues(false)
|
|
->extractValue()
|
|
->required(),
|
|
amisMake()->SelectControl()->name('invitor_id')->label(__('employee_promotion.invitor_id'))
|
|
->source(admin_url('api/employees?_all=1&store_id_gt=0&employee_status='.EmployeeStatus::Online->value))
|
|
->labelField('name')
|
|
->valueField('id')
|
|
->searchable()
|
|
->joinValues(false)
|
|
->extractValue()
|
|
->required(),
|
|
amisMake()->SelectControl()->name('job_id')->label(__('employee_promotion.job_id'))
|
|
->source(admin_url('api/keywords/tree-list').'?parent_key=job')
|
|
->labelField('name')
|
|
->valueField('key'),
|
|
amisMake()->TextControl()->name('remarks')->label(__('employee_promotion.remarks')),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
$detailId = 'promotion-detail';
|
|
$serviceId = 'promotion-checklog-service';
|
|
|
|
$detail = amisMake()->Property()->items([
|
|
['label' => __('employee_promotion.store_id'), 'content' => '${store.title}'],
|
|
['label' => __('employee_promotion.employee_id'), 'content' => '${employee.name}'],
|
|
['label' => __('employee_promotion.job_id'), 'content' => '${job.name}'],
|
|
['label' => __('employee_promotion.invitor_id'), 'content' => '${invitor.name}'],
|
|
['label' => __('employee_promotion.promotion_status'), 'content' => amisMake()->Mapping()->name('promotion_status')->map(PromotionStatus::options())],
|
|
['label' => __('employee_promotion.remarks'), 'content' => '${remarks}'],
|
|
]);
|
|
|
|
return $this->baseDetail()->id($detailId)->title('')->onEvent([
|
|
'inited' => [
|
|
'actions' => [
|
|
['actionType' => 'reload', 'componentId' => $serviceId],
|
|
],
|
|
],
|
|
])->body([
|
|
$detail,
|
|
amisMake()->Divider(),
|
|
$this->baseWorkflowLogService($detailId)->id($serviceId),
|
|
]);
|
|
}
|
|
}
|