添加人口详情查看

main
vine_liutk 2024-02-20 18:18:45 +08:00
parent b7050a1918
commit c1cc36d27a
2 changed files with 63 additions and 0 deletions

View File

@ -10,6 +10,11 @@ use App\Services\Admin\PersonService;
use App\Traits\CustomActionTrait;
use App\Models\Keyword;
use App\Admin\Components;
use Slowlyo\OwlAdmin\Renderers\Drawer;
use Slowlyo\OwlAdmin\Renderers\Dialog;
use Slowlyo\OwlAdmin\Renderers\DrawerAction;
use Slowlyo\OwlAdmin\Renderers\DialogAction;
use Slowlyo\OwlAdmin\Renderers\LinkAction;
/**
* 人口管理
@ -64,6 +69,7 @@ class PersonController extends AdminController
amis()->TableColumn('now_address', __('admin.persons.now_address'))->copyable(),
amisMake()->Operation()->label(__('admin.actions'))->buttons([
$this->rowShowTypeButton('drawer', 'xl'),
$this->rowEditTypeButton('drawer', '', '50%'),
$this->rowDeleteButton(),
])
@ -226,4 +232,25 @@ class PersonController extends AdminController
]),
]);
}
public function detail()
{
$form = amisMake()->form()->title('')->panelClassName('border-0')->mode('horizontal')
->static(true)->actions([])
->body([
amis()->FieldSetControl()->title('基本信息')->body([
amis()->GroupControl()->body([
Components::make()->cropImageControl('avatar', __('admin.persons.avatar')),
]),
amis()->GroupControl()->body([
amis()->TextControl('name', __('admin.persons.name'))->required(),
amis()->TextControl('used_name', __('admin.persons.used_name')),
]),
]),
]);
return amisMake()->Grid()->columns([
amis()->Column()->body($form)->md(6)
]);
}
}

View File

@ -96,4 +96,40 @@ trait CustomActionTrait
return $button->label(__('admin.edit'))->icon('fa-regular fa-pen-to-square')->level('link');
}
/**
* 行详情按钮
*
* @param string $type
* @param string $size
* @param string $width
*
* @return DialogAction|DrawerAction|LinkAction
*/
protected function rowShowTypeButton(string $type = '', string $size = '', string $width = ''): DialogAction|DrawerAction|LinkAction
{
switch ($type) {
case 'drawer':
$drawer = Drawer::make()->title(__('admin.show'))->body($this->detail('$id'))->closeOnOutside();
if($width){
$drawer->width($width);
}else{
$drawer->size($size);
}
$button = DrawerAction::make()->drawer($drawer);
break;
case 'dialog':
$button = DialogAction::make()->dialog(
Dialog::make()->title(__('admin.show'))->body($this->detail('$id'))->size($size)
);
break;
default:
$button = LinkAction::make()->link($this->getShowPath());
break;
}
return $button->label(__('admin.show'))->icon('fa-regular fa-eye')->level('link');
}
}