generated from liutk/owl-admin-base
151 lines
6.8 KiB
PHP
151 lines
6.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\Hr;
|
|
|
|
use App\Admin\Controllers\AdminController;
|
|
use App\Admin\Services\OvertimeApplyService;
|
|
use App\Enums\CheckStatus;
|
|
use App\Enums\EmployeeStatus;
|
|
use App\Traits\HasCheckActions;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
|
|
/**
|
|
* 加班管理
|
|
*/
|
|
class OvertimeController extends AdminController
|
|
{
|
|
use HasCheckActions;
|
|
|
|
protected string $serviceName = OvertimeApplyService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
// $this->createTypeButton('drawer', 'lg')->visible(Admin::user()->can('admin.hr.overtime.create')),
|
|
...$this->baseHeaderToolBar(),
|
|
$this->exportAction(true),
|
|
])
|
|
->bulkActions([])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->SelectControl()->name('store_id')->label(__('overtime_apply.store_id'))
|
|
->source(admin_url('api/stores?_all=1'))
|
|
->labelField('title')
|
|
->valueField('id')
|
|
->searchable()
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->TextControl()->name('employee_name')->label(__('overtime_apply.employee_id'))
|
|
->placeholder(__('employee.name').'/'.__('employee.phone'))
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->DateRangeControl()->name('date_range')->label(__('overtime_apply.date'))
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
amisMake()->SelectControl()->name('check_status')->label(__('overtime_apply.check_status'))
|
|
->options(CheckStatus::options())
|
|
->columnRatio(3)
|
|
->clearable(),
|
|
]),
|
|
]))
|
|
->filterDefaultVisible()
|
|
->columns([
|
|
amisMake()->TableColumn()->name('store.title')->label(__('overtime_apply.store_id')),
|
|
amisMake()->TableColumn()->name('employee.name')->label(__('overtime_apply.employee_id')),
|
|
amisMake()->TableColumn()->name('date')->label(__('overtime_apply.date')),
|
|
amisMake()->TableColumn()->name('hours')->label(__('overtime_apply.hours')),
|
|
amisMake()->TableColumn()->name('workflow.check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()),
|
|
amisMake()->TableColumn()->name('workflow.check_name')->label(__('workflow.value')),
|
|
amisMake()->TableColumn()->name('created_at')->label(__('overtime_apply.created_at')),
|
|
$this->rowActions([
|
|
$this->rowShowButton()->visibleOn('${ARRAYINCLUDES(row_actions, "view")}'),
|
|
// $this->rowEditTypeButton('drawer', 'lg')->visibleOn('${ARRAYINCLUDES(row_actions, "edit")}'),
|
|
$this->rowDeleteButton()->visibleOn('${ARRAYINCLUDES(row_actions, "delete")}'),
|
|
$this->applyAction()->visibleOn('${ARRAYINCLUDES(row_actions, "apply")}'),
|
|
// $this->cancelAction()->visibleOn('${ARRAYINCLUDES(row_actions, "cancel")}'),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form($edit): Form
|
|
{
|
|
return $this->baseForm()->title('')->body([
|
|
amisMake()->SelectControl()->name('employee_id')->label(__('overtime_apply.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()->InputDatetimeRange()
|
|
->name('datetime_range')
|
|
->label(__('overtime_apply.date'))
|
|
->required(),
|
|
amisMake()->TextControl()->name('reason')->label(__('overtime_apply.reason')),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
$detailId = 'overtime-detail';
|
|
$serviceId = 'overtime-checklog-service';
|
|
|
|
$detail = amisMake()->Property()->items([
|
|
['label' => __('overtime_apply.store_id'), 'content' => '${store.title}'],
|
|
['label' => __('overtime_apply.employee_id'), 'content' => '${employee.name}'],
|
|
['label' => __('overtime_apply.created_at'), 'content' => '${created_at}'],
|
|
['label' => __('overtime_apply.date'), 'content' => [
|
|
amisMake()->Tag()->label('${date}'),
|
|
amisMake()->Tag()->label('${start_at}'),
|
|
amisMake()->Tag()->label('${end_at}'),
|
|
], 'span' => 2],
|
|
['label' => __('overtime_apply.hours'), 'content' => '${hours}'],
|
|
['label' => __('overtime_apply.reason'), 'content' => '${reason}', 'span' => 3],
|
|
['label' => __('workflow_log.check_status'), 'content' => amisMake()->Mapping()->name('workflow.check_status')->map(CheckStatus::options())],
|
|
['label' => __('workflow_log.checked_at'), 'content' => '${workflow.checked_at}'],
|
|
['label' => __('workflow_log.remarks'), 'content' => '${workflow.check_remarks}'],
|
|
]);
|
|
|
|
return $this->baseDetail()->id($detailId)->title('')->onEvent([
|
|
'inited' => [
|
|
'actions' => [
|
|
['actionType' => 'reload', 'componentId' => $serviceId],
|
|
],
|
|
],
|
|
])->body([
|
|
$detail,
|
|
amisMake()->Divider(),
|
|
$this->baseWorkflowLogList($detailId)->id($serviceId),
|
|
]);
|
|
}
|
|
|
|
protected function exportFileName()
|
|
{
|
|
return '加班申请';
|
|
}
|
|
|
|
protected function exportMap($row)
|
|
{
|
|
return [
|
|
__('overtime_apply.id') => data_get($row, 'id'),
|
|
__('overtime_apply.store_id') => data_get($row, 'store.title'),
|
|
__('overtime_apply.employee_id') => data_get($row, 'employee.name'),
|
|
__('overtime_apply.date') => data_get($row, 'date'),
|
|
__('overtime_apply.start_at') => data_get($row, 'start_at'),
|
|
__('overtime_apply.end_at') => data_get($row, 'end_at'),
|
|
__('overtime_apply.hours') => data_get($row, 'hours'),
|
|
__('overtime_apply.reason') => data_get($row, 'reason'),
|
|
__('workflow_log.check_status') => data_get(CheckStatus::options(), data_get($row, 'workflow.check_status'), ''),
|
|
__('workflow.value') => data_get($row, 'workflow.check_name'),
|
|
__('overtime_apply.created_at') => data_get($row, 'created_at'),
|
|
];
|
|
}
|
|
}
|