generated from liutk/owl-admin-base
97 lines
5.1 KiB
PHP
97 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\Hr;
|
|
|
|
use App\Admin\Controllers\AdminController;
|
|
use App\Admin\Services\EmployeeSignService;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use App\Enums\{SignType, SignStatus, SignTime};
|
|
|
|
/**
|
|
* 考勤打卡
|
|
*/
|
|
class SignController extends AdminController
|
|
{
|
|
protected string $serviceName = EmployeeSignService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->bulkActions([])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->SelectControl()->source(admin_url('api/stores?_all=1'))->labelField('title')->valueField('id')->searchable()->name('store_id')->label(__('employee_sign.store_id'))->columnRatio(3)->clearable(),
|
|
amisMake()->TextControl()->name('employee_name')->label(__('employee_sign.employee_id'))->placeholder(__('employee.name').'/'.__('employee.phone'))->columnRatio(3)->clearable(),
|
|
amisMake()->SelectControl()->options(SignType::options())->name('sign_type')->label(__('employee_sign.sign_type'))->columnRatio(3)->clearable(),
|
|
amisMake()->SelectControl()->options(SignStatus::options())->name('sign_status')->label(__('employee_sign.sign_status'))->columnRatio(3)->clearable(),
|
|
]),
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->DateRangeControl()->name('date_range')->label(__('employee_sign.date'))->columnRatio(3)->clearable(),
|
|
]),
|
|
]))
|
|
->columns([
|
|
amisMake()->TableColumn()->name('date')->label(__('employee_sign.date')),
|
|
amisMake()->TableColumn()->name('store.title')->label(__('employee_sign.store_id')),
|
|
amisMake()->TableColumn()->name('employee.name')->label(__('employee.name')),
|
|
amisMake()->TableColumn()->name('sign_type')->label(__('employee_sign.sign_type'))
|
|
->set('type', 'status')
|
|
->source(SignType::source()),
|
|
amisMake()->TableColumn()->name('first_time')->label(__('employee_sign.first_time')),
|
|
amisMake()->TableColumn()->name('last_time')->label(__('employee_sign.last_time')),
|
|
amisMake()->TableColumn()->name('sign_status')->label(__('employee_sign.sign_status'))
|
|
->set('type', 'status')
|
|
->source(SignStatus::source()),
|
|
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign.remarks')),
|
|
$this->rowActions([
|
|
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.signs.view')),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
$detail = amisMake()->Property()->items([
|
|
['label' => __('employee_sign.date'), 'content' => '${date}'],
|
|
['label' => __('employee_sign.store_id'), 'content' => '${store.title}'],
|
|
['label' => __('employee.name'), 'content' => '${employee.name}'],
|
|
|
|
['label' => __('employee_sign.sign_status'), 'content' => amisMake()->Mapping()->name('sign_status')->map(SignStatus::options())],
|
|
['label' => __('employee_sign.sign_type'), 'content' => amisMake()->Mapping()->name('sign_type')->map(SignType::options())],
|
|
['label' => __('employee_sign.remarks'), 'content' => '${remarks}'],
|
|
|
|
['label' => __('employee_sign.first_time'), 'content' => '${first_time}'],
|
|
['label' => __('employee_sign.last_time'), 'content' => '${last_time}', 'span' => 2],
|
|
]);
|
|
$logs = amisMake()->Service()
|
|
->id('employee-sign-log-table')
|
|
->initFetch(false)
|
|
->api(
|
|
amisMake()->BaseApi()->method('get')->url(admin_url('api/employee-sign-logs'))->data(['date' => '${date}', 'employee_id' => '${employee_id}'])
|
|
)
|
|
->body(
|
|
amisMake()->Table()->columns([
|
|
amisMake()->TableColumn()->name('sign_time')->label(__('employee_sign_log.sign_time'))->set('type', 'mapping')->map(SignTime::options()),
|
|
amisMake()->TableColumn()->name('time')->label(__('employee_sign_log.time')),
|
|
amisMake()->TableColumn()->name('sign_type')->label(__('employee_sign_log.sign_type'))->set('type', 'mapping')->map(SignType::options()),
|
|
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign_log.remarks')),
|
|
amisMake()->TableColumn()->name('position.address')->label(__('employee_sign_log.position')),
|
|
])
|
|
);
|
|
return $this->baseDetail()->title('')->onEvent([
|
|
'inited' => [
|
|
'actions' => [
|
|
['actionType' => 'reload', 'componentId' => 'employee-sign-log-table'],
|
|
]
|
|
]
|
|
])->body([$detail, amisMake()->Divider()->title(__('employee_sign.log')), $logs]);
|
|
}
|
|
}
|