From bc98ab3805ca89fa1bcdc3c3e4ecc3b265e1df5f Mon Sep 17 00:00:00 2001
From: fmm <1442620801@qq.com>
Date: Sat, 3 Aug 2024 18:33:38 +0800
Subject: [PATCH 01/10] =?UTF-8?q?feat:=20vue=E6=96=B0=E5=A2=9E=E8=A7=92?=
=?UTF-8?q?=E8=89=B2=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../nestJs/src/role/dto/delete-role.dto.ts | 6 -
.../pro/template/tinyvue/src/api/menu.ts | 19 +
.../pro/template/tinyvue/src/api/role.ts | 18 +-
.../tinyvue/src/components/menu/index.vue | 17 +-
.../pro/template/tinyvue/src/locale/en-US.ts | 5 +
.../pro/template/tinyvue/src/locale/zh-CN.ts | 5 +
.../tinyvue/src/router/routes/modules/role.ts | 29 +
.../permission/info/components/info-tab.vue | 3 +-
.../template/tinyvue/src/views/role/index.vue | 5 +
.../views/role/info/components/info-tab.vue | 497 ++++++++++++++++++
.../tinyvue/src/views/role/info/index.vue | 61 +++
.../src/views/role/info/locale/en-US.ts | 18 +
.../src/views/role/info/locale/zh-CN.ts | 18 +
.../src/views/userManager/setting/index.vue | 4 +-
.../src/views/userManager/useradd/index.vue | 4 +-
15 files changed, 690 insertions(+), 19 deletions(-)
delete mode 100644 packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts
create mode 100644 packages/toolkits/pro/template/tinyvue/src/api/menu.ts
create mode 100644 packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts
create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/index.vue
create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/components/info-tab.vue
create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/index.vue
create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/locale/en-US.ts
create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/locale/zh-CN.ts
diff --git a/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts b/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts
deleted file mode 100644
index a53480b0..00000000
--- a/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { IsNotEmpty } from 'class-validator';
-
-export class DeleteRoleDto {
- @IsNotEmpty()
- name: string;
-}
diff --git a/packages/toolkits/pro/template/tinyvue/src/api/menu.ts b/packages/toolkits/pro/template/tinyvue/src/api/menu.ts
new file mode 100644
index 00000000..cc79c924
--- /dev/null
+++ b/packages/toolkits/pro/template/tinyvue/src/api/menu.ts
@@ -0,0 +1,19 @@
+import axios from "axios";
+
+
+
+export function getAllMenu() {
+ return axios.get('/api/menu');
+}
+
+export function updateMenu(data: any) {
+ return axios.patch(`/api/menu`, data);
+}
+
+export function deleteMenu(id: number) {
+ return axios.delete(`/api/menu/${id}`);
+}
+
+export function createMenu(data: any) {
+ return axios.post(`/api/menu`, data);
+}
diff --git a/packages/toolkits/pro/template/tinyvue/src/api/role.ts b/packages/toolkits/pro/template/tinyvue/src/api/role.ts
index 089039c5..6e57f754 100644
--- a/packages/toolkits/pro/template/tinyvue/src/api/role.ts
+++ b/packages/toolkits/pro/template/tinyvue/src/api/role.ts
@@ -2,6 +2,22 @@ import axios from "axios";
-export function getRoles() {
+export function getAllRole() {
return axios.get('/api/role');
}
+
+export function getAllRoleDetail() {
+ return axios.get('/api/role/detail');
+}
+
+export function updateRole(data: any) {
+ return axios.patch(`/api/role`, data);
+}
+
+export function deleteRole(id: number) {
+ return axios.delete(`/api/role/${id}`);
+}
+
+export function createRole(data: any) {
+ return axios.post(`/api/role`, data);
+}
diff --git a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue
index b53081d4..a1597c6b 100644
--- a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue
+++ b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue
@@ -35,6 +35,7 @@
IconApplication,
IconGroup,
IconFolderOpened,
+ IconActivation,
} from '@opentiny/vue-icon';
import { TreeMenu as tinyTreeMenu } from '@opentiny/vue';
import router from '@/router';
@@ -52,6 +53,7 @@
const iconApplication = IconApplication();
const iconFolderOpened = IconFolderOpened();
const iconGroup = IconGroup();
+ const iconActivation = IconActivation();
const tree = ref();
const expandeArr = ref();
const routerTitle = [
@@ -230,17 +232,18 @@
bold: 'title',
},
{
- value: 'PermissionSetting',
- name: 'menu.permission.setting',
- icon: null,
- bold: 'title',
+ value: 'Role',
+ name: 'menu.role',
+ icon: iconActivation,
+ bold: 'main-title',
},
{
- value: 'PermissionAdd',
- name: 'menu.permission.permissionAdd',
+ value: 'AllRole',
+ name: 'menu.role.info',
icon: null,
bold: 'title',
},
+
];
// 获取路由数据
@@ -311,6 +314,8 @@
'User',
'Cloud',
'UserManager',
+ 'Permission',
+ 'Role'
];
if (filter.indexOf(data.id) === -1) {
router.push({ name: data.id });
diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts
index 750d6e04..addd305d 100644
--- a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts
+++ b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts
@@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/en-US';
import localePermission from '@/views/permission/info/locale/en-US';
+import localeRole from '@/views/role/info/locale/en-US';
+
import localeSettings from './en-US/settings';
import localeHttpError from './en-US/httpError';
@@ -56,6 +58,8 @@ export default {
'menu.permission.info':'All Permission Info',
'menu.permission.setting':'Permission Setting',
'menu.permission.permissionAdd':'Add Permission',
+ 'menu.role': 'Role Manager',
+ 'menu.role.info':'All Role Info',
'navbar.docs': 'Docs',
'navbar.action.locale': 'Switch to English',
'messageBox.switchRoles': 'Switch Roles',
@@ -86,4 +90,5 @@ export default {
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
+ ...localeRole,
};
diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts
index 09ae2408..c00ab8cc 100644
--- a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts
+++ b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts
@@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/zh-CN';
import localePermission from '@/views/permission/info/locale/zh-CN';
+import localeRole from '@/views/role/info/locale/zh-CN';
+
import localeSettings from './zh-CN/settings';
import localeHttpError from './zh-CN/httpError';
@@ -57,6 +59,8 @@ export default {
'menu.permission.info':'查看权限',
'menu.permission.setting':'修改权限',
'menu.permission.permissionAdd':'添加权限',
+ 'menu.role': '角色管理',
+ 'menu.role.info':'查看角色',
'navbar.docs': '文档中心',
'navbar.action.locale': '切换为中文',
'messageBox.switchRoles': '切换角色',
@@ -87,4 +91,5 @@ export default {
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
+ ...localeRole,
};
diff --git a/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts
new file mode 100644
index 00000000..d6e1f749
--- /dev/null
+++ b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts
@@ -0,0 +1,29 @@
+import { RoleType } from '@/types/roleType';
+
+export default {
+ path: 'role',
+ name: 'Role',
+ id: 'Role',
+ label: 'Role',
+ component: () => import('@/views/role/index.vue'),
+ meta: {
+ locale: 'menu.role',
+ requiresAuth: true,
+ order: 9,
+ roles: [RoleType.admin],
+ },
+ children: [
+ {
+ path: 'allRole',
+ name: 'AllRole',
+ id: 'AllRole',
+ label: 'AllRole',
+ component: () => import('@/views/role/info/index.vue'),
+ meta: {
+ locale: 'menu.role.info',
+ requiresAuth: true,
+ roles: [RoleType.admin],
+ },
+ },
+ ],
+};
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
index 88f53dfb..0f4ee9df 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
+++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
@@ -2,7 +2,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+
@@ -163,9 +156,9 @@
-
+
@@ -185,7 +178,15 @@
:label="$t('menuInfo.table.parentId')"
prop="parentId"
>
-
+
+
@@ -223,9 +224,9 @@
-
+
@@ -263,9 +264,9 @@
-
+
@@ -285,7 +286,15 @@
:label="$t('menuInfo.table.parentId')"
prop="parentId"
>
-
+
+
@@ -323,9 +332,9 @@
-
+
@@ -344,11 +353,7 @@
import {ref, reactive, onMounted, watch, computed} from 'vue';
import {useI18n} from 'vue-i18n';
import {
- Tabs as TinyTabs,
- TabItem as TinyTabItem,
- Loading,
- GridColumn as TinyGridColumn,
- Grid as TinyGrid, Pager as TinyPager, Modal as TinyModal,
+ Modal as TinyModal,
Button as TinyButton,
Form as TinyForm,
FormItem as TinyFormItem,
@@ -358,6 +363,7 @@ import {
BaseSelect as TinyBaseSelect,
Select as TinySelect,
Option as TinyOption,
+ Tree as TinyTree,
} from '@opentiny/vue';
import {IconChevronDown} from '@opentiny/vue-icon';
import {useUserStore} from '@/store';
@@ -371,23 +377,27 @@ const router = useRouter();
const {t} = useI18n();
+const treeRef = ref();
+
// 加载效果
const state = reactive<{
tableData: any;
- permissionData: any;
menuData: any;
menuUpdData: any;
menuAddData: any;
+ menuInfoData: any;
isMenuUpdate: boolean;
isMenuAdd: boolean;
+ isMenuInfo: boolean;
}>({
tableData: [] as any,
- permissionData: [] as any,
menuData: {} as any,
menuUpdData: {} as any,
menuAddData: {} as any,
+ menuInfoData: {} as any,
isMenuAdd: false,
isMenuUpdate: false,
+ isMenuInfo: false,
});
// 变量设置
@@ -405,19 +415,18 @@ const rulesSelect = {
};
const rules = computed(() => {
return {
- name: [rulesType],
+ label: [rulesType],
order: [rulesType],
- parentId: [rulesType],
menuType: [rulesType],
icon: [rulesType],
component: [rulesType],
- path: [rulesType],
+ url: [rulesType],
};
});
// 初始化请求数据
onMounted(() => {
- // fetchMenuData();
+ fetchMenuData();
});
// 请求数据接口方法
@@ -427,15 +436,18 @@ async function fetchMenuData() {
};
-async function handleDelete (id: string){
+async function handleDelete (node: any){
+ let newTemp = {
+ id: node.data.id,
+ parentId: node.data.parentId,
+ };
try {
- await deleteMenu(id);
+ await deleteMenu(newTemp);
TinyModal.message({
message: '已删除',
status: 'success',
});
- state.isMenuUpdate = false;
- state.menuUpdData = {} as any;
+ await fetchMenuData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
@@ -447,9 +459,12 @@ async function handleDelete (id: string){
}
}
-const handleUpdate = (id: string) => {
+const handleUpdate = (node: any) => {
state.isMenuUpdate = true;
- state.menuUpdData = state.tableData[id - 1];
+ state.menuUpdData = node.data;
+ state.menuData = ref({
+ data: state.tableData,
+ })
}
const handleMenuUpdateCancel =()=>{
@@ -457,43 +472,72 @@ const handleMenuUpdateCancel =()=>{
state.menuUpdData = {} as any;
}
+const handleCheck = (node: any) => {
+ state.isMenuInfo = true;
+ state.menuInfoData = node.data;
+}
+
+const handleMenuInfoCancel = () => {
+ state.isMenuInfo = false;
+ state.menuInfoData = {} as any;
+}
+
async function handleMenuUpdateSubmit(){
let data = state.menuUpdData;
let newTemp = {
id: data.id,
- name: data.name,
- permissionIds: data.desc,
- menuIds:data.menu,
+ name: data.label,
+ order: data.order,
+ parentId: data.parentId,
+ menuType: data.menuType,
+ icon: data.icon,
+ component: data.component,
+ path: data.url,
};
- try {
- await updateMenu(newTemp);
+ if(newTemp.id === newTemp.parentId){
Modal.message({
- message: t('baseForm.form.submit.success'),
- status: 'success',
+ message: t('menuInfo.modal.message.error'),
+ status: 'error',
});
- state.isMenuUpdate = false;
- state.menuUpdData = {} as any;
- } catch (error) {
- if (error.response && error.response.data) {
- const errorMessage = error.response.data.message || '未知错误';
+ }else{
+ try {
+ await updateMenu(newTemp);
Modal.message({
- message: errorMessage,
- status: 'error',
+ message: t('baseForm.form.submit.success'),
+ status: 'success',
});
+ state.isMenuUpdate = false;
+ state.menuUpdData = {} as any;
+ await fetchMenuData();
+ } catch (error) {
+ if (error.response && error.response.data) {
+ const errorMessage = error.response.data.message || '未知错误';
+ Modal.message({
+ message: errorMessage,
+ status: 'error',
+ });
+ }
}
}
}
function handleAddMenu() {
state.isMenuAdd = true;
+ state.menuData = ref({
+ data: state.tableData,
+ })
}
async function handleMenuAddSubmit() {
let data = state.menuAddData;
let newTemp = {
- name: data.name,
- permissionIds: data.desc,
- menuIds:data.menu,
+ name: data.label,
+ order: data.order,
+ parentId: data.parentId,
+ menuType: data.menuType,
+ icon: data.icon,
+ component: data.component,
+ path: data.url,
};
try {
await createMenu(newTemp);
@@ -503,6 +547,7 @@ async function handleMenuAddSubmit() {
});
state.isMenuAdd = false;
state.menuAddData = {} as any;
+ await fetchMenuData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
@@ -540,8 +585,8 @@ async function handleMenuAddCancel() {
.operation {
&-delete {
- padding-right: 5px;
color: red;
+ padding-right: 10px;
}
&-update {
@@ -549,8 +594,9 @@ async function handleMenuAddCancel() {
color: #1890ff;
}
- &-pwd-update {
+ &-info {
color: orange;
+ padding-right: 10px;
}
}
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/index.vue b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/index.vue
index 5ceec97d..4164be0e 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/index.vue
+++ b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/index.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/en-US.ts b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/en-US.ts
index 1bcc2676..4c7a69a0 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/en-US.ts
+++ b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/en-US.ts
@@ -9,10 +9,12 @@ export default {
'menuInfo.table.component': 'Component',
'menuInfo.table.path': 'Path',
'menuInfo.table.operations': 'Operation',
+ 'menuInfo.table.operations.info': 'Detail',
'menuInfo.table.operations.update': 'Update',
'menuInfo.table.operations.delete': 'Delete',
+ 'menuInfo.modal.title.info': 'Menu Detail',
'menuInfo.modal.title.update': 'Update Menu',
'menuInfo.modal.title.add': 'Add Menu',
- 'menuInfo.modal.message.error': 'Error',
+ 'menuInfo.modal.message.error': 'ParentId is not as same as id',
'menuInfo.modal.message.notNull': 'Not Null',
};
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/zh-CN.ts b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/zh-CN.ts
index 4407baad..13e42383 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/zh-CN.ts
+++ b/packages/toolkits/pro/template/tinyvue/src/views/menu/info/locale/zh-CN.ts
@@ -9,10 +9,13 @@ export default {
'menuInfo.table.component': '组件',
'menuInfo.table.path': '路径',
'menuInfo.table.operations': '操作',
+ 'menuInfo.table.operations.info': '查看',
'menuInfo.table.operations.update': '修改',
'menuInfo.table.operations.delete': '删除',
+ 'menuInfo.modal.title.info': '查看菜单',
'menuInfo.modal.title.update': '修改菜单',
'menuInfo.modal.title.add': '添加菜单',
- 'menuInfo.modal.message.error': '错误',
+ 'menuInfo.modal.message.error': 'parentId不能和id相同',
'menuInfo.modal.message.notNull': '不能为空',
+
};
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
index 0f4ee9df..ee098800 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
+++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue
@@ -237,6 +237,7 @@ async function handleDelete (id: string){
});
state.isPermissionUpdate = false;
state.permissionUpdData = {} as any;
+ await fetchData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
@@ -273,6 +274,7 @@ async function handlePermissionUpdateSubmit(){
});
state.isPermissionUpdate = false;
state.permissionUpdData = {} as any;
+ await fetchData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
@@ -302,6 +304,7 @@ async function handlePermissionAddSubmit() {
});
state.isPermissionAdd = false;
state.permissionAddData = {} as any;
+ await fetchData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
From 181a2fae95eb313e97b29071e54612428e09a2d7 Mon Sep 17 00:00:00 2001
From: fmm <1442620801@qq.com>
Date: Mon, 5 Aug 2024 21:27:15 +0800
Subject: [PATCH 05/10] =?UTF-8?q?fix:=20nest=E5=AE=8C=E5=96=84=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../nestJs/src/menu/dto/delete-menu.dto.ts | 7 ++---
.../nestJs/src/menu/dto/update-menu.dto.ts | 2 ++
.../server/nestJs/src/menu/menu.controller.ts | 10 +++++--
.../server/nestJs/src/menu/menu.service.ts | 28 +++++++++++++++++--
4 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/dto/delete-menu.dto.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/dto/delete-menu.dto.ts
index fba71a0f..8190314a 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/dto/delete-menu.dto.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/dto/delete-menu.dto.ts
@@ -1,8 +1,7 @@
import { IsNotEmpty } from 'class-validator';
-
-export class DeleteMenuDto {
+import { PartialType } from '@nestjs/mapped-types';
+import { CreateMenuDto } from './create-menu.dto';
+export class DeleteMenuDto extends PartialType(CreateMenuDto) {
@IsNotEmpty()
id: number;
- @IsNotEmpty()
- name: string;
}
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/dto/update-menu.dto.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/dto/update-menu.dto.ts
index a8de5514..13a859e8 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/dto/update-menu.dto.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/dto/update-menu.dto.ts
@@ -1,6 +1,8 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateMenuDto } from './create-menu.dto';
+import {IsNotEmpty} from "class-validator";
export class UpdateMenuDto extends PartialType(CreateMenuDto) {
+ @IsNotEmpty()
id: number;
}
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
index 5913c059..dcb4fb5b 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
@@ -17,9 +17,15 @@ import { DeleteMenuDto } from './dto/delete-menu.dto';
export class MenuController {
constructor(private readonly menuService: MenuService) {}
- @Get()
+ @Get('/role')
async getMenus(@Req() req) {
- return this.menuService.findAll(req.user);
+ return this.menuService.findRoleMenu(req.user);
+ }
+
+ @Get()
+ @Permission('menu::query')
+ async getAllMenus() {
+ return this.menuService.findAllMenu();
}
@Post()
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
index 8609f651..bcbf6f18 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
@@ -17,6 +17,14 @@ export interface ITreeNodeData {
url: string;
//组件
component: string;
+ //图标
+ icon: string;
+ //类型
+ menuType: string;
+ //父节点
+ parentId: number;
+ //排序
+ order: number;
}
interface MenuMap {
@@ -30,6 +38,10 @@ const toNode = (menu: Menu): ITreeNodeData => {
children: [],
url: menu.path,
component: menu.component,
+ icon: menu.icon,
+ menuType: menu.menuType,
+ parentId: menu.parentId,
+ order: menu.order,
};
};
@@ -58,7 +70,7 @@ export class MenuService {
@InjectRepository(Menu)
private menu: Repository
-
-
-
-
-
-
-
+
+
+
@@ -57,22 +58,20 @@
-
- {{ $t('permissionInfo.table.id')}}:{{ $t(`${data.row.permission[0].id}`) }}
- {{ $t('permissionInfo.table.name')}}:{{ $t(`${data.row.permission[0].name}`) }}
- {{ $t('permissionInfo.table.desc')}}:{{ $t(`${data.row.permission[0].desc}`) }}
-
+
+ {{ $t(`${item.name}`) }}
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
@@ -159,18 +158,16 @@
:label="$t('roleInfo.modal.input.menu')"
prop="menu"
>
-
-
-
+
@@ -190,7 +187,7 @@
show-header
show-footer
mask-closable="true"
- height="350"
+ height="auto"
width="600"
:title="$t('roleInfo.modal.title.add')"
>
@@ -243,18 +240,16 @@
:label="$t('roleInfo.modal.input.menu')"
prop="menu"
>
-
-
-
+
@@ -287,6 +282,7 @@ import {
BaseSelect as TinyBaseSelect,
Select as TinySelect,
Option as TinyOption,
+ Tree as TinyTree,
} from '@opentiny/vue';
import {IconChevronDown} from '@opentiny/vue-icon';
import {useUserStore} from '@/store';
@@ -306,6 +302,7 @@ const state = reactive<{
tableData: any;
permissionData: any;
menuData: any;
+ menuOptionData: any;
roleUpdData: any;
roleAddData: any;
isRoleUpdate: boolean;
@@ -314,6 +311,7 @@ const state = reactive<{
tableData: [] as any,
permissionData: [] as any,
menuData: {} as any,
+ menuOptionData: {} as any,
roleUpdData: {} as any,
roleAddData: {} as any,
isRoleAdd: false,
@@ -351,19 +349,20 @@ onMounted(() => {
// 请求数据接口方法
async function fetchRoleData() {
const {data} = await getAllRoleDetail();
- state.tableData = data;
+ for(let i = 0; i < data.roleInfo.length; i+=1){
+ data.roleInfo[i].menuTree = data.menuTree[i]
+ }
+ state.tableData = data.roleInfo
};
async function fetchPermissionData() {
const {data} = await getAllPermission();
state.permissionData = data;
- console.log(state.permissionData)
};
async function fetchMenuData() {
const {data} = await getAllMenu();
state.menuData = data;
-
};
async function handleDelete (id: string){
@@ -386,9 +385,37 @@ async function handleDelete (id: string){
}
}
+async function convertMenu(data: any){
+ let menu = [] as any;
+ for (let j = 0; j < data.menus.length; j+=1){
+ menu.push(data.menus[j].id)
+ if(data.menus[j].children !== null){
+ convertMenu(data.menus[j].children)
+ }
+ }
+ return menu;
+}
+
const handleUpdate = (id: string) => {
state.isRoleUpdate = true;
- state.roleUpdData = state.tableData[id - 1];
+ let data = state.tableData[id - 1];
+ let permission = [] as any;
+ for (let i = 0; i < data.permission.length; i+=1){
+ permission.push(data.permission[i].id)
+ }
+ let menu = [] as any;
+ for (let j = 0; j < data.menus.length; j+=1){
+ menu.push(data.menus[j].id)
+ }
+ state.roleUpdData = {
+ id: data.id,
+ name: data.name,
+ menus: menu,
+ desc: permission,
+ }
+ state.menuOptionData = ref({
+ data: state.menuData
+ })
}
const handleRoleUpdateCancel =()=>{
@@ -402,7 +429,7 @@ async function handleRoleUpdateSubmit(){
id: data.id,
name: data.name,
permissionIds: data.desc,
- menuIds:data.menu,
+ menuIds:data.menus,
};
try {
await updateRole(newTemp);
@@ -412,6 +439,7 @@ async function handleRoleUpdateSubmit(){
});
state.isRoleUpdate = false;
state.roleUpdData = {} as any;
+ await fetchRoleData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
@@ -425,6 +453,9 @@ async function handleRoleUpdateSubmit(){
function handleAddRole() {
state.isRoleAdd = true;
+ state.menuOptionData = ref({
+ data: state.menuData
+ })
}
async function handleRoleAddSubmit() {
@@ -432,7 +463,7 @@ async function handleRoleAddSubmit() {
let newTemp = {
name: data.name,
permissionIds: data.desc,
- menuIds:data.menu,
+ menuIds:data.menus,
};
try {
await createRole(newTemp);
@@ -442,6 +473,7 @@ async function handleRoleAddSubmit() {
});
state.isRoleAdd = false;
state.roleAddData = {} as any;
+ await fetchRoleData();
} catch (error) {
if (error.response && error.response.data) {
const errorMessage = error.response.data.message || '未知错误';
diff --git a/packages/toolkits/pro/template/tinyvue/src/views/userManager/info/components/info-tab.vue b/packages/toolkits/pro/template/tinyvue/src/views/userManager/info/components/info-tab.vue
index 4ed20dd4..b669f356 100644
--- a/packages/toolkits/pro/template/tinyvue/src/views/userManager/info/components/info-tab.vue
+++ b/packages/toolkits/pro/template/tinyvue/src/views/userManager/info/components/info-tab.vue
@@ -167,7 +167,7 @@
show-header
show-footer
mask-closable="true"
- height="350"
+ height="auto"
width="600"
:title="$t('userInfo.modal.title.pwdUpdate')"
>
From 157c1c97458f7f1c5013e735383616d4faf99c00 Mon Sep 17 00:00:00 2001
From: fmm <1442620801@qq.com>
Date: Mon, 5 Aug 2024 23:37:05 +0800
Subject: [PATCH 07/10] =?UTF-8?q?fix:=20nest=E5=AE=8C=E5=96=84role?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../server/nestJs/src/menu/menu.controller.ts | 8 ++++----
.../server/nestJs/src/menu/menu.service.ts | 4 ++--
.../server/nestJs/src/role/role.service.ts | 19 +++++++++++++++----
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
index dcb4fb5b..4b0fca6e 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.controller.ts
@@ -5,7 +5,7 @@ import {
Body,
Patch,
Req,
- Delete,
+ Delete, Param,
} from '@nestjs/common';
import { MenuService } from './menu.service';
import { CreateMenuDto } from './dto/create-menu.dto';
@@ -17,9 +17,9 @@ import { DeleteMenuDto } from './dto/delete-menu.dto';
export class MenuController {
constructor(private readonly menuService: MenuService) {}
- @Get('/role')
- async getMenus(@Req() req) {
- return this.menuService.findRoleMenu(req.user);
+ @Get('/role/:email')
+ async getMenus(@Param('email') email: string) {
+ return this.menuService.findRoleMenu(email);
}
@Get()
diff --git a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
index bcbf6f18..07bc4748 100644
--- a/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
+++ b/packages/toolkits/pro/template/server/nestJs/src/menu/menu.service.ts
@@ -70,13 +70,13 @@ export class MenuService {
@InjectRepository(Menu)
private menu: Repository