Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
be1307db94 | ||
![]() |
a6c879ce09 | ||
![]() |
ff14f46fe0 | ||
![]() |
03ea4759af | ||
![]() |
9abd62b801 | ||
![]() |
1849c85c39 | ||
![]() |
d02d56a6c0 | ||
![]() |
f819869cea | ||
![]() |
353da4e7f5 | ||
![]() |
d64cfc99d9 | ||
![]() |
3e51a72e3b | ||
![]() |
960576e286 | ||
![]() |
2772c3322f | ||
![]() |
8088787eee | ||
![]() |
2a6d65d4e7 | ||
![]() |
b8c4c90da7 | ||
![]() |
abd95877e1 | ||
![]() |
c48607c123 | ||
![]() |
035ba22f52 | ||
![]() |
403501b214 | ||
![]() |
c56a01df56 | ||
![]() |
ac5e0957b9 | ||
![]() |
948082f4ce | ||
![]() |
35622b164c | ||
![]() |
cbb3c156a6 | ||
![]() |
2d61786ec6 | ||
![]() |
95fae0dc28 | ||
![]() |
f91e434a83 | ||
![]() |
3f4bbb70d3 | ||
![]() |
3fc1e07de9 | ||
![]() |
23348b3a6b |
@@ -40,6 +40,11 @@
|
|||||||
- 账户: `catch@admin.com`
|
- 账户: `catch@admin.com`
|
||||||
- 密码: `catchadmin`
|
- 密码: `catchadmin`
|
||||||
|
|
||||||
|
## 视频教程(😂记得一键三连哦)
|
||||||
|
- [catchadmin 安装](https://www.bilibili.com/video/BV1eY411v71J/)
|
||||||
|
- [catchadmin 开发之模块创建](https://www.bilibili.com/video/BV1jP41127aW/)
|
||||||
|
- [catchadmin 之快速开发](https://www.bilibili.com/video/BV1Qh4y1J7eB/)
|
||||||
|
|
||||||
## 赞助
|
## 赞助
|
||||||
如果项目对你有帮助,或者在工作上帮你节省了开发时间。在力所能及的情况下,可以支持下`Catchadmin`项目, 非常感谢🙏
|
如果项目对你有帮助,或者在工作上帮你节省了开发时间。在力所能及的情况下,可以支持下`Catchadmin`项目, 非常感谢🙏
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"laravel/framework": "^10.0",
|
"laravel/framework": "^10.0",
|
||||||
"laravel/tinker": "^2.8",
|
"laravel/tinker": "^2.8",
|
||||||
"catchadmin/core": "^0.1.10"
|
"catchadmin/core": "^0.1.14"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
@@ -4,6 +4,7 @@ namespace Modules\Common\Support\Upload\Uses;
|
|||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class LocalUpload extends Upload
|
class LocalUpload extends Upload
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,9 @@ class LocalUpload extends Upload
|
|||||||
*/
|
*/
|
||||||
protected function addUrl($path): mixed
|
protected function addUrl($path): mixed
|
||||||
{
|
{
|
||||||
$path['path'] = config('app.url') . '/'. $path['path'];
|
$path['path'] = config('app.url') . '/'.
|
||||||
|
|
||||||
|
Str::of($path['path'])->replace('\\', '/')->toString();
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,6 @@ class {controller} extends Controller
|
|||||||
){}
|
){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function index(): mixed
|
public function index(): mixed
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
<el-form-item label="{label}" prop="{prop}">
|
||||||
|
<el-input v-model="{model-value}" name="{prop}" type="textarea" clearable />
|
||||||
|
</el-form-item>
|
@@ -0,0 +1,3 @@
|
|||||||
|
<el-form-item label="{label}" prop="{prop}">
|
||||||
|
<Upload v-model="{model-value}" />
|
||||||
|
</el-form-item>
|
@@ -95,5 +95,5 @@ const validates: string[] = [
|
|||||||
'prohibited',
|
'prohibited',
|
||||||
]
|
]
|
||||||
|
|
||||||
const formComponents: string[] = ['cascader', 'date', 'datetime', 'input', 'input-number', 'radio', 'rate', 'select', 'tree', 'tree-select']
|
const formComponents: string[] = ['cascader', 'date', 'datetime', 'input', 'input-number', 'radio', 'rate', 'select', 'tree', 'tree-select', 'textarea', 'upload']
|
||||||
</script>
|
</script>
|
||||||
|
@@ -6,6 +6,7 @@ namespace Modules\Permissions\Http\Controllers;
|
|||||||
|
|
||||||
use Catch\Base\CatchController as Controller;
|
use Catch\Base\CatchController as Controller;
|
||||||
use Catch\Exceptions\FailedException;
|
use Catch\Exceptions\FailedException;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Modules\Permissions\Enums\DataRange;
|
use Modules\Permissions\Enums\DataRange;
|
||||||
use Modules\Permissions\Models\Roles;
|
use Modules\Permissions\Models\Roles;
|
||||||
use Modules\Permissions\Http\Requests\RoleRequest;
|
use Modules\Permissions\Http\Requests\RoleRequest;
|
||||||
@@ -39,13 +40,15 @@ class RolesController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(RoleRequest $request)
|
public function store(RoleRequest $request)
|
||||||
{
|
{
|
||||||
$dataRange = $request->get('data_range');
|
$data = $request->all();
|
||||||
|
|
||||||
if ($dataRange && ! DataRange::Personal_Choose->assert($request->get('data_range'))) {
|
if ($request->get('data_range') && ! DataRange::Personal_Choose->assert($data['data_range'])) {
|
||||||
$request['departments'] = [];
|
$data['departments'] = [];
|
||||||
|
} else {
|
||||||
|
$data['data_range'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->model->storeBy($request->all());
|
return $this->model->storeBy($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,11 +56,15 @@ class RolesController extends Controller
|
|||||||
* @param $id
|
* @param $id
|
||||||
* @return \Illuminate\Database\Eloquent\Model|null
|
* @return \Illuminate\Database\Eloquent\Model|null
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id, Request $request)
|
||||||
{
|
{
|
||||||
$role = $this->model->firstBy($id);
|
$role = $this->model->firstBy($id);
|
||||||
|
|
||||||
|
if ($request->has('from') && $request->get('from') == 'parent_role') {
|
||||||
|
$role->setAttribute('permissions', $role->permissions()->get()->toTree());
|
||||||
|
} else {
|
||||||
$role->setAttribute('permissions', $role->permissions()->get()->pluck('id'));
|
$role->setAttribute('permissions', $role->permissions()->get()->pluck('id'));
|
||||||
|
}
|
||||||
|
|
||||||
$role->setAttribute('departments', $role->departments()->pluck('id'));
|
$role->setAttribute('departments', $role->departments()->pluck('id'));
|
||||||
|
|
||||||
@@ -76,9 +83,11 @@ class RolesController extends Controller
|
|||||||
|
|
||||||
if ($request->get('data_range') && ! DataRange::Personal_Choose->assert($data['data_range'])) {
|
if ($request->get('data_range') && ! DataRange::Personal_Choose->assert($data['data_range'])) {
|
||||||
$data['departments'] = [];
|
$data['departments'] = [];
|
||||||
|
} else {
|
||||||
|
$data['data_range'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->model->updateBy($id,$data);
|
return $this->model->updateBy($id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -10,6 +10,7 @@ use Catch\Enums\Status;
|
|||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Modules\Permissions\Enums\MenuStatus;
|
use Modules\Permissions\Enums\MenuStatus;
|
||||||
use Modules\Permissions\Enums\MenuType;
|
use Modules\Permissions\Enums\MenuType;
|
||||||
|
|
||||||
@@ -199,6 +200,7 @@ class Permissions extends Model
|
|||||||
$data['route'] = '/'.trim($data['route'], '/');
|
$data['route'] = '/'.trim($data['route'], '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['component'] = Str::of($data['component'])->replace('\\', '/')->toString();
|
||||||
return parent::storeBy($data);
|
return parent::storeBy($data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -244,6 +246,7 @@ class Permissions extends Model
|
|||||||
$data['permission_mark'] = $parentMenu->permission_mark.'@'.$data['permission_mark'];
|
$data['permission_mark'] = $parentMenu->permission_mark.'@'.$data['permission_mark'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['component'] = Str::of($data['component'])->replace('\\', '/')->toString();
|
||||||
return parent::updateBy($id, $data);
|
return parent::updateBy($id, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,9 @@ use Modules\Permissions\Models\Departments;
|
|||||||
use Modules\Permissions\Models\Roles;
|
use Modules\Permissions\Models\Roles;
|
||||||
use Modules\Permissions\Enums\DataRange as DataRangeEnum;
|
use Modules\Permissions\Enums\DataRange as DataRangeEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method aliasField(string $field)
|
||||||
|
*/
|
||||||
trait DataRange
|
trait DataRange
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ trait DataRange
|
|||||||
|
|
||||||
$userIds = $this->getDepartmentUserIdsBy($roles, $currenUser);
|
$userIds = $this->getDepartmentUserIdsBy($roles, $currenUser);
|
||||||
|
|
||||||
if (empty($userIds)) {
|
if ($userIds->isEmpty()) {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,14 @@
|
|||||||
<Select v-model="formData.permission_mark" allow-create placeholder="请选择" api="controllers" :query="{ module: formData.module }" v-else />
|
<Select v-model="formData.permission_mark" allow-create 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">
|
||||||
<el-input v-model="formData.icon" name="icon" clearable @click="open" />
|
<el-popover placement="right" :width="400" trigger="click">
|
||||||
|
<template #reference>
|
||||||
|
<el-input v-model="formData.icon" name="icon" clearable />
|
||||||
|
</template>
|
||||||
|
<div>
|
||||||
|
<Icons v-model="formData.icon" @close="closeSelectIcon" />
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属组件" prop="component" v-if="!isAction">
|
<el-form-item label="所属组件" prop="component" v-if="!isAction">
|
||||||
<Select v-model="formData.component" placeholder="请选择" allow-create api="components" :query="{ module: formData.module }" />
|
<Select v-model="formData.component" placeholder="请选择" allow-create api="components" :query="{ module: formData.module }" />
|
||||||
@@ -92,10 +99,6 @@
|
|||||||
<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>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<Dialog v-model="visible" title="选择 Icon" width="1000px" destroy-on-close>
|
|
||||||
<Icons v-model="formData.icon" @close="closeSelectIcon" />
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@@ -105,7 +105,7 @@ const { formData, form, loading, submitForm, close, beforeCreate, beforeUpdate }
|
|||||||
|
|
||||||
if (props.primary) {
|
if (props.primary) {
|
||||||
const { afterShow } = useShow(props.api, props.primary, formData)
|
const { afterShow } = useShow(props.api, props.primary, formData)
|
||||||
|
// 更新角色值
|
||||||
afterShow.value = formData => {
|
afterShow.value = formData => {
|
||||||
const data = unref(formData)
|
const data = unref(formData)
|
||||||
data.parent_id = data.parent_id ? [data.parent_id] : 0
|
data.parent_id = data.parent_id ? [data.parent_id] : 0
|
||||||
@@ -115,6 +115,8 @@ if (props.primary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formData.value = data
|
formData.value = data
|
||||||
|
// 这里需要获取角色的上级的权限以限制可用权限范围
|
||||||
|
getPermissions(data.parent_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +129,12 @@ const departments = ref()
|
|||||||
const showDepartments = ref<boolean>(false)
|
const showDepartments = ref<boolean>(false)
|
||||||
|
|
||||||
const permissionLoadingText = ref<string>('加载中...')
|
const permissionLoadingText = ref<string>('加载中...')
|
||||||
|
|
||||||
|
// 获取权限
|
||||||
const getPermissions = async (value: number = 0) => {
|
const getPermissions = async (value: number = 0) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
http.get('permissions/roles/' + getParent(value)).then(r => {
|
// 获取角色权限
|
||||||
|
http.get('permissions/roles/' + getParent(value), { from: 'parent_role' }).then(r => {
|
||||||
permissions.value = r.data.data.permissions
|
permissions.value = r.data.data.permissions
|
||||||
setCheckedPermissions()
|
setCheckedPermissions()
|
||||||
})
|
})
|
||||||
@@ -141,6 +146,7 @@ const getPermissions = async (value: number = 0) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置已选权限
|
||||||
const setCheckedPermissions = () => {
|
const setCheckedPermissions = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
props.hasPermissions.forEach(p => {
|
props.hasPermissions.forEach(p => {
|
||||||
@@ -152,6 +158,8 @@ const setCheckedPermissions = () => {
|
|||||||
permissionLoadingText.value = '暂无数据'
|
permissionLoadingText.value = '暂无数据'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取角色信息
|
||||||
const getRoles = () => {
|
const getRoles = () => {
|
||||||
http.get(props.api, { id: props.primary ? props.primary : '' }).then(r => {
|
http.get(props.api, { id: props.primary ? props.primary : '' }).then(r => {
|
||||||
roles.value = r.data.data
|
roles.value = r.data.data
|
||||||
@@ -163,9 +171,15 @@ const getDepartments = () => {
|
|||||||
departments.value = r.data.data
|
departments.value = r.data.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增默认获取全部权限
|
||||||
|
if (!props.primary) {
|
||||||
|
getPermissions()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面挂载完成后
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getRoles()
|
getRoles()
|
||||||
getPermissions()
|
|
||||||
getDepartments()
|
getDepartments()
|
||||||
close(() => emit('close'))
|
close(() => emit('close'))
|
||||||
watch(
|
watch(
|
||||||
@@ -206,4 +220,10 @@ const getParent = (parentId: any) => {
|
|||||||
:deep(.el-tree .el-tree__empty-block .el-tree__empty-text) {
|
:deep(.el-tree .el-tree__empty-block .el-tree__empty-text) {
|
||||||
@apply left-10 top-4;
|
@apply left-10 top-4;
|
||||||
}
|
}
|
||||||
|
:deep(.el-tree-node .is-expanded .el-tree-node__children) {
|
||||||
|
@apply flex flex-wrap pl-9;
|
||||||
|
}
|
||||||
|
:deep(.el-tree-node .is-expanded .el-tree-node__children .el-tree-node__content) {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
72
modules/System/Http/Controllers/DictionaryController.php
Normal file
72
modules/System/Http/Controllers/DictionaryController.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\System\Http\Controllers;
|
||||||
|
|
||||||
|
use Catch\Base\CatchController as Controller;
|
||||||
|
use Modules\System\Models\Dictionary;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
|
class DictionaryController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected readonly Dictionary $model
|
||||||
|
){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function index(): mixed
|
||||||
|
{
|
||||||
|
return $this->model->getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
return $this->model->storeBy($request->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return $this->model->firstBy($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function update($id, Request $request)
|
||||||
|
{
|
||||||
|
return $this->model->updateBy($id, $request->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$dictionary = $this->model->find($id);
|
||||||
|
|
||||||
|
if ($this->model->deleteBy($id)) {
|
||||||
|
return $dictionary->values()->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enable($id)
|
||||||
|
{
|
||||||
|
return $this->model->toggleBy($id);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\System\Http\Controllers;
|
||||||
|
|
||||||
|
use Catch\Base\CatchController as Controller;
|
||||||
|
use Modules\System\Models\DictionaryValues;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
|
class DictionaryValuesController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected readonly DictionaryValues $model
|
||||||
|
){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function index(): mixed
|
||||||
|
{
|
||||||
|
return $this->model->getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
return $this->model->storeBy($request->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return $this->model->firstBy($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function update($id, Request $request)
|
||||||
|
{
|
||||||
|
return $this->model->updateBy($id, $request->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
return $this->model->deleteBy($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enable($id)
|
||||||
|
{
|
||||||
|
return $this->model->toggleBy($id);
|
||||||
|
}
|
||||||
|
}
|
56
modules/System/Models/Dictionary.php
Normal file
56
modules/System/Models/Dictionary.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\System\Models;
|
||||||
|
|
||||||
|
use Catch\Base\CatchModel as Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property $id
|
||||||
|
* @property $name
|
||||||
|
* @property $key
|
||||||
|
* @property $status
|
||||||
|
* @property $description
|
||||||
|
* @property $creator_id
|
||||||
|
* @property $created_at
|
||||||
|
* @property $updated_at
|
||||||
|
* @property $deleted_at
|
||||||
|
*/
|
||||||
|
class Dictionary extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'system_dictionary';
|
||||||
|
|
||||||
|
protected $fillable = [ 'id', 'name', 'key', 'status', 'description', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $fields = ['id','name','key','status','description','created_at','updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $form = ['name','key','status','description'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $searchable = [
|
||||||
|
'name' => 'like',
|
||||||
|
'key' => 'like',
|
||||||
|
'status' => '=',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典值集合
|
||||||
|
*
|
||||||
|
* @return HasMany
|
||||||
|
*/
|
||||||
|
public function values(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(DictionaryValues::class, 'dic_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
46
modules/System/Models/DictionaryValues.php
Normal file
46
modules/System/Models/DictionaryValues.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\System\Models;
|
||||||
|
|
||||||
|
use Catch\Base\CatchModel as Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property $id
|
||||||
|
* @property $dic_id
|
||||||
|
* @property $label
|
||||||
|
* @property $value
|
||||||
|
* @property $sort
|
||||||
|
* @property $status
|
||||||
|
* @property $description
|
||||||
|
* @property $creator_id
|
||||||
|
* @property $created_at
|
||||||
|
* @property $updated_at
|
||||||
|
* @property $deleted_at
|
||||||
|
*/
|
||||||
|
class DictionaryValues extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'system_dictionary_values';
|
||||||
|
|
||||||
|
protected $fillable = [ 'id', 'dic_id', 'label', 'value', 'sort', 'status', 'description', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $fields = ['id','label','value','sort','status','description','created_at','updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $form = ['dic_id', 'label','value','sort','description'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $searchable = [
|
||||||
|
'dic_ids' => '=',
|
||||||
|
'label' => 'like',
|
||||||
|
'status' => '=',
|
||||||
|
];
|
||||||
|
}
|
20
modules/System/Providers/SystemServiceProvider.php
Normal file
20
modules/System/Providers/SystemServiceProvider.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\System\Providers;
|
||||||
|
|
||||||
|
use Catch\CatchAdmin;
|
||||||
|
use Catch\Providers\CatchModuleServiceProvider;
|
||||||
|
|
||||||
|
class SystemServiceProvider extends CatchModuleServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* route path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function moduleName(): string
|
||||||
|
{
|
||||||
|
// TODO: Implement path() method.
|
||||||
|
return 'system';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('system_dictionary', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name', 100)->comment('字典名称');
|
||||||
|
$table->string('key')->comment('字典 key');
|
||||||
|
$table->tinyInteger('status')->default(1)->comment('状态 1 启用 2 禁用');
|
||||||
|
$table->string('description', 1000)->comment('备注')->default('');
|
||||||
|
$table->creatorId();
|
||||||
|
$table->createdAt();
|
||||||
|
$table->updatedAt();
|
||||||
|
$table->deletedAt();
|
||||||
|
|
||||||
|
$table->engine='InnoDB';
|
||||||
|
$table->comment('字段管理');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('system_dictionary');
|
||||||
|
}
|
||||||
|
};
|
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('system_dictionary_values', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->integer('dic_id')->comment('字典ID');
|
||||||
|
$table->string('label')->comment('值名称');
|
||||||
|
$table->tinyInteger('value')->comment('对应值');
|
||||||
|
$table->integer('sort')->default(0)->comment('排序');
|
||||||
|
$table->tinyInteger('status')->default(1)->comment('状态 1 正常 2 禁用');
|
||||||
|
$table->string('description', 1000)->comment('描述')->default('');
|
||||||
|
$table->creatorId();
|
||||||
|
$table->createdAt();
|
||||||
|
$table->updatedAt();
|
||||||
|
$table->deletedAt();
|
||||||
|
|
||||||
|
$table->engine='InnoDB';
|
||||||
|
$table->comment('字典对应值');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('system_dictionary_values');
|
||||||
|
}
|
||||||
|
};
|
193
modules/System/database/seeder/SystemMenusSeeder.php
Normal file
193
modules/System/database/seeder/SystemMenusSeeder.php
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
return new class extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the seeder.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$menus = $this->menus();
|
||||||
|
|
||||||
|
importTreeData($menus, 'permissions');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function menus(): array
|
||||||
|
{
|
||||||
|
return array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 96,
|
||||||
|
'parent_id' => 0,
|
||||||
|
'permission_name' => '系统管理',
|
||||||
|
'route' => '/system',
|
||||||
|
'icon' => 'server-stack',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => '',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => NULL,
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535826,
|
||||||
|
'updated_at' => 1683535826,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
'id' => 97,
|
||||||
|
'parent_id' => 96,
|
||||||
|
'permission_name' => '字典管理',
|
||||||
|
'route' => 'dictionary',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary',
|
||||||
|
'component' => '/System/views/dictionary/index.vue',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535863,
|
||||||
|
'updated_at' => 1683535874,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
2 =>
|
||||||
|
array (
|
||||||
|
'id' => 103,
|
||||||
|
'parent_id' => 97,
|
||||||
|
'permission_name' => '删除',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary@destroy',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 3,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 5,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535980,
|
||||||
|
'updated_at' => 1683535980,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
3 =>
|
||||||
|
array (
|
||||||
|
'id' => 99,
|
||||||
|
'parent_id' => 97,
|
||||||
|
'permission_name' => '列表',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary@index',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 3,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535980,
|
||||||
|
'updated_at' => 1683535980,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
4 =>
|
||||||
|
array (
|
||||||
|
'id' => 101,
|
||||||
|
'parent_id' => 97,
|
||||||
|
'permission_name' => '读取',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary@show',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 3,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 3,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535980,
|
||||||
|
'updated_at' => 1683535980,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
5 =>
|
||||||
|
array (
|
||||||
|
'id' => 100,
|
||||||
|
'parent_id' => 97,
|
||||||
|
'permission_name' => '新增',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary@store',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 3,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 2,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535980,
|
||||||
|
'updated_at' => 1683535980,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
6 =>
|
||||||
|
array (
|
||||||
|
'id' => 102,
|
||||||
|
'parent_id' => 97,
|
||||||
|
'permission_name' => '更新',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionary@update',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 3,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 4,
|
||||||
|
'active_menu' => '',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535980,
|
||||||
|
'updated_at' => 1683535980,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
7 =>
|
||||||
|
array (
|
||||||
|
'id' => 98,
|
||||||
|
'parent_id' => 96,
|
||||||
|
'permission_name' => '字典值管理',
|
||||||
|
'route' => 'dictionary/values/:id',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'system',
|
||||||
|
'permission_mark' => 'dictionaryValues',
|
||||||
|
'component' => '/System/views/dictionaryValues/index.vue',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 2,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 2,
|
||||||
|
'sort' => 1,
|
||||||
|
'active_menu' => '/system/dictionary',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'created_at' => 1683535961,
|
||||||
|
'updated_at' => 1683593856,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
17
modules/System/routes/route.php
Normal file
17
modules/System/routes/route.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Modules\System\Http\Controllers\DictionaryController;
|
||||||
|
use Modules\System\Http\Controllers\DictionaryValuesController;
|
||||||
|
|
||||||
|
Route::prefix('system')->group(function(){
|
||||||
|
|
||||||
|
Route::apiResource('dictionary', DictionaryController::class);
|
||||||
|
Route::put('dictionary/enable/{id}', [DictionaryController::class, 'enable']);
|
||||||
|
|
||||||
|
Route::apiResource('dic/values', DictionaryValuesController::class);
|
||||||
|
Route::put('dic/values/enable/{id}', [DictionaryValuesController::class, 'enable']);
|
||||||
|
|
||||||
|
//next
|
||||||
|
});
|
||||||
|
|
56
modules/System/views/dictionary/create.vue
Normal file
56
modules/System/views/dictionary/create.vue
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<template>
|
||||||
|
<el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
|
||||||
|
<el-form-item
|
||||||
|
label="字典名称"
|
||||||
|
prop="name"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '字典名称必须填写',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<el-input v-model="formData.name" name="name" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="字典键名"
|
||||||
|
prop="key"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '字典键名必须填写',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<el-input v-model="formData.key" name="key" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="字典描述" prop="description">
|
||||||
|
<el-input v-model="formData.description" name="description" clearable type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useCreate } from '/admin/composables/curd/useCreate'
|
||||||
|
import { useShow } from '/admin/composables/curd/useShow'
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
primary: String | Number,
|
||||||
|
api: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)
|
||||||
|
|
||||||
|
if (props.primary) {
|
||||||
|
useShow(props.api, props.primary, formData)
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['close'])
|
||||||
|
onMounted(() => {
|
||||||
|
close(() => emit('close'))
|
||||||
|
})
|
||||||
|
</script>
|
73
modules/System/views/dictionary/index.vue
Normal file
73
modules/System/views/dictionary/index.vue
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<Search :search="search" :reset="reset">
|
||||||
|
<template v-slot:body>
|
||||||
|
<el-form-item label="字典名称" prop="name">
|
||||||
|
<el-input v-model="query.name" name="name" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="字典键名" prop="key">
|
||||||
|
<el-input v-model="query.key" name="key" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="字典状态" prop="status">
|
||||||
|
<el-input v-model="query.status" name="status" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
</Search>
|
||||||
|
|
||||||
|
<div class="table-default">
|
||||||
|
<Operate :show="open" />
|
||||||
|
<el-table :data="tableData" class="mt-3" v-loading="loading">
|
||||||
|
<el-table-column prop="id" label="ID" width="100" />
|
||||||
|
<el-table-column prop="name" label="字典名称" />
|
||||||
|
<el-table-column prop="key" label="字典键名">
|
||||||
|
<template #default="scope">
|
||||||
|
<router-link :to="{ path: '/system/dictionary/values/' + scope.row.id }">
|
||||||
|
<el-text type="primary">{{ scope.row.key }}</el-text>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="status" label="字典状态">
|
||||||
|
<template #default="scope">
|
||||||
|
<Status v-model="scope.row.status" :id="scope.row.id" :api="api" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="description" label="字典描述" />
|
||||||
|
<el-table-column label="操作" width="300">
|
||||||
|
<template #default="scope">
|
||||||
|
<Update @click="open(scope.row.id)" />
|
||||||
|
<Destroy @click="destroy(api, scope.row.id)" />
|
||||||
|
<router-link :to="{ path: '/system/dictionary/values/' + scope.row.id }">
|
||||||
|
<Show text="列表" class="ml-3" />
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Paginate />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog v-model="visible" :title="title" destroy-on-close>
|
||||||
|
<Create @close="close(reset)" :primary="id" :api="api" />
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, onMounted } from 'vue'
|
||||||
|
import Create from './create.vue'
|
||||||
|
import { useGetList } from '/admin/composables/curd/useGetList'
|
||||||
|
import { useDestroy } from '/admin/composables/curd/useDestroy'
|
||||||
|
import { useOpen } from '/admin/composables/curd/useOpen'
|
||||||
|
|
||||||
|
const api = 'system/dictionary'
|
||||||
|
|
||||||
|
const { data, query, search, reset, loading } = useGetList(api)
|
||||||
|
const { destroy, deleted } = useDestroy()
|
||||||
|
const { open, close, title, visible, id } = useOpen()
|
||||||
|
|
||||||
|
const tableData = computed(() => data.value?.data)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
search()
|
||||||
|
deleted(reset)
|
||||||
|
})
|
||||||
|
</script>
|
65
modules/System/views/dictionaryValues/create.vue
Normal file
65
modules/System/views/dictionaryValues/create.vue
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<template>
|
||||||
|
<el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
|
||||||
|
<el-form-item
|
||||||
|
label="字典值名"
|
||||||
|
prop="label"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '字典值名必须填写',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<el-input v-model="formData.label" name="label" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="字典键值"
|
||||||
|
prop="value"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '字典键值必须填写',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<el-input-number v-model="formData.value" name="value" clearable :min="1" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="sort">
|
||||||
|
<el-input-number v-model="formData.sort" name="sort" :min="1" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="描述" prop="description">
|
||||||
|
<el-input v-model="formData.description" name="description" clearable type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useCreate } from '/admin/composables/curd/useCreate'
|
||||||
|
import { useShow } from '/admin/composables/curd/useShow'
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
import router from '/admin/router'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
primary: String | Number,
|
||||||
|
api: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)
|
||||||
|
|
||||||
|
// 默认值
|
||||||
|
formData.value.value = 1
|
||||||
|
formData.value.sort = 1
|
||||||
|
formData.value.dic_id = router.currentRoute.value.params.id
|
||||||
|
|
||||||
|
if (props.primary) {
|
||||||
|
useShow(props.api, props.primary, formData)
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['close'])
|
||||||
|
onMounted(() => {
|
||||||
|
close(() => emit('close'))
|
||||||
|
})
|
||||||
|
</script>
|
64
modules/System/views/dictionaryValues/index.vue
Normal file
64
modules/System/views/dictionaryValues/index.vue
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<Search :search="search" :reset="reset">
|
||||||
|
<template v-slot:body>
|
||||||
|
<el-form-item label="字典值名" prop="label">
|
||||||
|
<el-input v-model="query.label" name="label" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-input v-model="query.status" name="status" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
</Search>
|
||||||
|
<div class="table-default">
|
||||||
|
<Operate :show="open" />
|
||||||
|
<el-table :data="tableData" class="mt-3" v-loading="loading">
|
||||||
|
<el-table-column prop="id" label="ID" />
|
||||||
|
<el-table-column prop="label" label="字典值名称" />
|
||||||
|
<el-table-column prop="value" label="字典键值" />
|
||||||
|
<el-table-column prop="sort" label="排序" />
|
||||||
|
<el-table-column prop="status" label="状态">
|
||||||
|
<template #default="scope">
|
||||||
|
<Status v-model="scope.row.status" :id="scope.row.id" :api="api" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="description" label="描述" />
|
||||||
|
<el-table-column label="操作" width="200">
|
||||||
|
<template #default="scope">
|
||||||
|
<Update @click="open(scope.row.id)" />
|
||||||
|
<Destroy @click="destroy(api, scope.row.id)" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Paginate />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog v-model="visible" :title="title" destroy-on-close>
|
||||||
|
<Create @close="close(reset)" :primary="id" :api="api" />
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, onMounted } from 'vue'
|
||||||
|
import Create from './create.vue'
|
||||||
|
import { useGetList } from '/admin/composables/curd/useGetList'
|
||||||
|
import { useDestroy } from '/admin/composables/curd/useDestroy'
|
||||||
|
import { useOpen } from '/admin/composables/curd/useOpen'
|
||||||
|
import router from '/admin/router'
|
||||||
|
|
||||||
|
const api = 'system/dic/values'
|
||||||
|
|
||||||
|
const { data, query, search, reset, loading } = useGetList(api)
|
||||||
|
query.value.dic_id = router.currentRoute.value.params.id
|
||||||
|
|
||||||
|
const { destroy, deleted } = useDestroy()
|
||||||
|
const { open, close, title, visible, id } = useOpen()
|
||||||
|
|
||||||
|
const tableData = computed(() => data.value?.data)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
search()
|
||||||
|
deleted(reset)
|
||||||
|
})
|
||||||
|
</script>
|
@@ -6,13 +6,14 @@ use Catch\Base\CatchController as Controller;
|
|||||||
use Catch\Support\Module\ModuleRepository;
|
use Catch\Support\Module\ModuleRepository;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Modules\Permissions\Models\Departments;
|
use Modules\Permissions\Models\Departments;
|
||||||
use Modules\User\Models\LogLogin;
|
use Modules\User\Models\LogLogin;
|
||||||
use Modules\User\Models\LogOperate;
|
use Modules\User\Models\LogOperate;
|
||||||
use Modules\User\Models\User;
|
use Modules\User\Models\User;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use Modules\User\Http\Requests\UserRequest;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -47,10 +48,10 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* store
|
* store
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param UserRequest $request
|
||||||
* @return false|mixed
|
* @return false|mixed
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(UserRequest $request)
|
||||||
{
|
{
|
||||||
return $this->user->storeBy($request->all());
|
return $this->user->storeBy($request->all());
|
||||||
}
|
}
|
||||||
@@ -80,10 +81,10 @@ class UserController extends Controller
|
|||||||
* update
|
* update
|
||||||
*
|
*
|
||||||
* @param $id
|
* @param $id
|
||||||
* @param Request $request
|
* @param UserRequest $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function update($id, Request $request)
|
public function update($id, UserRequest $request)
|
||||||
{
|
{
|
||||||
return $this->user->updateBy($id, $request->all());
|
return $this->user->updateBy($id, $request->all());
|
||||||
}
|
}
|
||||||
|
44
modules/User/Http/Requests/UserRequest.php
Normal file
44
modules/User/Http/Requests/UserRequest.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\User\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Modules\Permissions\Models\Roles;
|
||||||
|
|
||||||
|
class UserRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* rules
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
Rule::unique('users')->where(function ($query) {
|
||||||
|
return $query->when($this->get('id'), function ($query){
|
||||||
|
$query->where('id', '<>', $this->get('id'));
|
||||||
|
})->where('deleted_at', 0);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* messages
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email.required' => '邮箱必须填写',
|
||||||
|
|
||||||
|
'email.unique' => '邮箱已存在',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -58,23 +58,19 @@ trait UserRelations
|
|||||||
|
|
||||||
/* @var Permissions $permissionsModel */
|
/* @var Permissions $permissionsModel */
|
||||||
$permissionsModel = app($this->getPermissionsModel());
|
$permissionsModel = app($this->getPermissionsModel());
|
||||||
|
|
||||||
if ($this->isSuperAdmin()) {
|
if ($this->isSuperAdmin()) {
|
||||||
$permissions = $permissionsModel->get();
|
$permissions = $permissionsModel->get();
|
||||||
} else {
|
} else {
|
||||||
$permissions = Collection::make();
|
$permissionIds = Collection::make();
|
||||||
|
$this->roles()->with('permissions')->get()
|
||||||
app($this->getRolesModel())->with(['permissions'])->get()
|
->each(function ($role) use (&$permissionIds) {
|
||||||
|
$permissionIds = $permissionIds->concat($role->permissions?->pluck('id'));
|
||||||
->each(function ($role) use (&$permissions) {
|
|
||||||
$permissions = $permissions->concat($role->permissions);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$permissions = $permissions->unique();
|
$permissions = $permissionsModel->whereIn('id', $permissionIds->unique())->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,14 +99,15 @@ trait UserRelations
|
|||||||
if ($permission->isAction()) {
|
if ($permission->isAction()) {
|
||||||
[$controller, $action] = explode('@', $permission->permission_mark);
|
[$controller, $action] = explode('@', $permission->permission_mark);
|
||||||
|
|
||||||
$actions->add(CatchAdmin::getModuleControllerNamespace($permission->module).$controller.'Controller@'.$action);
|
$actions->add(CatchAdmin::getModuleControllerNamespace($permission->module). ucfirst($controller).'Controller@'.$action);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 自定义权限判断
|
||||||
if ($permission) {
|
if ($permission) {
|
||||||
[$module, $controller, $action] = explode('@', $permission);
|
[$module, $controller, $action] = explode('@', $permission);
|
||||||
|
|
||||||
$permission = CatchAdmin::getModuleControllerNamespace($module).$controller.'Controller@'.$action;
|
$permission = CatchAdmin::getModuleControllerNamespace($module). ucfirst($controller) .'Controller@'.$action;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $actions->contains($permission ?: Route::currentRouteAction());
|
return $actions->contains($permission ?: Route::currentRouteAction());
|
||||||
|
@@ -37,7 +37,7 @@ class User extends Model implements AuthenticatableContract
|
|||||||
public array $searchable = [
|
public array $searchable = [
|
||||||
'username' => 'like',
|
'username' => 'like',
|
||||||
'email' => 'like',
|
'email' => 'like',
|
||||||
'status' => '='
|
'status' => '=',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +73,8 @@ class User extends Model implements AuthenticatableContract
|
|||||||
protected function DepartmentId(): Attribute
|
protected function DepartmentId(): Attribute
|
||||||
{
|
{
|
||||||
return new Attribute(
|
return new Attribute(
|
||||||
get: fn($value) => $value ? : null
|
get: fn($value) => $value ? : null,
|
||||||
|
set: fn($value) => $value ? : 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ class User extends Model implements AuthenticatableContract
|
|||||||
*/
|
*/
|
||||||
public function updateBy($id, array $data): mixed
|
public function updateBy($id, array $data): mixed
|
||||||
{
|
{
|
||||||
if (isset($data['password']) && ! $data['password']) {
|
if (empty($data['password'])) {
|
||||||
unset($data['password']);
|
unset($data['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form :model="profile" ref="form" v-loading="loading" label-position="top">
|
<el-form :model="profile" ref="form" v-loading="loading" label-position="top">
|
||||||
<Upload class="w-28 h-28 rounded-full mx-auto" action="upload/image" :show-file-list="false" name="image" :on-success="uploadAvatar">
|
<Upload imageClass="w-28 h-28 rounded-full mx-auto" v-model="profile.avatar" />
|
||||||
<img :src="profile.avatar" class="h-28 rounded-full" v-if="profile.avatar" />
|
|
||||||
<Icon name="plus" v-else />
|
|
||||||
</Upload>
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="昵称"
|
label="昵称"
|
||||||
prop="username"
|
prop="username"
|
||||||
@@ -66,14 +63,12 @@ interface profile {
|
|||||||
password: string
|
password: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = ref<profile>(
|
const profile = ref<profile>({
|
||||||
Object.assign({
|
|
||||||
avatar: '',
|
avatar: '',
|
||||||
username: '',
|
username: '',
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
}),
|
})
|
||||||
)
|
|
||||||
const { form, loading, submitForm, afterCreate } = useCreate('user/online', null, profile)
|
const { form, loading, submitForm, afterCreate } = useCreate('user/online', null, profile)
|
||||||
|
|
||||||
const getUserInfo = () => {
|
const getUserInfo = () => {
|
||||||
@@ -91,15 +86,6 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const uploadAvatar = (response, uploadFile) => {
|
|
||||||
if (response.code === Code.SUCCESS) {
|
|
||||||
form.value.avatar = response.data.path
|
|
||||||
profile.value.avatar = response.data.path
|
|
||||||
} else {
|
|
||||||
Message.error(response.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterCreate.value = () => {
|
afterCreate.value = () => {
|
||||||
userStore.getUserInfo()
|
userStore.getUserInfo()
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,8 @@
|
|||||||
<el-table-column prop="username" label="用户名" width="150" />
|
<el-table-column prop="username" label="用户名" width="150" />
|
||||||
<el-table-column prop="avatar" label="头像">
|
<el-table-column prop="avatar" label="头像">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-avatar :src="scope.row.avatar" />
|
<el-avatar :icon="UserFilled" v-if="!scope.row.avatar" />
|
||||||
|
<el-avatar :src="scope.row.avatar" v-else />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="email" label="邮箱" />
|
<el-table-column prop="email" label="邮箱" />
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
// @ts-nocheck
|
||||||
import { computed, onMounted, ref } 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'
|
||||||
@@ -58,11 +60,11 @@ import { useOpen } from '/admin/composables/curd/useOpen'
|
|||||||
import Department from './components/department.vue'
|
import Department from './components/department.vue'
|
||||||
import { useUserStore } from '/admin/stores/modules/user'
|
import { useUserStore } from '/admin/stores/modules/user'
|
||||||
import { isUndefined } from '/admin/support/helper'
|
import { isUndefined } from '/admin/support/helper'
|
||||||
|
import { UserFilled } from '@element-plus/icons-vue'
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const api = 'users'
|
const api = 'users'
|
||||||
|
|
||||||
const { data, query, search, reset, loading } = useGetList(api)
|
const { data, query, search, reset, loading } = useGetList(api)
|
||||||
const { destroy, deleted } = useDestroy()
|
const { destroy, deleted } = useDestroy()
|
||||||
const { open, close, title, visible, id } = useOpen()
|
const { open, close, title, visible, id } = useOpen()
|
||||||
@@ -74,9 +76,7 @@ const hasRoles = ref<boolean>(false)
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search()
|
search()
|
||||||
|
|
||||||
deleted(reset)
|
deleted(reset)
|
||||||
|
|
||||||
hasRoles.value = !isUndefined(userStore.getRoles)
|
hasRoles.value = !isUndefined(userStore.getRoles)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
62
package.json
62
package.json
@@ -8,46 +8,48 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/vue": "^2.0.14",
|
"@heroicons/vue": "^2.0.18",
|
||||||
"@tinymce/tinymce-vue": "^5.0.1",
|
"@tinymce/tinymce-vue": "^5.1.0",
|
||||||
"@vueuse/core": "^9.12.0",
|
"@vueuse/core": "^10.1.2",
|
||||||
"autoprefixer": "^10.4.13",
|
"element-plus": "^2.3.5",
|
||||||
"element-plus": "^2.2.33",
|
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"pinia": "^2.0.32",
|
"pinia": "^2.1.3",
|
||||||
"postcss": "^8.4.21",
|
"terser": "^5.16.6",
|
||||||
"tailwindcss": "^3.2.2",
|
"vue": "^3.3.4",
|
||||||
"terser": "^5.16.5",
|
|
||||||
"vue": "^3.2.47",
|
|
||||||
"vue-i18n": "9",
|
"vue-i18n": "9",
|
||||||
"vue-router": "4.1.6",
|
"vue-router": "4.2.1",
|
||||||
"vuedraggable": "^4.1.0"
|
"vuedraggable": "^2.24.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify-json/logos": "^1.1.22",
|
"@iconify-json/logos": "^1.1.31",
|
||||||
"@rollup/plugin-alias": "^4.0.3",
|
"@rollup/plugin-alias": "^5.0.0",
|
||||||
"@types/mockjs": "^1.0.7",
|
"@types/mockjs": "^1.0.7",
|
||||||
"@types/node": "^18.14.6",
|
"@types/node": "^20.2.3",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||||
"@typescript-eslint/parser": "^5.54.0",
|
"@typescript-eslint/parser": "^5.59.7",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.2.3",
|
||||||
"@vitejs/plugin-vue-jsx": "^3.0.0",
|
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
||||||
"axios": "^1.3.4",
|
"autoprefixer": "^10.4.14",
|
||||||
"eslint": "^8.35.0",
|
"axios": "^1.4.0",
|
||||||
|
"eslint": "^8.41.0",
|
||||||
"eslint-config-standard": "^17.0.0",
|
"eslint-config-standard": "^17.0.0",
|
||||||
"eslint-plugin-import": "^2.27.5",
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-n": "^15.6.0",
|
"eslint-plugin-n": "^16.0.0",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
"eslint-plugin-vue": "^9.9.0",
|
"eslint-plugin-vue": "^9.14.0",
|
||||||
"prettier": "2.8.4",
|
"mockjs": "^1.1.0",
|
||||||
"sass": "^1.58.0",
|
"postcss": "^8.4.23",
|
||||||
"typescript": "^4.9.5",
|
"prettier": "2.8.8",
|
||||||
"unplugin-auto-import": "^0.14.4",
|
"sass": "^1.62.1",
|
||||||
"unplugin-icons": "^0.15.2",
|
"tailwindcss": "^3.3.2",
|
||||||
|
"typescript": "^5.0.4",
|
||||||
|
"unplugin-auto-import": "^0.16.2",
|
||||||
|
"unplugin-icons": "^0.16.1",
|
||||||
"unplugin-vue-components": "^0.24.0",
|
"unplugin-vue-components": "^0.24.0",
|
||||||
"vite": "^4.1.4",
|
"vite": "^4.3.8",
|
||||||
"vite-plugin-html": "^3.2.0",
|
"vite-plugin-html": "^3.2.0",
|
||||||
"vue-tsc": "^1.2.0"
|
"vite-plugin-mock": "^3.0.0",
|
||||||
|
"vue-tsc": "^1.6.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="`grid ${grid} gap-y-6`">
|
<div class="h-84 pl-2 pr-2">
|
||||||
|
<div :class="`grid ${grid} gap-y-4 gap-x-4` + ' mt-3 h-72'">
|
||||||
<div v-for="icon in icons" :key="icon" class="flex justify-center hover:cursor-pointer" @click="selectIcon(icon)">
|
<div v-for="icon in icons" :key="icon" class="flex justify-center hover:cursor-pointer" @click="selectIcon(icon)">
|
||||||
<div v-if="modelValue === icon">
|
<div v-if="modelValue === icon">
|
||||||
<div class="flex justify-center w-full text-violet-700"><Icon :name="icon" /></div>
|
<div class="flex justify-center w-full text-violet-700"><Icon :name="icon" className="w-5 h-5" /></div>
|
||||||
<div class="text-sm text-violet-700">{{ icon }}</div>
|
<div class="text-[1px] text-violet-700">{{ icon }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="flex justify-center w-full"><Icon :name="icon" /></div>
|
<div class="flex justify-center w-full"><Icon :name="icon" className="w-5 h-5" /></div>
|
||||||
<div class="text-sm">{{ icon }}</div>
|
<div class="text-[1px]">{{ icon }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center mt-6">
|
||||||
|
<el-pagination layout="prev,next" :page-size="limit" :total="total" prev-text="上一页" next-text="下一页" @next-click="handleNext" @prev-click="handlePrev" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -22,18 +30,38 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'grid-cols-5',
|
default: 'grid-cols-4',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['update:modelValue', 'close'])
|
const emits = defineEmits(['update:modelValue', 'close'])
|
||||||
|
|
||||||
|
const limit = ref<number>(16)
|
||||||
|
const icons = ref<Array<string>>([])
|
||||||
|
const total = ref<number>(0)
|
||||||
|
function getIcons(page = 1) {
|
||||||
|
const start = (page - 1) * limit.value
|
||||||
|
const end = start + limit.value
|
||||||
|
icons.value = constIcons.slice(start, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getIcons()
|
||||||
|
total.value = constIcons.length
|
||||||
|
})
|
||||||
|
const handleNext = (value: number) => {
|
||||||
|
getIcons(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePrev = (value: number) => {
|
||||||
|
getIcons(value)
|
||||||
|
}
|
||||||
const selectIcon = (icon: string) => {
|
const selectIcon = (icon: string) => {
|
||||||
emits('update:modelValue', icon)
|
emits('update:modelValue', icon)
|
||||||
emits('close')
|
emits('close')
|
||||||
}
|
}
|
||||||
// icons
|
// icons
|
||||||
const icons = [
|
const constIcons = [
|
||||||
'academic-cap',
|
'academic-cap',
|
||||||
'adjustments-horizontal',
|
'adjustments-horizontal',
|
||||||
'adjustments-vertical',
|
'adjustments-vertical',
|
||||||
|
@@ -1,8 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-upload ref="upload" :action="actionApi" :auto-upload="auto" :headers="{ authorization: token, 'Request-from': 'Dashboard' }" v-bind="$attrs">
|
<el-upload
|
||||||
|
ref="upload"
|
||||||
|
:action="actionApi"
|
||||||
|
:show-file-list="false"
|
||||||
|
name="image"
|
||||||
|
:auto-upload="auto"
|
||||||
|
:headers="{ authorization: token, 'Request-from': 'Dashboard' }"
|
||||||
|
v-bind="$attrs"
|
||||||
|
:on-success="handleSuccess"
|
||||||
|
>
|
||||||
<template v-for="(index, name) in $slots" v-slot:[name]>
|
<template v-for="(index, name) in $slots" v-slot:[name]>
|
||||||
<slot :name="name"></slot>
|
<slot :name="name"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
<img :src="modelValue" v-if="modelValue" :class="imageClass" />
|
||||||
|
<div v-else class="w-24 h-24 border-blue-100 border-dashed border rounded flex justify-center pt-8">
|
||||||
|
<Icon name="plus" />
|
||||||
|
</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -10,18 +23,30 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { env } from '/admin/support/helper'
|
import { env } from '/admin/support/helper'
|
||||||
import { getAuthToken } from '/admin/support/helper'
|
import { getAuthToken } from '/admin/support/helper'
|
||||||
|
import { Code } from '/admin/enum/app'
|
||||||
|
import Message from '/admin/support/message'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
action: {
|
action: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'upload',
|
default: 'upload/image',
|
||||||
},
|
},
|
||||||
auto: {
|
auto: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
require: true,
|
||||||
|
},
|
||||||
|
imageClass: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['update:modelValue'])
|
||||||
const baseURL = env('VITE_BASE_URL')
|
const baseURL = env('VITE_BASE_URL')
|
||||||
|
|
||||||
const actionApi = ref<string>('')
|
const actionApi = ref<string>('')
|
||||||
@@ -30,4 +55,12 @@ actionApi.value = baseURL + props.action
|
|||||||
|
|
||||||
const token = ref<string>()
|
const token = ref<string>()
|
||||||
token.value = 'Bearer ' + getAuthToken()
|
token.value = 'Bearer ' + getAuthToken()
|
||||||
|
|
||||||
|
const handleSuccess = (response: any) => {
|
||||||
|
if (response.code === Code.SUCCESS) {
|
||||||
|
emits('update:modelValue', response.data.path)
|
||||||
|
} else {
|
||||||
|
Message.error(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -57,11 +57,7 @@ export function useGetList(path: string, isPaginate: boolean = true) {
|
|||||||
// reset
|
// reset
|
||||||
function reset() {
|
function reset() {
|
||||||
resetPage()
|
resetPage()
|
||||||
|
query.value = Object.assign(isPaginate ? { page: page.value, limit: limit.value } : {})
|
||||||
if (isPaginate) {
|
|
||||||
query.value = Object.assign({ page: page.value, limit: limit.value })
|
|
||||||
}
|
|
||||||
|
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ function checkAction(el: any, action: any) {
|
|||||||
el.parentNode && el.parentNode.removeChild(el)
|
el.parentNode && el.parentNode.removeChild(el)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`need action! Like v-action="module.controller.action" || v-action="module@controller@action" `)
|
throw new Error(`need action! Like v-action="module.controller.action"`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,13 +13,16 @@
|
|||||||
<el-icon>
|
<el-icon>
|
||||||
<Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" />
|
<Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span>{{ menu?.meta?.title }}</span>
|
<span v-if="menu?.path.indexOf('https://') !== -1 || menu?.path.indexOf('http://') !== -1">
|
||||||
|
<span @click="openUrl(menu?.path as string)">{{ menu?.meta?.title }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-else>{{ menu?.meta?.title }}</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="MenuItem" setup>
|
<script lang="ts" setup>
|
||||||
import { Menu } from '/admin/types/Menu'
|
import { Menu } from '/admin/types/Menu'
|
||||||
import { onMounted, PropType, ref } from 'vue'
|
import { PropType } from 'vue'
|
||||||
import { useAppStore } from '/admin/stores/modules/app'
|
import { useAppStore } from '/admin/stores/modules/app'
|
||||||
import { isMiniScreen } from '/admin/support/helper'
|
import { isMiniScreen } from '/admin/support/helper'
|
||||||
|
|
||||||
@@ -37,6 +40,12 @@ defineProps({
|
|||||||
require: true,
|
require: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const openUrl = (path: string) => {
|
||||||
|
const start = path.indexOf('https://') || path.indexOf('http://')
|
||||||
|
window.open(path.substring(start))
|
||||||
|
return false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@@ -7,22 +7,15 @@
|
|||||||
:collapse="!appStore.isExpand"
|
:collapse="!appStore.isExpand"
|
||||||
:collapse-transition="false"
|
:collapse-transition="false"
|
||||||
:router="true"
|
:router="true"
|
||||||
@select="selectMenu"
|
|
||||||
:unique-opened="true"
|
:unique-opened="true"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="menus">
|
<script lang="ts" setup>
|
||||||
import { useAppStore } from '/admin/stores/modules/app'
|
import { useAppStore } from '/admin/stores/modules/app'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
|
||||||
const selectMenu = (index: string) => {
|
|
||||||
if (index.startsWith('http') || index.startsWith('https')) {
|
|
||||||
window.open(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
<!-- Tag view -->
|
<!-- Tag view -->
|
||||||
<!--<div class=""></div>-->
|
<!--<div class=""></div>-->
|
||||||
<!-- Container -->
|
<!-- Container -->
|
||||||
<div class="p-1 sm:p-2 max-w-full h-screen overflow-auto sm:overflow-x-hidden">
|
<div class="p-1 sm:p-3 max-w-full h-screen overflow-auto sm:overflow-x-hidden">
|
||||||
<div class="min-h-[calc(100vh-8rem)]">
|
<div class="min-h-[calc(100vh-8rem)]">
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full text-center text-gray-400 h-4 leading-10">
|
<div class="w-full text-center text-gray-400 h-4 leading-10">
|
||||||
<el-link href="https://catchadmin.com/">CatchAdmin 管理系统 </el-link> @copyright 2018 ~ {{ year }}
|
<el-link href="https://catchadmin.com/" target="_blank">CatchAdmin 管理系统 </el-link> @copyright 2018 ~ {{ year }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-row h-16 w-full drop-shadow border-l dark:border-l-0 border-gray-200" style="background-color: var(--header-bg-color)">
|
<div class="flex flex-row h-16 w-full drop-shadow border-l dark:border-l-0 border-gray-200" style="background-color: var(--header-bg-color)">
|
||||||
<div class="flex flex-row justify-between w-full">
|
<div class="flex flex-row justify-between w-full h-16">
|
||||||
<div class="flex flex-row min-w-[17rem]">
|
<div class="flex flex-row min-w-[17rem]">
|
||||||
<div class="h-full flex items-center w-8 ml-2 hover:cursor-pointer" @click="store.changeExpaned">
|
<div class="h-full flex items-center w-8 ml-2 hover:cursor-pointer" @click="store.changeExpaned">
|
||||||
<Icon name="list-bullet" class="w-6 h-8" />
|
<Icon name="list-bullet" class="w-6 h-8" />
|
||||||
|
@@ -37,8 +37,7 @@ const guard = (router: Router) => {
|
|||||||
// 挂载路由(实际是从后端获取用户的权限)
|
// 挂载路由(实际是从后端获取用户的权限)
|
||||||
const permissionStore = usePermissionsStore()
|
const permissionStore = usePermissionsStore()
|
||||||
// 动态路由挂载
|
// 动态路由挂载
|
||||||
const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions))
|
const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions), true)
|
||||||
console.log(asyncRoutes)
|
|
||||||
asyncRoutes.forEach((route: Menu) => {
|
asyncRoutes.forEach((route: Menu) => {
|
||||||
router.addRoute(route as unknown as RouteRecordRaw)
|
router.addRoute(route as unknown as RouteRecordRaw)
|
||||||
})
|
})
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { User } from '/admin/types/user'
|
|
||||||
import http from '/admin/support/http'
|
import http from '/admin/support/http'
|
||||||
import { rememberAuthToken, removeAuthToken } from '/admin/support/helper'
|
import { rememberAuthToken, removeAuthToken } from '/admin/support/helper'
|
||||||
import Message from '/admin/support/message'
|
import Message from '/admin/support/message'
|
||||||
import router from '/admin/router'
|
import router from '/admin/router'
|
||||||
import { Permission } from '/admin/types/permission'
|
import { User } from '/admin/types/User'
|
||||||
|
import { Permission } from '/admin/types/Permission'
|
||||||
|
|
||||||
export const useUserStore = defineStore('UserStore', {
|
export const useUserStore = defineStore('UserStore', {
|
||||||
state: (): User => {
|
state: (): User => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { Permission } from '/admin/types/permission'
|
import { Permission } from '/admin/types/Permission'
|
||||||
import { MenuType } from '/admin/enum/app'
|
import { MenuType } from '/admin/enum/app'
|
||||||
import { Menu } from '/admin/types/Menu'
|
import { Menu } from '/admin/types/Menu'
|
||||||
import { constantRoutes } from '/admin/router'
|
import { constantRoutes } from '/admin/router'
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
// login user type
|
// login user type
|
||||||
|
import { Permission } from './Permission'
|
||||||
import { Permission } from './permission'
|
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id: number
|
id: number
|
||||||
|
Reference in New Issue
Block a user