new feature
This commit is contained in:
@@ -59,7 +59,7 @@ return [
|
|||||||
|
|
||||||
'namespace' => 'Modules',
|
'namespace' => 'Modules',
|
||||||
|
|
||||||
'default' => ['develop', 'user'],
|
'default' => ['develop', 'user', 'permission'],
|
||||||
|
|
||||||
'default_dirs' => [
|
'default_dirs' => [
|
||||||
'Http'.DIRECTORY_SEPARATOR,
|
'Http'.DIRECTORY_SEPARATOR,
|
||||||
@@ -82,7 +82,13 @@ return [
|
|||||||
|
|
||||||
// use database driver
|
// use database driver
|
||||||
'table_name' => 'admin_modules'
|
'table_name' => 'admin_modules'
|
||||||
]
|
],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* module routes collection
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'routes' => [],
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -117,19 +123,19 @@ return [
|
|||||||
'providers' => [
|
'providers' => [
|
||||||
'admin_users' => [
|
'admin_users' => [
|
||||||
'driver' => 'eloquent',
|
'driver' => 'eloquent',
|
||||||
'model' => \Modules\User\Models\Users::class
|
'model' => \Modules\User\Models\User::class
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| database sql log
|
| database sql log
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
'listen_db_log' => true,
|
'listen_db_log' => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| route config
|
| route config
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@@ -24,11 +24,6 @@ class Schemas extends CatchModel
|
|||||||
'id', 'module', 'name', 'columns', 'is_soft_delete', 'created_at', 'updated_at'
|
'id', 'module', 'name', 'columns', 'is_soft_delete', 'created_at', 'updated_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected bool $isPaginate = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array|string[]
|
* @var array|string[]
|
||||||
*/
|
*/
|
||||||
|
@@ -18,7 +18,7 @@ class {model} extends Model
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $fieldsInList = [{fieldsInList}];
|
protected array $fields = [{fieldsInList}];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Options\Repository;
|
namespace Modules\Options\Repository;
|
||||||
|
|
||||||
use Catch\CatchAdmin;
|
use Catch\CatchAdmin;
|
||||||
use Catch\Support\Composer;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ class Components implements OptionInterface
|
|||||||
public function get(): array
|
public function get(): array
|
||||||
{
|
{
|
||||||
if ($module = request()->get('module')) {
|
if ($module = request()->get('module')) {
|
||||||
$components = File::glob(CatchAdmin::getModuleViewsPath($module) . '*/*.vue');
|
$components = File::glob(CatchAdmin::getModuleViewsPath($module).'*/*.vue');
|
||||||
|
|
||||||
foreach ($components as $component) {
|
foreach ($components as $component) {
|
||||||
$this->components[] = [
|
$this->components[] = [
|
||||||
@@ -31,10 +30,8 @@ class Components implements OptionInterface
|
|||||||
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
|
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->components;
|
return $this->components;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Options\Repository;
|
namespace Modules\Options\Repository;
|
||||||
|
|
||||||
use Catch\CatchAdmin;
|
use Catch\CatchAdmin;
|
||||||
use Catch\Support\Composer;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ class Controllers implements OptionInterface
|
|||||||
$controllers = [];
|
$controllers = [];
|
||||||
|
|
||||||
if ($module = request()->get('module')) {
|
if ($module = request()->get('module')) {
|
||||||
$controllerFiles = File::glob(CatchAdmin::getModuleControllerPath($module) . '*.php');
|
$controllerFiles = File::glob(CatchAdmin::getModuleControllerPath($module).'*.php');
|
||||||
|
|
||||||
foreach ($controllerFiles as $controllerFile) {
|
foreach ($controllerFiles as $controllerFile) {
|
||||||
$controllers[] = [
|
$controllers[] = [
|
||||||
@@ -23,10 +22,8 @@ class Controllers implements OptionInterface
|
|||||||
'value' => Str::of(File::name($controllerFile))->remove('Controller'),
|
'value' => Str::of(File::name($controllerFile))->remove('Controller'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
29
modules/Permissions/Enums/MenuStatus.php
Normal file
29
modules/Permissions/Enums/MenuStatus.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Permissions\Enums;
|
||||||
|
|
||||||
|
use Catch\Enums\Enum;
|
||||||
|
|
||||||
|
enum MenuStatus: int implements Enum
|
||||||
|
{
|
||||||
|
case Show = 1; // 显示
|
||||||
|
case Hidden = 2; // 隐藏
|
||||||
|
|
||||||
|
public function value(): int
|
||||||
|
{
|
||||||
|
// TODO: Implement value() method.
|
||||||
|
return match ($this) {
|
||||||
|
self::Show => 1,
|
||||||
|
self::Hidden => 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function name(): string
|
||||||
|
{
|
||||||
|
// TODO: Implement name() method.
|
||||||
|
return match ($this) {
|
||||||
|
self::Show => '显示',
|
||||||
|
self::Hidden => '隐藏',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
32
modules/Permissions/Enums/MenuType.php
Normal file
32
modules/Permissions/Enums/MenuType.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Permissions\Enums;
|
||||||
|
|
||||||
|
use Catch\Enums\Enum;
|
||||||
|
|
||||||
|
enum MenuType: int implements Enum
|
||||||
|
{
|
||||||
|
case Top = 1; // 目录
|
||||||
|
case Menu = 2; // 菜单
|
||||||
|
case Action = 3; // 按钮
|
||||||
|
|
||||||
|
public function value(): int
|
||||||
|
{
|
||||||
|
// TODO: Implement value() method.
|
||||||
|
return match ($this) {
|
||||||
|
self::Top => 1,
|
||||||
|
self::Menu => 2,
|
||||||
|
self::Action => 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function name(): string
|
||||||
|
{
|
||||||
|
// TODO: Implement name() method.
|
||||||
|
return match ($this) {
|
||||||
|
self::Top => '目录类型',
|
||||||
|
self::Menu => '菜单类型',
|
||||||
|
self::Action => '按钮类型',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
13
modules/Permissions/Exceptions/PermissionForbidden.php
Normal file
13
modules/Permissions/Exceptions/PermissionForbidden.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Permissions\Exceptions;
|
||||||
|
|
||||||
|
use Catch\Enums\Code;
|
||||||
|
use Catch\Exceptions\CatchException;
|
||||||
|
|
||||||
|
class PermissionForbidden extends CatchException
|
||||||
|
{
|
||||||
|
protected $message = 'permission forbidden';
|
||||||
|
|
||||||
|
protected $code = Code::PERMISSION_FORBIDDEN;
|
||||||
|
}
|
@@ -46,6 +46,6 @@ class DepartmentsController extends Controller
|
|||||||
|
|
||||||
public function enable($id)
|
public function enable($id)
|
||||||
{
|
{
|
||||||
return $this->model->disOrEnable($id);
|
return $this->model->toggleBy($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,6 @@ class JobsController extends Controller
|
|||||||
|
|
||||||
public function enable($id)
|
public function enable($id)
|
||||||
{
|
{
|
||||||
return $this->model->disOrEnable($id);
|
return $this->model->toggleBy($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,6 @@ class PermissionsController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function enable($id)
|
public function enable($id)
|
||||||
{
|
{
|
||||||
return $this->model->disOrEnable($id, 'hidden');
|
return $this->model->toggleBy($id, 'hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
modules/Permissions/Middlewares/PermissionGate.php
Normal file
26
modules/Permissions/Middlewares/PermissionGate.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Permissions\Middlewares;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Permissions\Exceptions\PermissionForbidden;
|
||||||
|
use Modules\User\Models\User;
|
||||||
|
|
||||||
|
class PermissionGate
|
||||||
|
{
|
||||||
|
public function handle(Request $request, \Closure $next)
|
||||||
|
{
|
||||||
|
if ($request->isMethod('get')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @var User $user */
|
||||||
|
$user = $request->user(getGuardName());
|
||||||
|
|
||||||
|
if (! $user->can()) {
|
||||||
|
throw new PermissionForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@@ -26,10 +26,12 @@ class DepartmentsModel extends Model
|
|||||||
|
|
||||||
protected $fillable = ['id', 'parent_id', 'department_name', 'principal', 'mobile', 'email', 'status', 'sort', 'creator_id', 'created_at', 'updated_at', 'deleted_at'];
|
protected $fillable = ['id', 'parent_id', 'department_name', 'principal', 'mobile', 'email', 'status', 'sort', 'creator_id', 'created_at', 'updated_at', 'deleted_at'];
|
||||||
|
|
||||||
|
protected bool $isPaginate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $fieldsInList = ['id','parent_id','department_name','status','sort','created_at'];
|
protected array $fields = ['id','parent_id','department_name','status','sort','created_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@@ -44,8 +46,5 @@ class DepartmentsModel extends Model
|
|||||||
'status' => '=',
|
'status' => '=',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getList(): mixed
|
protected bool $asTree = true;
|
||||||
{
|
|
||||||
return self::query()->select($this->fieldsInList)->quickSearch()->get()->toTree();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ class JobsModel extends Model
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $fieldsInList = ['id','job_name','coding','status','sort','description','created_at','updated_at'];
|
protected array $fields = ['id','job_name','coding','status','sort','description','created_at','updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
|
@@ -5,6 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Modules\Permissions\Models;
|
namespace Modules\Permissions\Models;
|
||||||
|
|
||||||
use Catch\Base\CatchModel as Model;
|
use Catch\Base\CatchModel as Model;
|
||||||
|
use Catch\Enums\Status;
|
||||||
|
use Modules\Permissions\Enums\MenuStatus;
|
||||||
|
use Modules\Permissions\Enums\MenuType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property $id
|
* @property $id
|
||||||
@@ -34,7 +37,9 @@ class PermissionsModel extends Model
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $fieldsInList = ['id','parent_id','permission_name','route','icon','module','permission_mark','component','redirect','keepalive','type','hidden','sort','created_at','updated_at'];
|
protected array $fields = ['id','parent_id','permission_name','route','icon','module','permission_mark','component','redirect','keepalive','type','hidden','sort','created_at','updated_at'];
|
||||||
|
|
||||||
|
protected bool $isPaginate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@@ -48,13 +53,21 @@ class PermissionsModel extends Model
|
|||||||
'permission_name' => 'like',
|
'permission_name' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public function getList(): mixed
|
protected bool $asTree = true;
|
||||||
{
|
|
||||||
return self::query()->select($this->fieldsInList)->quickSearch()->get()->toTree();
|
/**
|
||||||
}
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'type' => MenuType::class,
|
||||||
|
|
||||||
|
'status' => MenuStatus::class
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is hidden
|
* is hidden
|
||||||
@@ -63,6 +76,16 @@ class PermissionsModel extends Model
|
|||||||
*/
|
*/
|
||||||
public function isHidden(): bool
|
public function isHidden(): bool
|
||||||
{
|
{
|
||||||
return $this->hidden === 2;
|
return $this->hidden === Status::Disable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* action type
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isAction(): bool
|
||||||
|
{
|
||||||
|
return $this->type == MenuType::Action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,13 +26,19 @@ class RolesModel extends Model
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $fieldsInList = ['id', 'role_name','identify','parent_id','description','data_range', 'created_at', 'updated_at'];
|
protected array $fields = ['id', 'role_name','identify','parent_id','description','data_range', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $form = ['role_name','identify','parent_id','description','data_range'];
|
protected array $form = ['role_name','identify','parent_id','description','data_range'];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected bool $isPaginate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@@ -41,11 +47,5 @@ class RolesModel extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
protected bool $asTree = true;
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getList(): mixed
|
|
||||||
{
|
|
||||||
return self::query()->select($this->fieldsInList)->quickSearch()->get()->toTree();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -4,9 +4,26 @@ namespace Modules\Permissions\Providers;
|
|||||||
|
|
||||||
use Catch\CatchAdmin;
|
use Catch\CatchAdmin;
|
||||||
use Catch\Providers\CatchModuleServiceProvider;
|
use Catch\Providers\CatchModuleServiceProvider;
|
||||||
|
use Modules\Permissions\Middlewares\PermissionGate;
|
||||||
|
|
||||||
class PermissionsServiceProvider extends CatchModuleServiceProvider
|
class PermissionsServiceProvider extends CatchModuleServiceProvider
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* register permission gate
|
||||||
|
*
|
||||||
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected function registering()
|
||||||
|
{
|
||||||
|
$route = $this->app['config']->get('catch.route');
|
||||||
|
|
||||||
|
$route['middlewares'][] = PermissionGate::class;
|
||||||
|
|
||||||
|
$this->app['config']->set('catch.route', $route);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* route path
|
* route path
|
||||||
*
|
*
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -14,11 +13,11 @@ return new class extends Migration
|
|||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::create('user_has_roles', function (Blueprint $table) {
|
Schema::create('user_has_roles', function (Blueprint $table) {
|
||||||
$table->integer('user_id')->comment('users primary key');
|
$table->integer('user_id')->comment('users primary key');
|
||||||
|
|
||||||
$table->integer('role_id')->comment('roles primary key');
|
$table->integer('role_id')->comment('roles primary key');
|
||||||
|
|
||||||
$table->comment('user relate roles');
|
$table->comment('user relate roles');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +28,5 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -29,6 +28,5 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -29,6 +28,5 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class () extends Migration {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -29,6 +28,5 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
<el-cascader :options="permissions" name="parent_id" v-model="formData.parent_id" clearable :props="{ value: 'id', label: 'permission_name', checkStrictly: true }" class="w-full" />
|
<el-cascader :options="permissions" name="parent_id" v-model="formData.parent_id" clearable :props="{ value: 'id', label: 'permission_name', checkStrictly: true }" class="w-full" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="权限标识" prop="permission_mark" :rules="[{ required: true, message: '权限标识必须填写' }]" v-if="!isTop">
|
<el-form-item label="权限标识" prop="permission_mark" :rules="[{ required: true, message: '权限标识必须填写' }]" v-if="!isTop">
|
||||||
<Select v-model="formData.permission_mark" name="permission_mark" :options="actionMenuNames" allow-create v-if="isAction" />
|
<Select v-model="formData.permission_mark" name="permission_mark" :options="actionMenuMark" allow-create v-if="isAction" />
|
||||||
<Select v-model="formData.permission_mark" placeholder="请选择" api="controllers" :query="{ module: formData.module }" v-else />
|
<Select v-model="formData.permission_mark" placeholder="请选择" api="controllers" :query="{ module: formData.module }" v-else />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="菜单Icon" prop="icon" v-if="!isAction">
|
<el-form-item label="菜单Icon" prop="icon" v-if="!isAction">
|
||||||
|
@@ -31,6 +31,19 @@
|
|||||||
<el-form-item label="角色描述" prop="description">
|
<el-form-item label="角色描述" prop="description">
|
||||||
<el-input v-model="formData.description" name="description" clearable type="textarea" />
|
<el-input v-model="formData.description" name="description" clearable type="textarea" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="选择权限" prop="permissions">
|
||||||
|
<el-tree
|
||||||
|
v-model="formData.permissions"
|
||||||
|
:default-expanded-keys="formData.permissions"
|
||||||
|
:data="permissions"
|
||||||
|
value-key="id"
|
||||||
|
check-strictly
|
||||||
|
class="w-full"
|
||||||
|
:props="{ label: 'permission_name', value: 'id' }"
|
||||||
|
show-checkbox
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="数据权限" prop="data_range">
|
<el-form-item label="数据权限" prop="data_range">
|
||||||
<Select v-model="formData.data_range" name="data_range" clearable api="dataRange" class="w-full" />
|
<Select v-model="formData.data_range" name="data_range" clearable api="dataRange" class="w-full" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -82,11 +95,22 @@ if (props.primary) {
|
|||||||
|
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
const roles = ref()
|
const roles = ref()
|
||||||
|
const permissions = ref()
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
http.get(props.api).then(r => {
|
http.get(props.api).then(r => {
|
||||||
roles.value = r.data.data
|
roles.value = r.data.data
|
||||||
})
|
})
|
||||||
|
|
||||||
close(() => emit('close'))
|
close(() => emit('close'))
|
||||||
|
|
||||||
|
http.get('permissions/permissions').then(r => {
|
||||||
|
permissions.value = r.data.data
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
:deep(.el-tree .el-tree-node__children:last-child) {
|
||||||
|
@apply flex flex-row;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@@ -6,12 +6,12 @@ use Catch\Base\CatchController as Controller;
|
|||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Modules\User\Models\LogLogin;
|
use Modules\User\Models\LogLogin;
|
||||||
use Modules\User\Models\Users;
|
use Modules\User\Models\User;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected readonly Users $user
|
protected readonly User $user
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,18 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return $this->user->firstBy($id)->makeHidden('password');
|
return $this->user->setAfterFirstBy(function (User $user){
|
||||||
|
$relations = array_keys($user->getRelations());
|
||||||
|
if (in_array('roles', $relations)) {
|
||||||
|
$user->setRelations([
|
||||||
|
'roles' => $user->roles->pluck('id'),
|
||||||
|
|
||||||
|
'jobs' => $user->jobs->pluck('id')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
})->firstBy($id)->makeHidden('password');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +89,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function enable($id)
|
public function enable($id)
|
||||||
{
|
{
|
||||||
return $this->user->disOrEnable($id);
|
return $this->user->toggleBy($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +99,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function online(Request $request)
|
public function online(Request $request)
|
||||||
{
|
{
|
||||||
/* @var Users $user */
|
/* @var User $user */
|
||||||
$user = $this->getLoginUser()->withPermissions();
|
$user = $this->getLoginUser()->withPermissions();
|
||||||
|
|
||||||
if ($request->isMethod('post')) {
|
if ($request->isMethod('post')) {
|
||||||
|
@@ -9,7 +9,7 @@ use Illuminate\Support\Str;
|
|||||||
use Illuminate\Support\Stringable;
|
use Illuminate\Support\Stringable;
|
||||||
use Modules\User\Events\Login as Event;
|
use Modules\User\Events\Login as Event;
|
||||||
use Modules\User\Models\LogLogin;
|
use Modules\User\Models\LogLogin;
|
||||||
use Modules\User\Models\Users;
|
use Modules\User\Models\User;
|
||||||
|
|
||||||
class Login
|
class Login
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@ class Login
|
|||||||
$this->log($request, (bool) $event->token);
|
$this->log($request, (bool) $event->token);
|
||||||
|
|
||||||
if ($event->token) {
|
if ($event->token) {
|
||||||
/* @var Users $user */
|
/* @var User $user */
|
||||||
$user = Auth::guard(getGuardName())->user();
|
$user = Auth::guard(getGuardName())->user();
|
||||||
|
|
||||||
$user->login_ip = $request->ip();
|
$user->login_ip = $request->ip();
|
||||||
|
38
modules/User/Models/Observers/UsersObserver.php
Normal file
38
modules/User/Models/Observers/UsersObserver.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\User\Models\Observers;
|
||||||
|
|
||||||
|
use Modules\User\Models\User;
|
||||||
|
|
||||||
|
class UsersObserver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function created(User $user): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function updated(User $user): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function deleted(User $user): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
@@ -1,22 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Modules\User\Models\Traits;
|
|
||||||
|
|
||||||
|
namespace Modules\User\Models\Traits;
|
||||||
|
|
||||||
use Catch\CatchAdmin;
|
use Catch\CatchAdmin;
|
||||||
use Catch\Support\Module\ModuleRepository;
|
use Catch\Support\Module\ModuleRepository;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
trait UserRelations
|
trait UserRelations
|
||||||
{
|
{
|
||||||
|
protected bool $isPermissionModuleEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init traits
|
* init traits
|
||||||
*/
|
*/
|
||||||
public function initializeUserRelations(): void
|
public function initializeUserRelations(): void
|
||||||
{
|
{
|
||||||
if (app(ModuleRepository::class)->enabled('permissions')) {
|
$this->isPermissionModuleEnabled = app(ModuleRepository::class)->enabled('permissions');
|
||||||
$this->with = ['roles', 'jobs'];
|
|
||||||
}
|
if ($this->isPermissionModuleEnabled) {
|
||||||
|
$this->with = ['roles', 'jobs'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,11 +61,42 @@ trait UserRelations
|
|||||||
$permissions = [];
|
$permissions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setAttribute('permissions', $permissions->each(fn($permission) => $permission->setAttribute('hidden', $permission->isHidden())));
|
$this->setAttribute('permissions', $permissions->each(fn ($permission) => $permission->setAttribute('hidden', $permission->isHidden())));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* permission module controller.action
|
||||||
|
*
|
||||||
|
* @param string|null $permission
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function can(string $permission = null): bool
|
||||||
|
{
|
||||||
|
if (! $this->isPermissionModuleEnabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isSuperAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->withPermissions();
|
||||||
|
|
||||||
|
$actions = Collection::make();
|
||||||
|
|
||||||
|
$this->permissions->each(function ($permission) use (&$actions) {
|
||||||
|
if ($permission->isAction()) {
|
||||||
|
[$controller, $action] = explode('@', $permission->permission_mark);
|
||||||
|
|
||||||
|
$actions->add(CatchAdmin::getModuleControllerNamespace($permission->module).$controller.'Controller@'.$action);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $actions->contains($permission ?: Route::currentRouteAction());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get RolesModel
|
* get RolesModel
|
||||||
@@ -70,7 +106,7 @@ trait UserRelations
|
|||||||
*/
|
*/
|
||||||
protected function getRolesModel(): string
|
protected function getRolesModel(): string
|
||||||
{
|
{
|
||||||
return '\\' . CatchAdmin::getModuleModelNamespace('permissions') . 'RolesModel';
|
return '\\'.CatchAdmin::getModuleModelNamespace('permissions').'RolesModel';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +118,7 @@ trait UserRelations
|
|||||||
*/
|
*/
|
||||||
protected function getJobsModel(): string
|
protected function getJobsModel(): string
|
||||||
{
|
{
|
||||||
return '\\'. CatchAdmin::getModuleModelNamespace('permissions') . 'JobsModel';
|
return '\\'.CatchAdmin::getModuleModelNamespace('permissions').'JobsModel';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +129,6 @@ trait UserRelations
|
|||||||
*/
|
*/
|
||||||
protected function getPermissionsModel(): string
|
protected function getPermissionsModel(): string
|
||||||
{
|
{
|
||||||
return '\\'. CatchAdmin::getModuleModelNamespace('permissions') . 'PermissionsModel';
|
return '\\'.CatchAdmin::getModuleModelNamespace('permissions').'PermissionsModel';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,12 +23,12 @@ use Illuminate\Auth\Authenticatable;
|
|||||||
* @property int $updated_at
|
* @property int $updated_at
|
||||||
* @property string $remember_token
|
* @property string $remember_token
|
||||||
*/
|
*/
|
||||||
class Users extends Model implements AuthenticatableContract, JWTSubject
|
class User extends Model implements AuthenticatableContract, JWTSubject
|
||||||
{
|
{
|
||||||
use Authenticatable, UserRelations;
|
use Authenticatable, UserRelations;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id', 'username', 'email', 'avatar', 'password', 'remember_token', 'creator_id', 'status', 'login_ip', 'login_at', 'created_at', 'updated_at', 'deleted_at'
|
'id', 'username', 'email', 'avatar', 'password', 'remember_token', 'creator_id', 'status', 'department_id', 'login_ip', 'login_at', 'created_at', 'updated_at', 'deleted_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,10 +45,17 @@ class Users extends Model implements AuthenticatableContract, JWTSubject
|
|||||||
*/
|
*/
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
|
|
||||||
|
protected array $fields = ['id', 'username', 'email', 'avatar', 'creator_id', 'status', 'department_id', 'created_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array|string[]
|
* @var array|string[]
|
||||||
*/
|
*/
|
||||||
protected array $form = ['username', 'email', 'password'];
|
protected array $form = ['username', 'email', 'password', 'department_id'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|string[]
|
||||||
|
*/
|
||||||
|
protected array $formRelations = ['roles', 'jobs'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@@ -25,6 +25,8 @@ return new class () extends Migration {
|
|||||||
|
|
||||||
$table->string('remember_token', 1000)->nullable()->comment('token');
|
$table->string('remember_token', 1000)->nullable()->comment('token');
|
||||||
|
|
||||||
|
$table->integer('department_id')->default(0)->comment('部门ID');
|
||||||
|
|
||||||
$table->integer('creator_id')->default(0);
|
$table->integer('creator_id')->default(0);
|
||||||
|
|
||||||
$table->status();
|
$table->status();
|
||||||
|
@@ -33,6 +33,21 @@
|
|||||||
<el-form-item label="密码" prop="password" :rules="passwordRules">
|
<el-form-item label="密码" prop="password" :rules="passwordRules">
|
||||||
<el-input v-model="formData.password" type="password" show-password placeholder="请输入密码" />
|
<el-input v-model="formData.password" type="password" show-password placeholder="请输入密码" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="角色" prop="roles" v-if="hasRoles" :rules="[{ required: true, message: '请选择角色' }]">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="formData.roles"
|
||||||
|
:default-expanded-keys="formData.roles"
|
||||||
|
:data="roles"
|
||||||
|
value-key="id"
|
||||||
|
check-strictly
|
||||||
|
class="w-full"
|
||||||
|
:props="{ label: 'role_name', value: 'id' }"
|
||||||
|
clearable
|
||||||
|
multiple
|
||||||
|
show-checkbox
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-1/2" v-if="hasRoles">
|
<div class="w-1/2" v-if="hasRoles">
|
||||||
@@ -46,9 +61,6 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item label="角色" prop="role_id" :rules="[{ required: true, message: '请选择角色' }]">
|
|
||||||
<el-tree v-model="formData.role_id" empty-text="" :data="roles" check-strictly :props="{ label: 'role_name', value: 'id' }" show-checkbox class="w-full mt-1" default-checked-keys />
|
|
||||||
</el-form-item>
|
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,8 +71,8 @@
|
|||||||
import { useCreate } from '/admin/composables/curd/useCreate'
|
import { useCreate } from '/admin/composables/curd/useCreate'
|
||||||
import { useShow } from '/admin/composables/curd/useShow'
|
import { useShow } from '/admin/composables/curd/useShow'
|
||||||
|
|
||||||
import { onMounted, watch, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import http from '../../../../resources/admin/support/http'
|
import http from '/admin/support/http'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
primary: String | Number,
|
primary: String | Number,
|
||||||
@@ -91,20 +103,16 @@ const { formData, form, loading, submitForm, close } = useCreate(props.api, prop
|
|||||||
if (props.primary) {
|
if (props.primary) {
|
||||||
useShow(props.api, props.primary, formData)
|
useShow(props.api, props.primary, formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
|
close(() => emit('close'))
|
||||||
|
|
||||||
const departments = ref()
|
const departments = ref()
|
||||||
const jobs = ref()
|
const jobs = ref()
|
||||||
const roles = ref()
|
const roles = ref()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
close(() => emit('close'))
|
|
||||||
|
|
||||||
if (props.hasRoles) {
|
if (props.hasRoles) {
|
||||||
http.get('permissions/roles').then(r => {
|
|
||||||
roles.value = r.data.data
|
|
||||||
})
|
|
||||||
|
|
||||||
http.get('permissions/departments').then(r => {
|
http.get('permissions/departments').then(r => {
|
||||||
departments.value = r.data.data
|
departments.value = r.data.data
|
||||||
})
|
})
|
||||||
@@ -112,6 +120,10 @@ onMounted(() => {
|
|||||||
http.get('permissions/jobs').then(r => {
|
http.get('permissions/jobs').then(r => {
|
||||||
jobs.value = r.data.data
|
jobs.value = r.data.data
|
||||||
})
|
})
|
||||||
|
|
||||||
|
http.get('permissions/roles').then(r => {
|
||||||
|
roles.value = r.data.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,52 +1,52 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col sm:flex-row w-full justify-between">
|
<div class="flex flex-col sm:flex-row w-full justify-between">
|
||||||
<Department v-model="query.department_id" @searchDepartmentUsers="search" v-if="false"/>
|
<Department v-model="query.department_id" @searchDepartmentUsers="search" v-if="false" />
|
||||||
<div class="w-full ml-5">
|
<div class="w-full ml-5">
|
||||||
<Search :search="search" :reset="reset">
|
<Search :search="search" :reset="reset">
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<el-form-item label="用户名">
|
<el-form-item label="用户名">
|
||||||
<el-input v-model="query.username" clearable />
|
<el-input v-model="query.username" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="邮箱">
|
<el-form-item label="邮箱">
|
||||||
<el-input v-model="query.email" clearable />
|
<el-input v-model="query.email" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<Select v-model="query.status" clearable api="status" />
|
<Select v-model="query.status" clearable api="status" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</template>
|
</template>
|
||||||
</Search>
|
</Search>
|
||||||
<div class="pl-2 pr-2 bg-white dark:bg-regal-dark rounded-lg mt-4 pb-6">
|
<div class="pl-2 pr-2 bg-white dark:bg-regal-dark rounded-lg mt-4 pb-6">
|
||||||
<Operate :show="open" />
|
<Operate :show="open" />
|
||||||
<el-table :data="tableData" class="mt-3" v-loading="loading">
|
<el-table :data="tableData" class="mt-3" v-loading="loading">
|
||||||
<el-table-column prop="username" label="用户名" width="180" />
|
<el-table-column prop="username" label="用户名" width="180" />
|
||||||
<el-table-column prop="avatar" label="头像" width="180" />
|
<el-table-column prop="avatar" label="头像" width="180" />
|
||||||
<el-table-column prop="email" label="邮箱" />
|
<el-table-column prop="email" label="邮箱" />
|
||||||
<el-table-column prop="status" label="状态">
|
<el-table-column prop="status" label="状态">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<Status v-model="scope.row.status" :id="scope.row.id" :api="api" />
|
<Status v-model="scope.row.status" :id="scope.row.id" :api="api" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="created_at" label="创建时间" />
|
<el-table-column prop="created_at" label="创建时间" />
|
||||||
<el-table-column label="操作" width="200">
|
<el-table-column label="操作" width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<Update @click="open(scope.row.id)" />
|
<Update @click="open(scope.row.id)" />
|
||||||
<Destroy @click="destroy(api, scope.row.id)" />
|
<Destroy @click="destroy(api, scope.row.id)" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<Paginate />
|
<Paginate />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog v-model="visible" :title="title" destroy-on-close>
|
||||||
|
<Create @close="close(reset)" :primary="id" :api="api" />
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Dialog v-model="visible" :title="title" destroy-on-close>
|
|
||||||
<Create @close="close" :primary="id" :api="api" />
|
|
||||||
</Dialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import Create from './create.vue'
|
import Create from './create.vue'
|
||||||
import { useGetList } from '/admin/composables/curd/useGetList'
|
import { useGetList } from '/admin/composables/curd/useGetList'
|
||||||
import { useDestroy } from '/admin/composables/curd/useDestroy'
|
import { useDestroy } from '/admin/composables/curd/useDestroy'
|
||||||
@@ -61,6 +61,7 @@ const { open, close, title, visible, id } = useOpen()
|
|||||||
|
|
||||||
const tableData = computed(() => data.value?.data)
|
const tableData = computed(() => data.value?.data)
|
||||||
|
|
||||||
|
const roles = ref<Array<Object>>()
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search()
|
search()
|
||||||
|
|
||||||
|
@@ -17,12 +17,3 @@ use Modules\Options\Http\OptionController;
|
|||||||
|
|
||||||
Route::get('options/{name}', [OptionController::class, 'index']);
|
Route::get('options/{name}', [OptionController::class, 'index']);
|
||||||
|
|
||||||
Route::get('/user/info', function (Request $request) {
|
|
||||||
return [
|
|
||||||
'id' => 1,
|
|
||||||
'nickname' => 'catchadmin',
|
|
||||||
'remember_token' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhZG1pbl9pZCI6MSwiYXVkIjoiIiwiZXhwIjoxNjg0ODA2MzIxLCJpYXQiOjE2NTg4ODYzMjEsImlzcyI6IiIsImp0aSI6ImI4ZjZlMzM4ZjM1MDg2OWJiZjIwNjE4OTA4OTk0ODMzIiwibmJmIjoxNjU4ODg2MzIxLCJzdWIiOiIifQ.ZJinC0JvY6OhJjr1GJgMaYk2qie8U_2W55L_I2AIBHk',
|
|
||||||
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user