generated from liutk/owl-admin-base
126 lines
6.4 KiB
PHP
126 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\Hr;
|
|
|
|
use App\Admin\Controllers\AdminController;
|
|
use App\Admin\Services\EmployeeSignService;
|
|
use App\Enums\SignStatus;
|
|
use App\Enums\SignTime;
|
|
use App\Enums\SignType;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
|
|
/**
|
|
* 考勤打卡
|
|
*/
|
|
class SignController extends AdminController
|
|
{
|
|
protected string $serviceName = EmployeeSignService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
...$this->baseHeaderToolBar(),
|
|
$this->exportAction(true),
|
|
])
|
|
->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_search')->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(),
|
|
]),
|
|
]))
|
|
->filterDefaultVisible()
|
|
->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_sign.employee_id')),
|
|
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')),
|
|
$this->rowDeleteButton()->visible(Admin::user()->can('admin.hr.signs.delete')),
|
|
]),
|
|
]);
|
|
|
|
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()->columnsTogglable(false)->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')->label(__('employee_sign_log.position'))->set('tpl', '经度:${position.lon},纬度:${position.lat}'),
|
|
amisMake()->TableColumn()->name('is_repair')->label(__('employee_sign_log.is_repair'))->set('type', 'mapping')->map(['否', '是']),
|
|
])
|
|
);
|
|
|
|
return $this->baseDetail()->title('')->onEvent([
|
|
'inited' => [
|
|
'actions' => [
|
|
['actionType' => 'reload', 'componentId' => 'employee-sign-log-table'],
|
|
],
|
|
],
|
|
])->body([$detail, amisMake()->Divider()->title(__('employee_sign.log')), $logs]);
|
|
}
|
|
|
|
protected function exportFileName()
|
|
{
|
|
return '考勤打卡';
|
|
}
|
|
|
|
protected function exportMap($row)
|
|
{
|
|
$type = SignType::options();
|
|
$status = SignStatus::options();
|
|
|
|
return [
|
|
__('employee_sign.date') => data_get($row, 'date'),
|
|
__('employee_sign.store_id') => data_get($row, 'store.title'),
|
|
__('employee_sign.employee_id') => data_get($row, 'employee.name'),
|
|
__('employee_sign.sign_type') => data_get($type, data_get($row, 'sign_type')),
|
|
__('employee_sign.first_time') => data_get($row, 'first_time'),
|
|
__('employee_sign.last_time') => data_get($row, 'last_time'),
|
|
__('employee_sign.sign_status') => data_get($status, data_get($row, 'sign_status')),
|
|
__('employee_sign.remarks') => data_get($row, 'remarks'),
|
|
];
|
|
}
|
|
}
|