diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs index ca28efc03a81a45fc4e47c917e5a365741a29169..caaeb11fcfaa16186d1c990bfda66bd33a1e21a4 100644 --- a/ZR.Service/System/SysMenuService.cs +++ b/ZR.Service/System/SysMenuService.cs @@ -1,4 +1,4 @@ -using Infrastructure.Attribute; +using Infrastructure.Attribute; using Infrastructure.Extensions; using SqlSugar; using System; @@ -41,7 +41,7 @@ namespace ZR.Service var userRoles = SysRoleService.SelectUserRoles(userId); menuList = SelectTreeMenuListByRoles(menu, userRoles); } - return menuList; + return menuList ?? new List(); } /// diff --git a/ZR.Vue/src/views/system/menu/index.vue b/ZR.Vue/src/views/system/menu/index.vue index 92f97895fd4b46e523d94a59079989853ffe44f6..b0799504be9eeab63f2c19f78cb97c038ee37d3a 100644 --- a/ZR.Vue/src/views/system/menu/index.vue +++ b/ZR.Vue/src/views/system/menu/index.vue @@ -27,6 +27,7 @@ { this.msgSuccess("修改成功"); this.open = false; - this.getList(); + if (this.form.parentId == 0) { + this.getList(); + } else { + this.refreshTableTree(this.form.parentId); + } }); } else { addMenu(this.form).then((response) => { this.msgSuccess("新增成功"); this.open = false; - this.getList(); + if (this.form.parentId == 0) { + this.getList(); + } else { + this.refreshTableTree(this.form.parentId); + } }); } } @@ -424,7 +435,11 @@ export default { return delMenu(row.menuId); }) .then(() => { - this.getList(); + if (row.parentId == 0) { + this.getList(); + } else { + this.refreshTableTree(row.parentId); + } this.msgSuccess("删除成功"); }); }, @@ -465,7 +480,16 @@ export default { listMenuById(row.menuId).then((res) => { resolve(res.data) }) - } + }, + //新增/修改/删除子节点时刷新子节点 + refreshTableTree(key) { + const node = this.tableTreeNodeMap.get(key) + if (!node) { + return + } + const { row, treeNode, resolve } = node + this.loadMenu(row, treeNode, resolve) + }, }, };