generated from liutk/owl-admin-base
调整新增弹窗方式
parent
62b994c3ea
commit
6c787ec15f
|
|
@ -11,6 +11,7 @@ use App\Services\Admin\AdService;
|
|||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use App\Models\Ad;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
/**
|
||||
* 广告管理
|
||||
|
|
@ -19,13 +20,15 @@ use App\Models\Ad;
|
|||
*/
|
||||
class AdController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = AdService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
$this->createButton(),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||
|
|
@ -59,7 +62,7 @@ class AdController extends AdminController
|
|||
amis()->TableColumn('is_enable', __('admin.ads.is_enable'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
Operation::make()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ namespace App\Admin\Controllers;
|
|||
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminRoleController as AdminRoleBaseController;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class AdminRoleController extends AdminRoleBaseController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filterTogglable(false)
|
||||
|
|
@ -32,7 +35,7 @@ class AdminRoleController extends AdminRoleBaseController
|
|||
->sortable(true),
|
||||
amis()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->setPermission()->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowEditButton(true)->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowEditTypeButton('drawer', 'md')->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowDeleteButton()->visibleOn('${slug != "administrator"}'),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,19 +10,22 @@ use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|||
use App\Services\Admin\AdminUserService;
|
||||
use Slowlyo\OwlAdmin\Services\AdminRoleService;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
/**
|
||||
* @property AdminUserService $service
|
||||
*/
|
||||
class AdminUserController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = AdminUserService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->body(
|
||||
|
|
@ -43,7 +46,7 @@ class AdminUserController extends AdminController
|
|||
amisMake()->TableColumn('lock', __('admin.admin_user.lock'))->quickEdit(SwitchControl::make()->saveImmediately(true)->mode('inline')->disabledOn('${id === 1}')),
|
||||
amisMake()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
Operation::make()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true)->visibleOn('${id != 1}'),
|
||||
$this->rowEditTypeButton('drawer', 'md')->visibleOn('${id != 1}'),
|
||||
//单独修改密码
|
||||
$this->editPassword()->visibleOn('${id != 1}'),
|
||||
$this->rowDeleteButton()->visibleOn('${id != 1}'),
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|||
use App\Services\Admin\ArticleCategoryService;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class ArticleCategoryController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = ArticleCategoryService::class;
|
||||
|
||||
public function list(): Page
|
||||
|
|
@ -21,7 +24,7 @@ class ArticleCategoryController extends AdminController
|
|||
->footerToolbar([])
|
||||
//去掉分页-end
|
||||
->headerToolbar([
|
||||
$this->createButton(true, 'md'),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -40,7 +43,7 @@ class ArticleCategoryController extends AdminController
|
|||
amis()->TableColumn('sort', __('admin.article_categories.sort')),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true, 'md'),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,16 +10,18 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|||
use App\Services\Admin\ArticleService;
|
||||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class ArticleController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = ArticleService::class;
|
||||
|
||||
public function list():Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
$this->createButton(),
|
||||
$this->createTypeButton('drawer', 'xl'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->body([
|
||||
|
|
@ -67,7 +69,7 @@ class ArticleController extends AdminController
|
|||
amis()->TableColumn('is_recommend', __('admin.articles.is_recommend'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amis()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(),
|
||||
$this->rowEditTypeButton('drawer', 'xl'),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,16 +11,18 @@ use App\Services\Admin\BuildingService;
|
|||
use App\Models\Keyword;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class BuildingController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = BuildingService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -40,7 +42,7 @@ class BuildingController extends AdminController
|
|||
TableColumn::make()->name('sort')->label('排序'),
|
||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,16 +9,18 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|||
use App\Services\Admin\FriendLinkService;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class FriendLinkController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = FriendLinkService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true, 'md'),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -35,7 +37,7 @@ class FriendLinkController extends AdminController
|
|||
amis()->TableColumn('is_enable', __('admin.friend_links.is_enable'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true, 'md'),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,16 +10,18 @@ use App\Services\Admin\InstitutionService;
|
|||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class InstitutionController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = InstitutionService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true, 'md'),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -38,7 +40,7 @@ class InstitutionController extends AdminController
|
|||
amis()->TableColumn('sort', __('admin.institutions.sort')),
|
||||
// amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true, 'md'),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ use App\Services\Admin\KeywordService;
|
|||
use App\Models\Keyword;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class KeywordController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = KeywordService::class;
|
||||
|
||||
protected array $menuData = ['financial_cate', 'file_cate', 'department', 'area_cate', 'organized_body', 'housing_estate', 'domicile', 'nation', 'political_face','educational_level','oral_disputes','sanitary_inspection', 'book_cate', 'business_area','money_cate', 'welfare_cate', 'job_cate'];
|
||||
|
|
@ -45,7 +47,7 @@ class KeywordController extends AdminController
|
|||
->footerToolbar([])
|
||||
// //去掉分页-end
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -63,7 +65,7 @@ class KeywordController extends AdminController
|
|||
TableColumn::make()->name('sort')->label('排序'),
|
||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
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;
|
||||
|
||||
trait CustomActionTrait
|
||||
{
|
||||
/**
|
||||
* 新增按钮
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $size
|
||||
*
|
||||
* @return DialogAction|DrawerAction|LinkAction
|
||||
*/
|
||||
protected function createTypeButton(string $type = '', string $size = ''): DialogAction|DrawerAction|LinkAction
|
||||
{
|
||||
switch ($type) {
|
||||
case 'drawer':
|
||||
$form = $this->form(false)->api($this->getStorePath())->onEvent([]);
|
||||
|
||||
$button = DrawerAction::make()->drawer(
|
||||
Drawer::make()->title(__('admin.create'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
case 'dialog':
|
||||
$form = $this->form(false)->api($this->getStorePath())->onEvent([]);
|
||||
|
||||
$button = DialogAction::make()->dialog(
|
||||
Dialog::make()->title(__('admin.create'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$button = LinkAction::make()->link($this->getCreatePath());
|
||||
break;
|
||||
}
|
||||
|
||||
return $button->label(__('admin.create'))->icon('fa fa-add')->level('primary');
|
||||
}
|
||||
|
||||
/**
|
||||
* 行编辑按钮
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $size
|
||||
*
|
||||
* @return DialogAction|DrawerAction|LinkAction
|
||||
*/
|
||||
protected function rowEditTypeButton(string $type = '', string $size = ''): DialogAction|DrawerAction|LinkAction
|
||||
{
|
||||
switch ($type) {
|
||||
case 'drawer':
|
||||
$form = $this->form(true)
|
||||
->api($this->getUpdatePath())
|
||||
->initApi($this->getEditGetDataPath())
|
||||
->redirect('')
|
||||
->onEvent([]);
|
||||
|
||||
$button = DrawerAction::make()->drawer(
|
||||
Drawer::make()->title(__('admin.edit'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
case 'dialog':
|
||||
$form = $this->form(true)
|
||||
->api($this->getUpdatePath())
|
||||
->initApi($this->getEditGetDataPath())
|
||||
->redirect('')
|
||||
->onEvent([]);
|
||||
|
||||
$button = DialogAction::make()->dialog(
|
||||
Dialog::make()->title(__('admin.edit'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$button = LinkAction::make()->link($this->getEditPath());
|
||||
break;
|
||||
}
|
||||
|
||||
return $button->label(__('admin.edit'))->icon('fa-regular fa-pen-to-square')->level('link');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue