Pre Merge pull request !389 from gwoksing/master
This commit is contained in:
commit
b534f24386
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -44,6 +46,18 @@ public class SysMenuController extends BaseController
|
|||||||
return AjaxResult.success(menus);
|
return AjaxResult.success(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取菜单列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
|
@GetMapping("/listTreeByPage")
|
||||||
|
public TableDataInfo listTreeByPage(SysMenu menu)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysMenu> menus = menuService.selectTreeByPage(menu, getUserId());
|
||||||
|
return getDataTable(menus);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单编号获取详细信息
|
* 根据菜单编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ -133,4 +133,13 @@ public interface ISysMenuService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String checkMenuNameUnique(SysMenu menu);
|
public String checkMenuNameUnique(SysMenu menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询菜单树
|
||||||
|
*
|
||||||
|
* @param menu
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<SysMenu> selectTreeByPage(SysMenu menu, Long userId);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,60 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询菜单树
|
||||||
|
*
|
||||||
|
* @param menu
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysMenu> selectTreeByPage(SysMenu menu, Long userId)
|
||||||
|
{
|
||||||
|
List<SysMenu> menuList = null;
|
||||||
|
menu.setParentId(0L);
|
||||||
|
|
||||||
|
// 管理员显示所有菜单信息
|
||||||
|
if (SysUser.isAdmin(userId)) {
|
||||||
|
menuList = menuMapper.selectMenuList(menu);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.getParams().put("userId", userId);
|
||||||
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||||
|
}
|
||||||
|
return findChildren(menuList, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysMenu> findChildren(List<SysMenu> sysMenuList, Long userId)
|
||||||
|
{
|
||||||
|
List<SysMenu> children = null;
|
||||||
|
SysMenu menu = new SysMenu();
|
||||||
|
|
||||||
|
for (SysMenu sysMenu : sysMenuList)
|
||||||
|
{
|
||||||
|
menu.setParentId(sysMenu.getMenuId());
|
||||||
|
|
||||||
|
// 管理员显示所有菜单信息
|
||||||
|
if (SysUser.isAdmin(userId))
|
||||||
|
{
|
||||||
|
children = menuMapper.selectMenuList(menu);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.getParams().put("userId", userId);
|
||||||
|
children = menuMapper.selectMenuListByUserId(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotNull(children) && children.size() > 0)
|
||||||
|
{
|
||||||
|
findChildren(children, userId);
|
||||||
|
sysMenu.setChildren(children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysMenuList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询权限
|
* 根据用户ID查询权限
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
|
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||||
<include refid="selectMenuVo"/>
|
<include refid="selectMenuVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
<if test="parentId != null">
|
||||||
|
AND parent_id = #{parentId}
|
||||||
|
</if>
|
||||||
<if test="menuName != null and menuName != ''">
|
<if test="menuName != null and menuName != ''">
|
||||||
AND menu_name like concat('%', #{menuName}, '%')
|
AND menu_name like concat('%', #{menuName}, '%')
|
||||||
</if>
|
</if>
|
||||||
@ -61,6 +64,9 @@
|
|||||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||||
left join sys_role ro on ur.role_id = ro.role_id
|
left join sys_role ro on ur.role_id = ro.role_id
|
||||||
where ur.user_id = #{params.userId}
|
where ur.user_id = #{params.userId}
|
||||||
|
<if test="parentId != null">
|
||||||
|
AND m.parent_id = #{parentId}
|
||||||
|
</if>
|
||||||
<if test="menuName != null and menuName != ''">
|
<if test="menuName != null and menuName != ''">
|
||||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -1,60 +1,69 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 查询菜单列表
|
// 查询菜单列表
|
||||||
export function listMenu(query) {
|
export function listMenu(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu/list',
|
url: '/system/menu/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询菜单详细
|
// 分页查询菜单列表
|
||||||
export function getMenu(menuId) {
|
export function listTreeByPage(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu/' + menuId,
|
url: '/system/menu/listTreeByPage',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
params: query
|
||||||
}
|
})
|
||||||
|
}
|
||||||
// 查询菜单下拉树结构
|
|
||||||
export function treeselect() {
|
// 查询菜单详细
|
||||||
return request({
|
export function getMenu(menuId) {
|
||||||
url: '/system/menu/treeselect',
|
return request({
|
||||||
method: 'get'
|
url: '/system/menu/' + menuId,
|
||||||
})
|
method: 'get'
|
||||||
}
|
})
|
||||||
|
}
|
||||||
// 根据角色ID查询菜单下拉树结构
|
|
||||||
export function roleMenuTreeselect(roleId) {
|
// 查询菜单下拉树结构
|
||||||
return request({
|
export function treeselect() {
|
||||||
url: '/system/menu/roleMenuTreeselect/' + roleId,
|
return request({
|
||||||
method: 'get'
|
url: '/system/menu/treeselect',
|
||||||
})
|
method: 'get'
|
||||||
}
|
})
|
||||||
|
}
|
||||||
// 新增菜单
|
|
||||||
export function addMenu(data) {
|
// 根据角色ID查询菜单下拉树结构
|
||||||
return request({
|
export function roleMenuTreeselect(roleId) {
|
||||||
url: '/system/menu',
|
return request({
|
||||||
method: 'post',
|
url: '/system/menu/roleMenuTreeselect/' + roleId,
|
||||||
data: data
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改菜单
|
// 新增菜单
|
||||||
export function updateMenu(data) {
|
export function addMenu(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu',
|
url: '/system/menu',
|
||||||
method: 'put',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除菜单
|
// 修改菜单
|
||||||
export function delMenu(menuId) {
|
export function updateMenu(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu/' + menuId,
|
url: '/system/menu',
|
||||||
method: 'delete'
|
method: 'put',
|
||||||
})
|
data: data
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除菜单
|
||||||
|
export function delMenu(menuId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/menu/' + menuId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@ -102,6 +102,14 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
@ -275,7 +283,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu";
|
import { listMenu, getMenu, delMenu, addMenu, updateMenu, listTreeByPage } from "@/api/system/menu";
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
import IconSelect from "@/components/IconSelect";
|
import IconSelect from "@/components/IconSelect";
|
||||||
@ -304,9 +312,12 @@ export default {
|
|||||||
refreshTable: true,
|
refreshTable: true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
menuName: undefined,
|
menuName: undefined,
|
||||||
visible: undefined
|
visible: undefined
|
||||||
},
|
},
|
||||||
|
total: 0,
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@ -334,8 +345,9 @@ export default {
|
|||||||
/** 查询菜单列表 */
|
/** 查询菜单列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listMenu(this.queryParams).then(response => {
|
listTreeByPage(this.queryParams).then(response => {
|
||||||
this.menuList = this.handleTree(response.data, "menuId");
|
this.menuList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user