81 lines
2.8 KiB
PHP
81 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Services\UserService;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
|
|
/**
|
|
* 用户管理
|
|
*
|
|
* @property UserService $service
|
|
*/
|
|
class UserController extends AdminController
|
|
{
|
|
protected string $serviceName = UserService::class;
|
|
|
|
public function list()
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->columnsTogglable(false)
|
|
->headerToolbar([
|
|
$this->createButton('drawer', 'lg')->permission('admin.users.create'),
|
|
...$this->baseHeaderToolBar(),
|
|
$this->exportAction(),
|
|
])
|
|
->bulkActions([
|
|
$this->bulkDeleteButton()->permission('admin.users.delete')
|
|
])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amis()->TextControl()->name('search')->label(__('admin.search'))->placeholder(__('users.phone').'/'.__('users.name'))->columnRatio(3)->clearable(),
|
|
amis()->DateRangeControl()->name('created_range')->label(__('users.created_at'))->columnRatio(3)->clearable(),
|
|
])
|
|
]))
|
|
->columns([
|
|
amis()->TableColumn()->name('id')->label(__('admin.id')),
|
|
amis()->TableColumn()->name('avatar')->label(__('users.avatar'))->type('avatar')->src('${avatar}'),
|
|
amis()->TableColumn()->name('phone')->label(__('users.phone')),
|
|
amis()->TableColumn()->name('name')->label(__('users.name')),
|
|
amis()->TableColumn()->name('created_at')->label(__('users.created_at')),
|
|
$this->rowActions([
|
|
$this->rowShowButton('drawer', 'lg')->permission('admin.users.show'),
|
|
$this->rowEditButton('drawer', 'lg')->permission('admin.users.edit'),
|
|
$this->rowDeleteButton()->permission('admin.users.delete'),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form()
|
|
{
|
|
return $this->baseForm()->mode('horizontal')->body([
|
|
amis()->ImageControl()->name('avatar')->label(__('users.avatar')),
|
|
amis()->TextControl()->name('phone')->label(__('users.phone'))->required(),
|
|
amis()->TextControl()->name('name')->label(__('users.name')),
|
|
]);
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
return $this->baseDetail()->body(amis()->Property()->column(2)->items([
|
|
['label' => __('users.avatar'), 'content' => amis()->Avatar()->src('${avatar}')],
|
|
['label' => __('users.phone'), 'content' => '${phone}'],
|
|
['label' => __('users.name'), 'content' => '${name}'],
|
|
['label' => __('users.created_at'), 'content' => '${created_at}'],
|
|
]));
|
|
}
|
|
|
|
protected function exportMap($row)
|
|
{
|
|
return [
|
|
__('admin.id') => $row['id'],
|
|
__('users.avatar') => $row['avatar'],
|
|
__('users.phone') => $row['phone'],
|
|
__('users.name') => $row['name'],
|
|
__('users.created_at') => $row['created_at'],
|
|
];
|
|
}
|
|
} |