up.
This commit is contained in:
parent
78cbfb21d5
commit
31b8e5807f
@ -12,12 +12,19 @@ class ConfigController extends BaseController
|
||||
public function list(): Json
|
||||
{
|
||||
$model = SysConfig::with([])
|
||||
->withSearch([], [
|
||||
|
||||
->withSearch(['group'], [
|
||||
'group'=> $this->request->get('group/s','')
|
||||
]);
|
||||
|
||||
$paginate = CurdService::getPaginate($this->request, $model);
|
||||
|
||||
return $this->writeSuccess('success', $paginate);
|
||||
}
|
||||
|
||||
public function data(string $name)
|
||||
{
|
||||
$config = SysConfig::where('name', $name)->findOrEmpty();
|
||||
|
||||
return $this->writeSuccess('success', $config->toArray());
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,39 @@ class MenuController extends BaseController
|
||||
|
||||
return $this->writeSuccess('ok', $lists);
|
||||
}
|
||||
public function update()
|
||||
{
|
||||
$data = $this->request->put([
|
||||
'menuId' => 0,
|
||||
'parentId' => 0,
|
||||
'title' => '',
|
||||
'menuType' => '',
|
||||
'openType' => '',
|
||||
'icon' => '',
|
||||
'path' => '',
|
||||
'component' => '',
|
||||
'authority' => '',
|
||||
'sortNumber' => 0,
|
||||
'hide' => 0,
|
||||
'meta' => '',
|
||||
]);
|
||||
|
||||
$user = SysMenu::findOrFail($data['menuId']);
|
||||
$user->save([
|
||||
'parent_id' => $data['parentId'],
|
||||
'title' => $data['title'],
|
||||
'menu_type' => $data['menuType'],
|
||||
'open_type' => $data['openType'],
|
||||
'icon' => $data['icon'],
|
||||
'path' => $data['path'],
|
||||
'component' => $data['component'],
|
||||
'authority' => $data['authority'],
|
||||
'sortNumber' => $data['sortNumber'],
|
||||
'hide' => $data['hide'],
|
||||
'meta' => $data['meta'],
|
||||
]);
|
||||
return $this->writeSuccess('添加成功');
|
||||
}
|
||||
/**
|
||||
* 添加菜单列表
|
||||
* @return Json
|
||||
|
||||
@ -68,7 +68,8 @@ Route::group("adminapi", function () {
|
||||
/*
|
||||
* 配置管理
|
||||
*/
|
||||
Route::get('config', [ConfigController::class, "list"])->name("system.listConfig");
|
||||
Route::get('config$', [ConfigController::class, "list"])->name("system.listConfig");
|
||||
Route::get('config/data', [ConfigController::class, "data"])->name("system.getConfigData");
|
||||
Route::post("config", [UserController::class, "add"])->name("system.addConfig");
|
||||
Route::put("config$", [UserController::class, "update"])->name("system.updateConfig");
|
||||
Route::delete("config", [UserController::class, "delete"])->name("system.deleteConfig");
|
||||
@ -96,6 +97,7 @@ Route::group("adminapi", function () {
|
||||
*/
|
||||
Route::get("menu$", [MenuController::class, "list"])->name("system.listMenus");
|
||||
Route::post("menu", [MenuController::class, "add"])->name("system.addMenu");
|
||||
Route::put("menu", [MenuController::class, "update"])->name("system.updateMenu");
|
||||
Route::delete("menu/:menu_id", [MenuController::class, "remove"])
|
||||
->model('menu_id', SysMenu::class)
|
||||
->name("system.removeMenu");
|
||||
|
||||
6203
z_ele/package-lock.json
generated
6203
z_ele/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
z_ele/src/api/system/config/index.ts
Normal file
30
z_ele/src/api/system/config/index.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Config, ConfigParam } from './model';
|
||||
|
||||
/**
|
||||
* 分页查询角色
|
||||
*/
|
||||
export async function configData(params: ConfigParam) {
|
||||
const res = await request.get<ApiResult<PageResult<Config>>>(
|
||||
'/system/config/data',
|
||||
{ params }
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色列表
|
||||
*/
|
||||
export async function listConfig(params?: ConfigParam) {
|
||||
const res = await request.get<ApiResult<Config[]>>('/system/config', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
15
z_ele/src/api/system/config/model/index.ts
Normal file
15
z_ele/src/api/system/config/model/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
export interface Config {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色搜索条件
|
||||
*/
|
||||
export interface ConfigParam extends PageParam {
|
||||
|
||||
}
|
||||
16
z_ele/src/utils/sys-config.ts
Normal file
16
z_ele/src/utils/sys-config.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {configData} from "@/api/system/config";
|
||||
|
||||
export async function getSysConfig(name) {
|
||||
const config = await configData({name});
|
||||
switch (config.type) {
|
||||
case 'json':
|
||||
config.valueData = JSON.parse(config.value);
|
||||
break
|
||||
case 'int':
|
||||
config.valueData = parseInt(config.value)
|
||||
break;
|
||||
default:
|
||||
config.valueData = config.value;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
11
z_ele/src/views/system/config-set/index.vue
Normal file
11
z_ele/src/views/system/config-set/index.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
148
z_ele/src/views/system/config/components/role-auth.vue
Normal file
148
z_ele/src/views/system/config/components/role-auth.vue
Normal file
@ -0,0 +1,148 @@
|
||||
<!-- 角色权限分配弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="460"
|
||||
title="分配权限"
|
||||
position="center"
|
||||
v-model="visible"
|
||||
:body-style="{ padding: '12px 0 12px 22px' }"
|
||||
@open="handleOpen"
|
||||
>
|
||||
<ele-loading
|
||||
:loading="authLoading"
|
||||
:spinner-style="{ background: 'transparent' }"
|
||||
:style="{
|
||||
paddingRight: '20px',
|
||||
height: 'calc(100vh - 192px)',
|
||||
maxHeight: 'calc(100dvh - 192px)',
|
||||
minHeight: '100px',
|
||||
overflow: 'auto'
|
||||
}"
|
||||
>
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
show-checkbox
|
||||
:data="authData"
|
||||
node-key="menuId"
|
||||
:default-expand-all="true"
|
||||
:props="{ label: 'title' }"
|
||||
:default-checked-keys="checkedKeys"
|
||||
:style="{ '--ele-tree-item-height': '28px' }"
|
||||
>
|
||||
<template #default="scope">
|
||||
<div>
|
||||
<el-icon
|
||||
v-if="scope.data.icon"
|
||||
:size="16"
|
||||
style="margin-right: 6px; vertical-align: -5px"
|
||||
>
|
||||
<component :is="scope.data.icon" />
|
||||
</el-icon>
|
||||
<span style="vertical-align: -2px">{{ scope.data.title }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-tree>
|
||||
</ele-loading>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick } from 'vue';
|
||||
import type { ElTree } from 'element-plus';
|
||||
import { EleMessage, toTree, eachTree } from 'ele-admin-plus';
|
||||
import { listRoleMenus, updateRoleMenus } from '@/api/system/role';
|
||||
import type { Role } from '@/api/system/role/model';
|
||||
import type { Menu } from '@/api/system/menu/model';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 当前角色数据 */
|
||||
data?: Role | null;
|
||||
}>();
|
||||
|
||||
/** 弹窗是否打开 */
|
||||
const visible = defineModel({ type: Boolean });
|
||||
|
||||
/** 树组件实例 */
|
||||
const treeRef = ref<InstanceType<typeof ElTree> | null>(null);
|
||||
|
||||
/** 权限数据 */
|
||||
const authData = ref<Menu[]>([]);
|
||||
|
||||
/** 权限数据请求状态 */
|
||||
const authLoading = ref(false);
|
||||
|
||||
/** 提交状态 */
|
||||
const loading = ref(false);
|
||||
|
||||
/** 角色权限选中的keys */
|
||||
const checkedKeys = ref<number[]>([]);
|
||||
|
||||
/** 查询权限数据 */
|
||||
const query = () => {
|
||||
authData.value = [];
|
||||
checkedKeys.value = [];
|
||||
if (!props.data) {
|
||||
return;
|
||||
}
|
||||
authLoading.value = true;
|
||||
listRoleMenus(props.data.roleId)
|
||||
.then((data) => {
|
||||
authLoading.value = false;
|
||||
// 转成树形结构的数据
|
||||
authData.value = toTree({
|
||||
data: data,
|
||||
idField: 'menuId',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
// 回显选中的数据
|
||||
nextTick(() => {
|
||||
const cks: number[] = [];
|
||||
eachTree(authData.value, (d) => {
|
||||
if (d.menuId && d.checked && !d.children?.length) {
|
||||
cks.push(d.menuId);
|
||||
}
|
||||
});
|
||||
checkedKeys.value = cks;
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
authLoading.value = false;
|
||||
EleMessage.error({ message: e.message, plain: true });
|
||||
});
|
||||
};
|
||||
|
||||
/** 关闭弹窗 */
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
/** 保存权限分配 */
|
||||
const save = () => {
|
||||
loading.value = true;
|
||||
const ids =
|
||||
(treeRef.value?.getCheckedKeys?.() ?? []).concat(
|
||||
treeRef.value?.getHalfCheckedKeys?.() ?? []
|
||||
) ?? [];
|
||||
updateRoleMenus(props.data?.roleId, ids as unknown as number[])
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
EleMessage.success({ message: msg, plain: true });
|
||||
handleCancel();
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
EleMessage.error({ message: e.message, plain: true });
|
||||
});
|
||||
};
|
||||
|
||||
/** 弹窗打开事件 */
|
||||
const handleOpen = () => {
|
||||
query();
|
||||
};
|
||||
</script>
|
||||
147
z_ele/src/views/system/config/components/role-edit.vue
Normal file
147
z_ele/src/views/system/config/components/role-edit.vue
Normal file
@ -0,0 +1,147 @@
|
||||
<!-- 角色编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
form
|
||||
destroy-on-close
|
||||
:width="460"
|
||||
v-model="visible"
|
||||
:title="isUpdate ? '修改角色' : '添加角色'"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="80px"
|
||||
@submit.prevent=""
|
||||
>
|
||||
<el-form-item label="角色名称" prop="roleName">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
v-model="form.roleName"
|
||||
placeholder="请输入角色名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色标识" prop="roleCode">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
v-model="form.roleCode"
|
||||
placeholder="请输入角色标识"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input
|
||||
:rows="4"
|
||||
type="textarea"
|
||||
v-model="form.comments"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import type { FormInstance, FormRules } from 'element-plus';
|
||||
import { EleMessage } from 'ele-admin-plus';
|
||||
import { useFormData } from '@/utils/use-form-data';
|
||||
import { addRole, updateRole } from '@/api/system/role';
|
||||
import type { Role } from '@/api/system/role/model';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 修改回显的数据 */
|
||||
data?: Role | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
/** 弹窗是否打开 */
|
||||
const visible = defineModel({ type: Boolean });
|
||||
|
||||
/** 是否是修改 */
|
||||
const isUpdate = ref(false);
|
||||
|
||||
/** 提交状态 */
|
||||
const loading = ref(false);
|
||||
|
||||
/** 表单实例 */
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/** 表单数据 */
|
||||
const [form, resetFields, assignFields] = useFormData<Role>({
|
||||
roleId: void 0,
|
||||
roleName: '',
|
||||
roleCode: '',
|
||||
comments: ''
|
||||
});
|
||||
|
||||
/** 表单验证规则 */
|
||||
const rules = reactive<FormRules>({
|
||||
roleName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入角色名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
roleCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入角色标识',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/** 关闭弹窗 */
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
/** 保存编辑 */
|
||||
const save = () => {
|
||||
formRef.value?.validate?.((valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
const saveOrUpdate = isUpdate.value ? updateRole : addRole;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
EleMessage.success({ message: msg, plain: true });
|
||||
handleCancel();
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
EleMessage.error({ message: e.message, plain: true });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/** 监听弹窗打开 */
|
||||
watch(visible, () => {
|
||||
if (visible.value) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
resetFields();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
64
z_ele/src/views/system/config/components/role-search.vue
Normal file
64
z_ele/src/views/system/config/components/role-search.vue
Normal file
@ -0,0 +1,64 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<ele-card :body-style="{ paddingBottom: '2px' }">
|
||||
<el-form
|
||||
label-width="72px"
|
||||
@keyup.enter.prevent="search"
|
||||
@submit.prevent=""
|
||||
>
|
||||
<el-row :gutter="8">
|
||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
||||
<el-form-item label="角色名称">
|
||||
<el-input
|
||||
clearable
|
||||
v-model.trim="form.roleName"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
||||
<el-form-item label="角色标识">
|
||||
<el-input
|
||||
clearable
|
||||
v-model.trim="form.roleCode"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12" :md="8" :sm="24" :xs="24">
|
||||
<el-form-item label-width="16px">
|
||||
<el-button type="primary" @click="search">查询</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</ele-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useFormData } from '@/utils/use-form-data';
|
||||
import type { RoleParam } from '@/api/system/role/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: RoleParam): void;
|
||||
}>();
|
||||
|
||||
/** 表单数据 */
|
||||
const [form, resetFields] = useFormData<RoleParam>({
|
||||
roleName: '',
|
||||
roleCode: '',
|
||||
comments: ''
|
||||
});
|
||||
|
||||
/** 搜索 */
|
||||
const search = () => {
|
||||
emit('search', { ...form });
|
||||
};
|
||||
|
||||
/** 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
search();
|
||||
};
|
||||
</script>
|
||||
245
z_ele/src/views/system/config/index.vue
Normal file
245
z_ele/src/views/system/config/index.vue
Normal file
@ -0,0 +1,245 @@
|
||||
<template>
|
||||
<ele-page>
|
||||
<!-- 搜索表单 -->
|
||||
<role-search @search="reload" />
|
||||
|
||||
<ele-tabs
|
||||
type="card"
|
||||
v-model="configGroup"
|
||||
:items="groupItems"
|
||||
@tabChange="reload()"
|
||||
/>
|
||||
|
||||
<ele-card :body-style="{ paddingTop: '8px' }">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="roleId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:show-overflow-tooltip="true"
|
||||
v-model:selections="selections"
|
||||
:highlight-current-row="true"
|
||||
:export-config="{ fileName: '角色数据', datasource: exportSource }"
|
||||
:print-config="{ datasource: exportSource }"
|
||||
:pagination="false"
|
||||
cache-key="systemRoleTable"
|
||||
:load-on-created="false"
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:icon="PlusOutlined"
|
||||
@click="openEdit()"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
class="ele-btn-icon"
|
||||
:icon="DeleteOutlined"
|
||||
@click="remove()"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<el-link type="primary" underline="never" @click="openEdit(row)">
|
||||
修改
|
||||
</el-link>
|
||||
<el-divider direction="vertical" />
|
||||
<el-link type="danger" underline="never" @click="remove(row)">
|
||||
删除
|
||||
</el-link>
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<el-switch
|
||||
size="small"
|
||||
:model-value="row.status === 0"
|
||||
@change="(checked: boolean) => editStatus(checked, row)"
|
||||
/>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</ele-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<role-edit v-model="showEdit" :data="current" @done="reload" />
|
||||
<!-- 权限分配弹窗 -->
|
||||
<role-auth v-model="showAuth" :data="current" />
|
||||
</ele-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {onMounted, ref} from 'vue';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { EleMessage } from 'ele-admin-plus';
|
||||
import type { EleProTable } from 'ele-admin-plus';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
Columns
|
||||
} from 'ele-admin-plus/es/ele-pro-table/types';
|
||||
import { PlusOutlined, DeleteOutlined } from '@/components/icons';
|
||||
import RoleSearch from './components/role-search.vue';
|
||||
import RoleEdit from './components/role-edit.vue';
|
||||
import RoleAuth from './components/role-auth.vue';
|
||||
import { pageRoles, removeRoles, listRoles } from '@/api/system/role';
|
||||
import type { Role, RoleParam } from '@/api/system/role/model';
|
||||
import { listConfig } from "@/api/system/config";
|
||||
import {getSysConfig} from "@/utils/sys-config";
|
||||
import type {User} from "@/api/system/user/model";
|
||||
import {updateUserStatus} from "@/api/system/user";
|
||||
|
||||
defineOptions({ name: 'SystemRole' });
|
||||
|
||||
/** 表格实例 */
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
/** 表格列配置 */
|
||||
const columns = ref<Columns>([
|
||||
{
|
||||
type: 'index',
|
||||
columnKey: 'index',
|
||||
width: 50,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
sortable: 'custom',
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
prop: 'title',
|
||||
label: '标题',
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '类型',
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
sortable: 'custom',
|
||||
slot: 'status',
|
||||
formatter: (row) => (row.status == 0 ? '正常' : '冻结')
|
||||
},
|
||||
{
|
||||
prop: 'comments',
|
||||
label: '备注',
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
columnKey: 'action',
|
||||
label: '操作',
|
||||
width: 200,
|
||||
align: 'center' /* ,
|
||||
fixed: 'right' */,
|
||||
slot: 'action',
|
||||
hideInPrint: true,
|
||||
hideInExport: true
|
||||
}
|
||||
]);
|
||||
|
||||
/** 表格选中数据 */
|
||||
const selections = ref<Role[]>([]);
|
||||
|
||||
/** 当前编辑数据 */
|
||||
const current = ref<Role | null>(null);
|
||||
|
||||
/** 是否显示编辑弹窗 */
|
||||
const showEdit = ref(false);
|
||||
|
||||
/** 是否显示权限分配弹窗 */
|
||||
const showAuth = ref(false);
|
||||
|
||||
/** 表格数据源 */
|
||||
const datasource: DatasourceFunction = ({ pages, where, orders }) => {
|
||||
return listConfig({ ...where, ...orders, ...pages, group: configGroup.value });
|
||||
};
|
||||
|
||||
/** 搜索 */
|
||||
const reload = (where?: RoleParam) => {
|
||||
selections.value = [];
|
||||
tableRef.value?.reload?.({ page: 1, where });
|
||||
};
|
||||
|
||||
/** 打开编辑弹窗 */
|
||||
const openEdit = (row?: Role) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/** 打开权限分配弹窗 */
|
||||
const openAuth = (row?: Role) => {
|
||||
current.value = row ?? null;
|
||||
showAuth.value = true;
|
||||
};
|
||||
|
||||
/** 删除单个 */
|
||||
const remove = (row?: Role) => {
|
||||
const rows = row == null ? selections.value : [row];
|
||||
if (!rows.length) {
|
||||
EleMessage.error({ message: '请至少选择一条数据', plain: true });
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
'确定要删除“' + rows.map((d) => d.roleName).join(', ') + '”吗?',
|
||||
'系统提示',
|
||||
{ type: 'warning', draggable: true }
|
||||
)
|
||||
.then(() => {
|
||||
const loading = EleMessage.loading({
|
||||
message: '请求中..',
|
||||
plain: true
|
||||
});
|
||||
removeRoles(rows.map((d) => d.roleId))
|
||||
.then((msg) => {
|
||||
loading.close();
|
||||
EleMessage.success({ message: msg, plain: true });
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.close();
|
||||
EleMessage.error({ message: e.message, plain: true });
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/** 导出和打印全部数据的数据源 */
|
||||
const exportSource: DatasourceFunction = ({ where, orders }) => {
|
||||
return listRoles({ ...where, ...orders });
|
||||
};
|
||||
/** 修改配置状态 */
|
||||
const editStatus = (checked: boolean, row: User) => {
|
||||
const status = checked ? 1 : 0;
|
||||
updateUserStatus(row.id, status)
|
||||
.then((msg) => {
|
||||
row.status = status;
|
||||
EleMessage.success({ message: msg, plain: true });
|
||||
})
|
||||
.catch((e) => {
|
||||
EleMessage.error({ message: e.message, plain: true });
|
||||
});
|
||||
};
|
||||
|
||||
const groupItems = ref([]);
|
||||
const configGroup = ref("");
|
||||
onMounted(async ()=>{
|
||||
// 配置分组
|
||||
const group = [];
|
||||
const { valueData } = await getSysConfig( "system.config_group");
|
||||
for (const name in valueData) {
|
||||
group.push({ name: name, label: valueData[name] })
|
||||
}
|
||||
groupItems.value = group
|
||||
if(group.length > 0){
|
||||
configGroup.value = group[0].name
|
||||
}
|
||||
reload();
|
||||
})
|
||||
</script>
|
||||
@ -216,7 +216,7 @@
|
||||
|
||||
/** 表格数据源 */
|
||||
const datasource: DatasourceFunction = async ({ where }) => {
|
||||
const data = await listMenus({ ...where });
|
||||
const data = await listMenus({ ...where, limit: 999 });
|
||||
return toTree({
|
||||
data,
|
||||
idField: 'menuId',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user