系统菜单
This commit is contained in:
@@ -19,7 +19,8 @@ public enum QueryTEnum {
|
|||||||
LE((q, k, v) -> { q.le(k[0],v); }),
|
LE((q, k, v) -> { q.le(k[0],v); }),
|
||||||
BY((q, k, v) -> { q.orderByDesc(k[0],v); }),
|
BY((q, k, v) -> { q.orderByDesc(k[0],v); }),
|
||||||
NO((q, k, v) -> { q.isNull(k[0]); }),
|
NO((q, k, v) -> { q.isNull(k[0]); }),
|
||||||
LT((q, k, v) -> { q.lt(k[0],v); });
|
LT((q, k, v) -> { q.lt(k[0],v); }),
|
||||||
|
OREQ((q, k, v) -> { if (v == null){ q.isNull(k[0]); }else { q.eq(k[0],v); } });
|
||||||
|
|
||||||
private LConsumer<QueryWrapper,String[], Object> doP;
|
private LConsumer<QueryWrapper,String[], Object> doP;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.nl.modules.common.base.BaseDTO;
|
import org.nl.modules.common.base.BaseDTO;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.nl.modules.common.utils.SecurityUtils;
|
import org.nl.modules.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.system.service.MenuService;
|
import org.nl.modules.system.service.MenuService;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -43,7 +43,7 @@ import java.util.*;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Api(tags = "系统:菜单管理")
|
@Api(tags = "系统:菜单管理")
|
||||||
@RequestMapping("/api/menus")
|
@RequestMapping("/api/menus2")
|
||||||
public class MenuController {
|
public class MenuController {
|
||||||
|
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ package org.nl.modules.system.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.nl.modules.system.domain.Menu;
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
|
||||||
import org.nl.modules.system.service.dto.MenuQueryCriteria;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.nl.modules.system.service.dto;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.nl.modules.common.base.BaseDTO;
|
import org.nl.modules.common.base.BaseDTO;
|
||||||
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import org.nl.modules.common.utils.SecurityUtils;
|
|||||||
import org.nl.modules.system.domain.vo.MenuMetaVo;
|
import org.nl.modules.system.domain.vo.MenuMetaVo;
|
||||||
import org.nl.modules.system.domain.vo.MenuVo;
|
import org.nl.modules.system.domain.vo.MenuVo;
|
||||||
import org.nl.modules.system.service.MenuService;
|
import org.nl.modules.system.service.MenuService;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
|
||||||
import org.nl.modules.tools.IdUtil;
|
import org.nl.modules.tools.IdUtil;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.nl.modules.wql.util.WqlUtil;
|
import org.nl.modules.wql.util.WqlUtil;
|
||||||
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -69,7 +69,7 @@ public class MenuServiceImpl implements MenuService {
|
|||||||
public MenuDto menuJsonToMenuDto(JSONObject json) {
|
public MenuDto menuJsonToMenuDto(JSONObject json) {
|
||||||
MenuDto menuDto = new MenuDto();
|
MenuDto menuDto = new MenuDto();
|
||||||
menuDto.setMenuId(json.getString("menu_id"));
|
menuDto.setMenuId(json.getString("menu_id"));
|
||||||
menuDto.setType(json.getInteger("type"));
|
menuDto.setType(json.getString("type"));
|
||||||
menuDto.setPermission(json.getString("permission"));
|
menuDto.setPermission(json.getString("permission"));
|
||||||
menuDto.setTitle(json.getString("title"));
|
menuDto.setTitle(json.getString("title"));
|
||||||
menuDto.setMenuSort(json.getInteger("menu_sort"));
|
menuDto.setMenuSort(json.getInteger("menu_sort"));
|
||||||
@@ -329,7 +329,7 @@ public class MenuServiceImpl implements MenuService {
|
|||||||
if (!menuDTO.getIFrame()) {
|
if (!menuDTO.getIFrame()) {
|
||||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && menuDTO.getType() == 0) {
|
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||||
|
|
||||||
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ package org.nl.system.controller.menu;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.dev33.satoken.annotation.SaMode;
|
import cn.dev33.satoken.annotation.SaMode;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.nl.common.TableDataInfo;
|
import org.nl.common.TableDataInfo;
|
||||||
import org.nl.modules.common.utils.SecurityUtils;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
|
||||||
import org.nl.system.service.menu.ISysMenuService;
|
import org.nl.system.service.menu.ISysMenuService;
|
||||||
import org.nl.system.service.menu.dao.SysMenu;
|
import org.nl.system.service.menu.dao.SysMenu;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
|
import org.nl.system.service.menu.dto.MenuQuery;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -30,48 +32,32 @@ import java.util.stream.Collectors;
|
|||||||
* @since 2022-12-15
|
* @since 2022-12-15
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api/sysMenu")
|
@RequestMapping("api/menus")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SysMenuController {
|
public class SysMenuController {
|
||||||
private final ISysMenuService baseService;
|
private final ISysMenuService iSysMenuService;
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
@ApiOperation("查询菜单")
|
|
||||||
@SaCheckPermission("menu:list")
|
|
||||||
public ResponseEntity<Object> pageQuery(@RequestParam Map param, Pageable page) throws Exception {
|
|
||||||
TableDataInfo data = TableDataInfo.build(baseService.queryAll(param));
|
|
||||||
return new ResponseEntity<>(data, HttpStatus.OK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("返回全部的菜单")
|
|
||||||
@GetMapping(value = "/lazy")//新增时候点击
|
|
||||||
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
|
||||||
public ResponseEntity<Object> query(@RequestParam String pid) {
|
|
||||||
return new ResponseEntity<>(baseService.getMenus(pid), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
|
||||||
@PostMapping("/superior")
|
|
||||||
@SaCheckPermission("menu:list")
|
|
||||||
public ResponseEntity<Object> getSuperior(@RequestBody List<String> ids) {
|
|
||||||
Set<MenuDto> menuDtos = new LinkedHashSet<>();
|
|
||||||
if (CollectionUtil.isNotEmpty(ids)) {
|
|
||||||
for (String id : ids) {
|
|
||||||
MenuDto menuDto = baseService.doToDto(baseService.findById(id));
|
|
||||||
menuDtos.addAll(baseService.getSuperior(menuDto, new ArrayList<>()));
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(baseService.buildTree(new ArrayList<>(menuDtos)), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(baseService.getMenus(null), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(value = "/build")
|
@GetMapping(value = "/build")
|
||||||
@ApiOperation("根据用户获取菜单")
|
@ApiOperation("根据用户获取菜单")
|
||||||
public ResponseEntity<Object> buildMenus() {
|
public ResponseEntity<Object> buildMenus(@Validated String systemType) {
|
||||||
List<MenuDto> menuDtoList = baseService.findByUser(SecurityUtils.getCurrentUserId());
|
//校验系统表是否存在该系统类型
|
||||||
List<MenuDto> menuDtos = baseService.buildTree(menuDtoList);
|
return new ResponseEntity(iSysMenuService.buildMenus(systemType),HttpStatus.OK);
|
||||||
return new ResponseEntity<>(baseService.buildMenus(menuDtos), HttpStatus.OK);
|
}
|
||||||
|
|
||||||
|
@ApiOperation("返回全部的菜单")
|
||||||
|
@GetMapping(value = "/lazy")
|
||||||
|
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||||
|
public ResponseEntity<Object> query(@RequestParam String pid) {
|
||||||
|
return new ResponseEntity<>(iSysMenuService.getMenus(pid), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
@ApiOperation("获取菜单列表")
|
||||||
|
@PostMapping(value = "/getMenusByRole")
|
||||||
|
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||||
|
public ResponseEntity<Object> getMenusByRole(@RequestBody JSONObject json) {
|
||||||
|
String role_id = json.getString("role_id");
|
||||||
|
String system_type = json.getString("system_type");
|
||||||
|
String category = json.getString("category");
|
||||||
|
return new ResponseEntity<>(iSysMenuService.getMenusByRole(role_id, system_type, category), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||||
@@ -79,19 +65,40 @@ public class SysMenuController {
|
|||||||
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||||
public ResponseEntity<Object> child(@RequestParam String id) {
|
public ResponseEntity<Object> child(@RequestParam String id) {
|
||||||
Set<SysMenu> menuSet = new HashSet<>();
|
Set<SysMenu> menuSet = new HashSet<>();
|
||||||
List<SysMenu> menuList = baseService.getMenus(id);
|
List<SysMenu> menuList = iSysMenuService.getMenus(id);
|
||||||
menuSet.add(baseService.findById(id));
|
menuSet.add(iSysMenuService.findById(id));
|
||||||
menuSet = baseService.getChildMenus(menuList, menuSet);
|
menuSet = iSysMenuService.getChildMenus(menuList, menuSet);
|
||||||
Set<String> ids = menuSet.stream().map(SysMenu::getMenuId).collect(Collectors.toSet());
|
Set<String> ids = menuSet.stream().map(SysMenu::getMenuId).collect(Collectors.toSet());
|
||||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@ApiOperation("查询菜单")
|
||||||
|
@SaCheckPermission("menu:list")
|
||||||
|
public ResponseEntity<Object> pageQuery(@RequestBody MenuQuery query, PageQuery page) throws Exception {
|
||||||
|
List list = iSysMenuService.query(query, page);
|
||||||
|
return new ResponseEntity<>(TableDataInfo.build(list), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||||
|
@PostMapping("/superior")
|
||||||
|
@SaCheckPermission("menu:list")
|
||||||
|
public ResponseEntity<Object> getSuperior(@RequestBody JSONObject param) {
|
||||||
|
Set<MenuDto> menuDtos = new LinkedHashSet<>();
|
||||||
|
String id=param.getString("ids");
|
||||||
|
if (StrUtil.isNotEmpty(id)) {
|
||||||
|
menuDtos.addAll(iSysMenuService.getSuperior(iSysMenuService.doToDto(iSysMenuService.findById(id)), new ArrayList<>()));
|
||||||
|
return new ResponseEntity<>(iSysMenuService.buildTree(new ArrayList<>(menuDtos)), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(iSysMenuService.getMenus(null), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@Log("新增菜单")
|
@Log("新增菜单")
|
||||||
@ApiOperation("新增菜单")
|
@ApiOperation("新增菜单")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@SaCheckPermission("menu:add")
|
@SaCheckPermission("menu:add")
|
||||||
public ResponseEntity<Object> create(@Validated @RequestBody SysMenu resources) {
|
public ResponseEntity<Object> create(@Validated @RequestBody SysMenu form) {
|
||||||
baseService.create(resources);
|
iSysMenuService.create(form);
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +106,8 @@ public class SysMenuController {
|
|||||||
@ApiOperation("修改菜单")
|
@ApiOperation("修改菜单")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@SaCheckPermission("menu:edit")
|
@SaCheckPermission("menu:edit")
|
||||||
public ResponseEntity<Object> update(@RequestBody SysMenu resources) {
|
public ResponseEntity<Object> update( @RequestBody SysMenu form) {
|
||||||
baseService.update(resources);
|
iSysMenuService.update(form);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,12 +118,11 @@ public class SysMenuController {
|
|||||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||||
Set<SysMenu> menuSet = new HashSet<>();
|
Set<SysMenu> menuSet = new HashSet<>();
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
//获取所有子节点
|
List<SysMenu> menuList = iSysMenuService.getMenus(id);
|
||||||
List<SysMenu> menuList = baseService.getMenus(id);
|
menuSet.add(iSysMenuService.findById(id));
|
||||||
menuSet.add(baseService.findById(id));
|
menuSet = iSysMenuService.getChildMenus(menuList, menuSet);
|
||||||
menuSet = baseService.getChildMenus(menuList, menuSet);
|
|
||||||
}
|
}
|
||||||
baseService.delete(menuSet);
|
iSysMenuService.delete(menuSet);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package org.nl.system.service.menu;
|
package org.nl.system.service.menu;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.modules.system.domain.vo.MenuVo;
|
import org.nl.modules.system.domain.vo.MenuVo;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
|
||||||
import org.nl.system.service.menu.dao.SysMenu;
|
import org.nl.system.service.menu.dao.SysMenu;
|
||||||
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
|
import org.nl.system.service.menu.dto.MenuQuery;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -26,6 +28,14 @@ public interface ISysMenuService extends IService<SysMenu> {
|
|||||||
*/
|
*/
|
||||||
List<MenuDto> queryAll(Map<String, Object> param);
|
List<MenuDto> queryAll(Map<String, Object> param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件查询
|
||||||
|
* @param query
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List query(MenuQuery query, PageQuery page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取同级与上级数据
|
* 根据ID获取同级与上级数据
|
||||||
*
|
*
|
||||||
@@ -98,6 +108,9 @@ public interface ISysMenuService extends IService<SysMenu> {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
List<MenuVo> buildMenus(List<MenuDto> menuDtos);
|
List<MenuVo> buildMenus(List<MenuDto> menuDtos);
|
||||||
|
List<MenuVo> buildMenus(List<MenuDto> menuDtos,String pid);
|
||||||
|
|
||||||
|
List<MenuVo> buildMenus(String systemType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建菜单树
|
* 构建菜单树
|
||||||
@@ -121,4 +134,6 @@ public interface ISysMenuService extends IService<SysMenu> {
|
|||||||
*/
|
*/
|
||||||
MenuDto doToDto(SysMenu sysMenu);
|
MenuDto doToDto(SysMenu sysMenu);
|
||||||
|
|
||||||
|
List<Map> getMenusByRole(String roleId, String systemType, String category);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Select;
|
|||||||
import org.nl.system.service.menu.dao.SysMenu;
|
import org.nl.system.service.menu.dao.SysMenu;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -31,6 +32,14 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||||||
*/
|
*/
|
||||||
List<SysMenu> findByUser(@Param("userId") String userId);
|
List<SysMenu> findByUser(@Param("userId") String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统菜单
|
||||||
|
* @param userId
|
||||||
|
* @param systemType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysMenu> findSystemMenu(@Param("user") String userId,@Param("systemType") String systemType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户标识获取权限列表
|
* 根据用户标识获取权限列表
|
||||||
*
|
*
|
||||||
@@ -46,4 +55,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||||||
*/
|
*/
|
||||||
@Delete(value = "delete from sys_roles_menus where menu_id = #{menuId}")
|
@Delete(value = "delete from sys_roles_menus where menu_id = #{menuId}")
|
||||||
void untiedMenu(String menuId);
|
void untiedMenu(String menuId);
|
||||||
|
|
||||||
|
List<Map> getMenusByRole(@Param("systemType") String systemType, @Param("category")String category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,4 +51,38 @@
|
|||||||
AND permission IS NOT NULL
|
AND permission IS NOT NULL
|
||||||
AND permission != ''
|
AND permission != ''
|
||||||
</select>
|
</select>
|
||||||
|
<select id="findSystemMenu" resultType="org.nl.system.service.menu.dao.SysMenu">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
sys_menu
|
||||||
|
WHERE
|
||||||
|
type != '2'
|
||||||
|
and system_type = #{systemType}
|
||||||
|
and
|
||||||
|
menu_id IN (
|
||||||
|
SELECT
|
||||||
|
menu_id
|
||||||
|
FROM
|
||||||
|
sys_roles_menus
|
||||||
|
WHERE
|
||||||
|
role_id IN ( SELECT role_id FROM sys_users_roles where user_id = #{user})
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
<select id="getMenusByRole" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
m.* ,
|
||||||
|
(CASE WHEN rm.menu_id IS NULL THEN '0' ELSE '1' END ) AS is_checked ,
|
||||||
|
(CASE WHEN 0 >= sub_count THEN true ELSE false END ) AS leaf
|
||||||
|
FROM
|
||||||
|
sys_menu m
|
||||||
|
LEFT JOIN sys_roles_menus rm ON m.menu_id = rm.menu_id
|
||||||
|
where (pid is null or pid=0)
|
||||||
|
<if test="systemType != null">
|
||||||
|
and system_type = #{systemType}
|
||||||
|
</if>
|
||||||
|
<if test="category != null">
|
||||||
|
and category = #{category}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -13,29 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.nl.modules.system.service.dto;
|
package org.nl.system.service.menu.dto;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.Setter;
|
|
||||||
import org.nl.modules.common.base.BaseDTO;
|
import org.nl.modules.common.base.BaseDTO;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
@Data
|
||||||
* @author Zheng Jie
|
|
||||||
* @date 2018-12-17
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class MenuDto extends BaseDTO implements Serializable {
|
public class MenuDto extends BaseDTO implements Serializable {
|
||||||
|
|
||||||
private String menuId;
|
private String menuId;
|
||||||
|
|
||||||
private List<MenuDto> children;
|
private List<MenuDto> children;
|
||||||
|
|
||||||
private Integer type;
|
private String type;
|
||||||
|
|
||||||
private String permission;
|
private String permission;
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.nl.system.service.menu.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.nl.common.domain.query.BaseQuery;
|
||||||
|
import org.nl.common.domain.query.QParam;
|
||||||
|
import org.nl.common.enums.QueryTEnum;
|
||||||
|
import org.nl.system.service.dict.dao.Dict;
|
||||||
|
import org.nl.system.service.menu.dao.SysMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: lyd
|
||||||
|
* @Description:
|
||||||
|
* @Date: 2022/12/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MenuQuery extends BaseQuery<SysMenu> {
|
||||||
|
private String pid = " ";
|
||||||
|
@Override
|
||||||
|
public void paramMapping() {
|
||||||
|
this.doP.put("pid", QParam.builder().k(new String[]{"pid"}).type(QueryTEnum.OREQ).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,16 +4,24 @@ import cn.hutool.core.map.MapUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.modules.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.system.domain.vo.MenuMetaVo;
|
import org.nl.modules.system.domain.vo.MenuMetaVo;
|
||||||
import org.nl.modules.system.domain.vo.MenuVo;
|
import org.nl.modules.system.domain.vo.MenuVo;
|
||||||
import org.nl.modules.system.service.dto.MenuDto;
|
import org.nl.modules.system.util.CopyUtil;
|
||||||
import org.nl.modules.tools.IdUtil;
|
import org.nl.modules.tools.IdUtil;
|
||||||
|
import org.nl.system.service.dict.dao.Dict;
|
||||||
|
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||||
|
import org.nl.system.service.menu.dto.MenuDto;
|
||||||
import org.nl.system.service.menu.ISysMenuService;
|
import org.nl.system.service.menu.ISysMenuService;
|
||||||
import org.nl.system.service.menu.dao.SysMenu;
|
import org.nl.system.service.menu.dao.SysMenu;
|
||||||
|
import org.nl.system.service.menu.dto.MenuQuery;
|
||||||
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -34,6 +42,7 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
||||||
private final SysMenuMapper baseMapper;
|
private final SysMenuMapper baseMapper;
|
||||||
|
private final SysDictMapper sysDictMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuDto> queryAll(Map<String, Object> param) {
|
public List<MenuDto> queryAll(Map<String, Object> param) {
|
||||||
@@ -42,6 +51,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
return getMenus(pid).stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
return getMenus(pid).stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List query(MenuQuery query, PageQuery page) {
|
||||||
|
Page<SysMenu> menuPage = this.page(page.build(), query.build());
|
||||||
|
List<MenuDto> collect = menuPage.getRecords().stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
||||||
|
return collect;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuDto> getSuperior(MenuDto menuDto, List<SysMenu> menus) {
|
public List<MenuDto> getSuperior(MenuDto menuDto, List<SysMenu> menus) {
|
||||||
if (menuDto.getPid() == null) {
|
if (menuDto.getPid() == null) {
|
||||||
@@ -83,7 +100,6 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void create(SysMenu resources) {
|
public void create(SysMenu resources) {
|
||||||
|
|
||||||
if (resources.getPid().equals("0")) {
|
if (resources.getPid().equals("0")) {
|
||||||
resources.setPid(null);
|
resources.setPid(null);
|
||||||
}
|
}
|
||||||
@@ -185,7 +201,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
if (!menuDTO.getIFrame()) {
|
if (!menuDTO.getIFrame()) {
|
||||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && menuDTO.getType() == 0) {
|
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||||
|
|
||||||
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||||
@@ -262,8 +278,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
public MenuDto doToDto(SysMenu entity) {
|
public MenuDto doToDto(SysMenu entity) {
|
||||||
|
|
||||||
MenuDto menuDto = new MenuDto();
|
MenuDto menuDto = new MenuDto();
|
||||||
|
if (ObjectUtil.isEmpty(entity)){
|
||||||
|
return menuDto;
|
||||||
|
}
|
||||||
menuDto.setMenuId(entity.getMenuId());
|
menuDto.setMenuId(entity.getMenuId());
|
||||||
menuDto.setType(Integer.parseInt(entity.getType()));
|
menuDto.setType(entity.getType());
|
||||||
menuDto.setPermission(entity.getPermission());
|
menuDto.setPermission(entity.getPermission());
|
||||||
menuDto.setTitle(entity.getTitle());
|
menuDto.setTitle(entity.getTitle());
|
||||||
menuDto.setMenuSort(entity.getMenuSort());
|
menuDto.setMenuSort(entity.getMenuSort());
|
||||||
@@ -289,4 +308,77 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
return menuDto;
|
return menuDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MenuVo> buildMenus(String systemType) {
|
||||||
|
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", "system_type").eq("value", systemType));
|
||||||
|
if (dict == null || StringUtils.isEmpty(dict.getPara1())){
|
||||||
|
throw new BadRequestException("获取对应的系统菜单不存在");
|
||||||
|
}
|
||||||
|
String pid = dict.getPara1();
|
||||||
|
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(),systemType);
|
||||||
|
//移除系统级菜单
|
||||||
|
menuDtoList.removeIf(a->a.getMenuId().equals(pid));
|
||||||
|
List<MenuDto> menuDtos = this.buildTree(CopyUtil.copyList(menuDtoList, MenuDto.class));
|
||||||
|
return this.buildMenus(menuDtos,pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MenuVo> buildMenus(List<MenuDto> menuDtos, String pid) {
|
||||||
|
List<MenuVo> list = new LinkedList<>();
|
||||||
|
//剔除系统级菜单
|
||||||
|
menuDtos.forEach(menuDTO -> {
|
||||||
|
if (menuDTO != null) {
|
||||||
|
List<MenuDto> menuDtoList = menuDTO.getChildren();
|
||||||
|
MenuVo menuVo = new MenuVo();
|
||||||
|
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getTitle());
|
||||||
|
// 一级目录需要加斜杠,不然会报警告
|
||||||
|
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||||
|
menuVo.setHidden(menuDTO.getHidden());
|
||||||
|
// 如果不是外链
|
||||||
|
if (!menuDTO.getIFrame()) {
|
||||||
|
if (pid.equals(menuDTO.getPid())) {
|
||||||
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||||
|
} else if (!pid.equals(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||||
|
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||||
|
|
||||||
|
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||||
|
menuVo.setComponent(menuDTO.getComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(), menuDTO.getIcon(), !menuDTO.getCache()));
|
||||||
|
if (menuDtoList != null && menuDtoList.size() != 0) {
|
||||||
|
menuVo.setAlwaysShow(true);
|
||||||
|
menuVo.setRedirect("noredirect");
|
||||||
|
menuVo.setChildren(buildMenus(menuDtoList,pid));
|
||||||
|
// 处理是一级菜单并且没有子菜单的情况
|
||||||
|
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||||
|
MenuVo menuVo1 = new MenuVo();
|
||||||
|
menuVo1.setMeta(menuVo.getMeta());
|
||||||
|
// 非外链
|
||||||
|
if (!menuDTO.getIFrame()) {
|
||||||
|
menuVo1.setPath("index");
|
||||||
|
menuVo1.setName(menuVo.getName());
|
||||||
|
menuVo1.setComponent(menuVo.getComponent());
|
||||||
|
} else {
|
||||||
|
menuVo1.setPath(menuDTO.getPath());
|
||||||
|
}
|
||||||
|
menuVo.setName(null);
|
||||||
|
menuVo.setMeta(null);
|
||||||
|
menuVo.setComponent("Layout");
|
||||||
|
List<MenuVo> list1 = new ArrayList<>();
|
||||||
|
list1.add(menuVo1);
|
||||||
|
menuVo.setChildren(list1);
|
||||||
|
}
|
||||||
|
list.add(menuVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map> getMenusByRole(String roleId, String systemType, String category) {
|
||||||
|
baseMapper.getMenusByRole(systemType,category);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|||||||
@@ -227,8 +227,7 @@ public class OnlineUserService {
|
|||||||
// 校验数据库
|
// 校验数据库
|
||||||
// 根据用户名查询,在比对密码
|
// 根据用户名查询,在比对密码
|
||||||
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username",authUser.getUsername()));
|
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username",authUser.getUsername()));
|
||||||
String dbPassword = userInfo.getPassword();
|
if (userInfo == null||!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
||||||
if (!dbPassword.equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
|
||||||
throw new BadRequestException("账号或密码错误");
|
throw new BadRequestException("账号或密码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function getChild(id) {
|
|||||||
|
|
||||||
export function buildMenus(data) {
|
export function buildMenus(data) {
|
||||||
return request({
|
return request({
|
||||||
url: 'api/sysMenu/build?system_type=' + data,
|
url: 'api/sysMenu/build?systemType=' + data,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const loadMenus = (next, to) => {
|
export const loadMenus = (next, to) => {
|
||||||
buildMenus().then(res => {
|
buildMenus(1).then(res => {
|
||||||
const sdata = JSON.parse(JSON.stringify(res))
|
const sdata = JSON.parse(JSON.stringify(res))
|
||||||
const rdata = JSON.parse(JSON.stringify(res))
|
const rdata = JSON.parse(JSON.stringify(res))
|
||||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||||
|
|||||||
@@ -66,6 +66,8 @@
|
|||||||
v-model="form.isUsed"
|
v-model="form.isUsed"
|
||||||
active-color="#409EFF"
|
active-color="#409EFF"
|
||||||
inactive-color="#F56C6C"
|
inactive-color="#F56C6C"
|
||||||
|
active-value = 'true'
|
||||||
|
inactive-valu='false'
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="form.isTop === '0'" style="margin-bottom: 0;" label="上级部门" prop="pid">
|
<el-form-item v-if="form.isTop === '0'" style="margin-bottom: 0;" label="上级部门" prop="pid">
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
export function get(dictName) {
|
export function get(code) {
|
||||||
const params = {
|
const params = {
|
||||||
dictName,
|
code,
|
||||||
page: 0,
|
page: 0,
|
||||||
size: 9999
|
size: 9999
|
||||||
}
|
}
|
||||||
|
|||||||
304
nladmin-ui/src/views/system/menu/dd/index.vue
Normal file
304
nladmin-ui/src/views/system/menu/dd/index.vue
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!--工具栏-->
|
||||||
|
<div class="head-container">
|
||||||
|
<div v-if="crud.props.searchToggle">
|
||||||
|
<!-- 搜索 -->
|
||||||
|
<el-input
|
||||||
|
v-model="query.blurry"
|
||||||
|
clearable
|
||||||
|
size="mini"
|
||||||
|
placeholder="模糊搜索"
|
||||||
|
style="width: 200px;"
|
||||||
|
class="filter-item"
|
||||||
|
@keyup.enter.native="crud.toQuery"
|
||||||
|
/>
|
||||||
|
<rrOperation />
|
||||||
|
</div>
|
||||||
|
<crudOperation :permission="permission" />
|
||||||
|
</div>
|
||||||
|
<!--表单渲染-->
|
||||||
|
<el-dialog
|
||||||
|
append-to-body
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:before-close="crud.cancelCU"
|
||||||
|
:visible.sync="crud.status.cu > 0"
|
||||||
|
:title="crud.status.title"
|
||||||
|
width="650px"
|
||||||
|
>
|
||||||
|
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||||
|
<el-form-item label="菜单类型" prop="type">
|
||||||
|
<el-radio-group v-model="form.type" size="mini">
|
||||||
|
<el-radio-button label="1">系统</el-radio-button>
|
||||||
|
<el-radio-button label="2">目录</el-radio-button>
|
||||||
|
<el-radio-button label="3">菜单</el-radio-button>
|
||||||
|
<el-radio-button label="4">按钮</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="form.type.toString() !== '1' && form.type.toString() !== '4' " label="菜单图标" prop="icon">
|
||||||
|
<el-popover
|
||||||
|
placement="bottom-start"
|
||||||
|
width="450"
|
||||||
|
trigger="click"
|
||||||
|
@show="$refs['iconSelect'].reset()"
|
||||||
|
>
|
||||||
|
<IconSelect ref="iconSelect" @selected="selected" />
|
||||||
|
<el-input slot="reference" v-model="form.icon" style="width: 450px;" placeholder="点击选择图标" readonly>
|
||||||
|
<svg-icon
|
||||||
|
v-if="form.icon"
|
||||||
|
slot="prefix"
|
||||||
|
:icon-class="form.icon"
|
||||||
|
class="el-input__icon"
|
||||||
|
style="height: 32px;width: 16px;"
|
||||||
|
/>
|
||||||
|
<i v-else slot="prefix" class="el-icon-search el-input__icon" />
|
||||||
|
</el-input>
|
||||||
|
</el-popover>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1'" label="外链菜单" prop="iframe">
|
||||||
|
<el-radio-group v-model="form.iframe" size="mini">
|
||||||
|
<el-radio-button label="1">是</el-radio-button>
|
||||||
|
<el-radio-button label="0">否</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="form.type.toString() === '2'" label="菜单缓存" prop="cache">
|
||||||
|
<el-radio-group v-model="form.cache" size="mini">
|
||||||
|
<el-radio-button label="1">是</el-radio-button>
|
||||||
|
<el-radio-button label="0">否</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1' " label="菜单可见" prop="hidden">
|
||||||
|
<el-radio-group v-model="form.hidden" size="mini">
|
||||||
|
<el-radio-button label="1">是</el-radio-button>
|
||||||
|
<el-radio-button label="0">否</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.type.toString() !== '2'" label="菜单标题" prop="title">
|
||||||
|
<el-input
|
||||||
|
v-model="form.title"
|
||||||
|
:style=" form.type.toString() === '0' ? 'width: 450px' : 'width: 190px'"
|
||||||
|
placeholder="菜单标题"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.type.toString() === '2'" label="按钮名称" prop="title">
|
||||||
|
<el-input v-model="form.title" placeholder="按钮名称" style="width: 190px;" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="form.type.toString() !== '1' " label="权限标识" prop="permission">
|
||||||
|
<el-input v-model="form.permission" :disabled="form.iframe=='1'" placeholder="权限标识" style="width: 190px;" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.type.toString() !== '1' && form.type.toString() !== '2'" label="路由地址" prop="path">
|
||||||
|
<el-input v-model="form.path" placeholder="路由地址" style="width: 190px;" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="菜单排序" prop="menuSort">
|
||||||
|
<el-input-number
|
||||||
|
v-model.number="form.menuSort"
|
||||||
|
:min="0"
|
||||||
|
:max="999"
|
||||||
|
controls-position="right"
|
||||||
|
style="width: 190px;"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="!form.iframe && form.type.toString() === '3' " label="组件名称" prop="componentName">
|
||||||
|
<el-input v-model="form.componentName" style="width: 190px;" placeholder="匹配组件内Name字段" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="!form.iframe && (form.type.toString() === '2' ||form.type.toString() === '3' ) " label="组件路径" prop="component">
|
||||||
|
<el-input v-model="form.component" style="width: 190px;" placeholder="组件路径" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="上级类目" prop="pid">
|
||||||
|
<!-- normalizer转换- loadMenus 点击扩展的时候会调用该方法-->
|
||||||
|
<treeselect
|
||||||
|
v-model="form.pid"
|
||||||
|
:options="menus"
|
||||||
|
:load-options="loadMenus"
|
||||||
|
:normalizer="normalizer"
|
||||||
|
style="width: 450px;"
|
||||||
|
placeholder="选择上级类目"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||||
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
<!--表格渲染-->
|
||||||
|
<el-table
|
||||||
|
ref="table"
|
||||||
|
v-loading="crud.loading"
|
||||||
|
lazy
|
||||||
|
:load="getMenus"
|
||||||
|
:auto-load-root-options="false"
|
||||||
|
:data="crud.data"
|
||||||
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
row-key="menuId"
|
||||||
|
|
||||||
|
@select="crud.selectChange"
|
||||||
|
@select-all="crud.selectAllChange"
|
||||||
|
@selection-change="crud.selectionChangeHandler"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column label="菜单标题" prop="title" :min-width="flexWidth('title',crud.data,'菜单标题')" />
|
||||||
|
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')" />
|
||||||
|
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<svg-icon :icon-class="scope.row.icon ? scope.row.icon : ''" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="menuSort" align="center" label="排序" :min-width="flexWidth('menuSort',crud.data,'排序')">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.menuSort }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
|
||||||
|
<el-table-column prop="component" label="组件路径" min-width="120" />
|
||||||
|
<el-table-column prop="iframe" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('iframe',crud.data,'外链')" />
|
||||||
|
|
||||||
|
<el-table-column prop="cache" label="缓存" :formatter="crud.formatIsOrNot" :min-width="flexWidth('cache',crud.data,'缓存')" />
|
||||||
|
<el-table-column prop="hidden" label="可见" :formatter="crud.formatIsOrNot" :min-width="flexWidth('hidden',crud.data,'可见')" />
|
||||||
|
<el-table-column prop="createTime" label="创建日期" :min-width="flexWidth('createTime',crud.data,'创建日期')" />
|
||||||
|
<el-table-column
|
||||||
|
v-permission="['admin','menu:edit','menu:del']"
|
||||||
|
label="操作"
|
||||||
|
width="130px"
|
||||||
|
align="center"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<udOperation
|
||||||
|
:data="scope.row"
|
||||||
|
:permission="permission"
|
||||||
|
msg="确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import crudMenu from '@/api/system/menu'
|
||||||
|
import IconSelect from '@/components/IconSelect'
|
||||||
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||||
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||||
|
import rrOperation from '@crud/RR.operation'
|
||||||
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
|
import udOperation from '@crud/UD.operation'
|
||||||
|
|
||||||
|
// crud交由presenter持有
|
||||||
|
const defaultForm = {
|
||||||
|
menuId: null,
|
||||||
|
title: null,
|
||||||
|
menuSort: 999,
|
||||||
|
path: null,
|
||||||
|
system_type: null,
|
||||||
|
category: null,
|
||||||
|
component: null,
|
||||||
|
componentName: null,
|
||||||
|
iframe: 0,
|
||||||
|
roles: [],
|
||||||
|
pid: 0,
|
||||||
|
icon: null,
|
||||||
|
cache: 0,
|
||||||
|
hidden: 0,
|
||||||
|
type: 0,
|
||||||
|
permission: null
|
||||||
|
}
|
||||||
|
export default {
|
||||||
|
name: 'Menu',
|
||||||
|
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation },
|
||||||
|
cruds() {
|
||||||
|
return CRUD({ title: '菜单', idField: 'menuId', url: 'api/sysMenu', crudMethod: { ...crudMenu }})
|
||||||
|
},
|
||||||
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
menus: [],
|
||||||
|
permission: {
|
||||||
|
add: ['admin', 'menu:add'],
|
||||||
|
edit: ['admin', 'menu:edit'],
|
||||||
|
del: ['admin', 'menu:del']
|
||||||
|
},
|
||||||
|
normalizer(node) {
|
||||||
|
return {
|
||||||
|
id: node.menuId,
|
||||||
|
label: node.title,
|
||||||
|
children: node.children
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
title: [
|
||||||
|
{ required: true, message: '请输入标题', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
path: [
|
||||||
|
{ required: true, message: '请输入地址', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 新增与编辑前做的操作
|
||||||
|
[CRUD.HOOK.afterToCU](crud, form) {
|
||||||
|
this.menus = []
|
||||||
|
if (form.menuId) { // 修改
|
||||||
|
if (!form.pid) { // 一级菜单,一级的父级菜单的pid为0.
|
||||||
|
form.pid = 0
|
||||||
|
}
|
||||||
|
this.getSupDepts(form.menuId)
|
||||||
|
} else { // 新增
|
||||||
|
this.menus.push({ menuId: 0, title: '顶级类目', children: null })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getMenus(tree, treeNode, resolve) {
|
||||||
|
const params = { pid: tree.menuId }
|
||||||
|
setTimeout(() => {
|
||||||
|
crudMenu.getMenus(params).then(res => {
|
||||||
|
resolve(res.content)
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
|
getSupDepts(menuId) {
|
||||||
|
crudMenu.getMenuSuperior(menuId).then(res => {
|
||||||
|
const children = res.map(function(obj) {
|
||||||
|
if (!obj.leaf && !obj.children) {
|
||||||
|
obj.children = null
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
this.menus = [{ menuId: 0, title: '顶级类目', children: children }]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadMenus({ action, parentNode, callback }) {
|
||||||
|
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||||
|
crudMenu.getMenusTree(parentNode.menuId).then(res => {
|
||||||
|
parentNode.children = res.map(function(obj) {
|
||||||
|
if (!obj.leaf) {
|
||||||
|
obj.children = null
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
callback()
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 选中图标
|
||||||
|
selected(name) {
|
||||||
|
this.form.icon = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||||
|
::v-deep .el-input-number .el-input__inner {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .vue-treeselect__control, ::v-deep .vue-treeselect__placeholder, ::v-deep .vue-treeselect__single-value {
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -9,13 +9,25 @@
|
|||||||
clearable
|
clearable
|
||||||
size="mini"
|
size="mini"
|
||||||
placeholder="模糊搜索"
|
placeholder="模糊搜索"
|
||||||
style="width: 200px;"
|
style="width: 200px;margin-bottom: 10px"
|
||||||
class="filter-item"
|
class="filter-item"
|
||||||
@keyup.enter.native="crud.toQuery"
|
@keyup.enter.native="queryBlurry"
|
||||||
/>
|
/>
|
||||||
|
<el-select
|
||||||
|
style="width: 100px; height: 35px;top: -5px;"
|
||||||
|
v-model="query.system_type"
|
||||||
|
placeholder="切换系统"
|
||||||
|
@change="changetype"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in dict.system_type"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
<rrOperation />
|
<rrOperation />
|
||||||
</div>
|
</div>
|
||||||
<crudOperation :permission="permission" />
|
<crudOperation :permission="permission"/>
|
||||||
</div>
|
</div>
|
||||||
<!--表单渲染-->
|
<!--表单渲染-->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
@@ -55,8 +67,8 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1'" label="外链菜单" prop="iframe">
|
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1'" label="外链菜单" prop="i_frame">
|
||||||
<el-radio-group v-model="form.iframe" size="mini">
|
<el-radio-group v-model="form.i_frame" size="mini">
|
||||||
<el-radio-button label="1">是</el-radio-button>
|
<el-radio-button label="1">是</el-radio-button>
|
||||||
<el-radio-button label="0">否</el-radio-button>
|
<el-radio-button label="0">否</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
@@ -69,8 +81,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1' " label="菜单可见" prop="hidden">
|
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1' " label="菜单可见" prop="hidden">
|
||||||
<el-radio-group v-model="form.hidden" size="mini">
|
<el-radio-group v-model="form.hidden" size="mini">
|
||||||
<el-radio-button label="1">是</el-radio-button>
|
<el-radio-button label="0">是</el-radio-button>
|
||||||
<el-radio-button label="0">否</el-radio-button>
|
<el-radio-button label="1">否</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="form.type.toString() !== '2'" label="菜单标题" prop="title">
|
<el-form-item v-if="form.type.toString() !== '2'" label="菜单标题" prop="title">
|
||||||
@@ -84,7 +96,7 @@
|
|||||||
<el-input v-model="form.title" placeholder="按钮名称" style="width: 190px;" />
|
<el-input v-model="form.title" placeholder="按钮名称" style="width: 190px;" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-show="form.type.toString() !== '1' " label="权限标识" prop="permission">
|
<el-form-item v-show="form.type.toString() !== '1' " label="权限标识" prop="permission">
|
||||||
<el-input v-model="form.permission" :disabled="form.iframe=='1'" placeholder="权限标识" style="width: 190px;" />
|
<el-input v-model="form.permission" :disabled="form.i_frame=='1'" placeholder="权限标识" style="width: 190px;" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="form.type.toString() !== '1' && form.type.toString() !== '2'" label="路由地址" prop="path">
|
<el-form-item v-if="form.type.toString() !== '1' && form.type.toString() !== '2'" label="路由地址" prop="path">
|
||||||
<el-input v-model="form.path" placeholder="路由地址" style="width: 190px;" />
|
<el-input v-model="form.path" placeholder="路由地址" style="width: 190px;" />
|
||||||
@@ -98,10 +110,10 @@
|
|||||||
style="width: 190px;"
|
style="width: 190px;"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-show="!form.iframe && form.type.toString() === '3' " label="组件名称" prop="componentName">
|
<el-form-item v-show="!form.i_frame && form.type.toString() === '3' " label="组件名称" prop="componentName">
|
||||||
<el-input v-model="form.componentName" style="width: 190px;" placeholder="匹配组件内Name字段" />
|
<el-input v-model="form.componentName" style="width: 190px;" placeholder="匹配组件内Name字段" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-show="!form.iframe && (form.type.toString() === '2' ||form.type.toString() === '3' ) " label="组件路径" prop="component">
|
<el-form-item v-show="!form.i_frame && (form.type.toString() === '2' ||form.type.toString() === '3' ) " label="组件路径" prop="component">
|
||||||
<el-input v-model="form.component" style="width: 190px;" placeholder="组件路径" />
|
<el-input v-model="form.component" style="width: 190px;" placeholder="组件路径" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="上级类目" prop="pid">
|
<el-form-item label="上级类目" prop="pid">
|
||||||
@@ -130,15 +142,19 @@
|
|||||||
:auto-load-root-options="false"
|
:auto-load-root-options="false"
|
||||||
:data="crud.data"
|
:data="crud.data"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
row-key="menuId"
|
row-key="menu_id"
|
||||||
|
|
||||||
@select="crud.selectChange"
|
@select="crud.selectChange"
|
||||||
@select-all="crud.selectAllChange"
|
@select-all="crud.selectAllChange"
|
||||||
@selection-change="crud.selectionChangeHandler"
|
@selection-change="crud.selectionChangeHandler"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column label="菜单标题" prop="title" :min-width="flexWidth('title',crud.data,'菜单标题')" />
|
<el-table-column label="菜单标题" prop="title" :min-width="100" />
|
||||||
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')" />
|
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ dict.label.system_type[scope.row.system_type] }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<svg-icon :icon-class="scope.row.icon ? scope.row.icon : ''" />
|
<svg-icon :icon-class="scope.row.icon ? scope.row.icon : ''" />
|
||||||
@@ -151,11 +167,25 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
|
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
|
||||||
<el-table-column prop="component" label="组件路径" min-width="120" />
|
<el-table-column prop="component" label="组件路径" min-width="120" />
|
||||||
<el-table-column prop="iframe" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('iframe',crud.data,'外链')" />
|
<el-table-column prop="i_frame" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('i_frame',crud.data,'外链')">
|
||||||
|
<template slot-scope="scope">
|
||||||
<el-table-column prop="cache" label="缓存" :formatter="crud.formatIsOrNot" :min-width="flexWidth('cache',crud.data,'缓存')" />
|
<span v-if="scope.row.i_frame">是</span>
|
||||||
<el-table-column prop="hidden" label="可见" :formatter="crud.formatIsOrNot" :min-width="flexWidth('hidden',crud.data,'可见')" />
|
<span v-else>否</span>
|
||||||
<el-table-column prop="createTime" label="创建日期" :min-width="flexWidth('createTime',crud.data,'创建日期')" />
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="cache" label="缓存" :formatter="crud.formatIsOrNot" :min-width="flexWidth('cache',crud.data,'缓存')">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span v-if="scope.row.cache">是</span>
|
||||||
|
<span v-else>否</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="hidden" label="可见" :formatter="crud.formatIsOrNot" :min-width="flexWidth('hidden',crud.data,'可见')">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span v-if="scope.row.hidden">否</span>
|
||||||
|
<span v-else>是</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="create_time" label="创建日期" :min-width="flexWidth('create_time',crud.data,'创建日期')" />
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-permission="['admin','menu:edit','menu:del']"
|
v-permission="['admin','menu:edit','menu:del']"
|
||||||
label="操作"
|
label="操作"
|
||||||
@@ -176,7 +206,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import crudMenu from '@/api/system/menu'
|
import crudMenu from '@/views/system/menu/menu'
|
||||||
import IconSelect from '@/components/IconSelect'
|
import IconSelect from '@/components/IconSelect'
|
||||||
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'
|
||||||
@@ -185,10 +215,12 @@ import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
|||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
|
import DateRangePicker from '@/components/DateRangePicker'
|
||||||
|
import Dict from "../../../components/Dict/Dict";
|
||||||
|
|
||||||
// crud交由presenter持有
|
// crud交由presenter持有
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
menuId: null,
|
menu_id: null,
|
||||||
title: null,
|
title: null,
|
||||||
menuSort: 999,
|
menuSort: 999,
|
||||||
path: null,
|
path: null,
|
||||||
@@ -196,7 +228,7 @@ const defaultForm = {
|
|||||||
category: null,
|
category: null,
|
||||||
component: null,
|
component: null,
|
||||||
componentName: null,
|
componentName: null,
|
||||||
iframe: 0,
|
i_frame: 0,
|
||||||
roles: [],
|
roles: [],
|
||||||
pid: 0,
|
pid: 0,
|
||||||
icon: null,
|
icon: null,
|
||||||
@@ -207,26 +239,22 @@ const defaultForm = {
|
|||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'Menu',
|
name: 'Menu',
|
||||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation },
|
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||||
cruds() {
|
cruds() {
|
||||||
return CRUD({ title: '菜单', idField: 'menuId', url: 'api/sysMenu', crudMethod: { ...crudMenu }})
|
return CRUD({ title: '菜单', idField: 'menu_id', url: 'api/menus', crudMethod: { ...crudMenu }})
|
||||||
},
|
},
|
||||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
|
dicts: ['system_type'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
typeList: [],
|
||||||
|
defaultType: '',
|
||||||
menus: [],
|
menus: [],
|
||||||
permission: {
|
permission: {
|
||||||
add: ['admin', 'menu:add'],
|
add: ['admin', 'menu:add'],
|
||||||
edit: ['admin', 'menu:edit'],
|
edit: ['admin', 'menu:edit'],
|
||||||
del: ['admin', 'menu:del']
|
del: ['admin', 'menu:del']
|
||||||
},
|
},
|
||||||
normalizer(node) {
|
|
||||||
return {
|
|
||||||
id: node.menuId,
|
|
||||||
label: node.title,
|
|
||||||
children: node.children
|
|
||||||
}
|
|
||||||
},
|
|
||||||
rules: {
|
rules: {
|
||||||
title: [
|
title: [
|
||||||
{ required: true, message: '请输入标题', trigger: 'blur' }
|
{ required: true, message: '请输入标题', trigger: 'blur' }
|
||||||
@@ -238,40 +266,83 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
normalizer(node) {
|
||||||
|
return {
|
||||||
|
id: node.menu_id,
|
||||||
|
label: node.title,
|
||||||
|
children: node.children
|
||||||
|
}
|
||||||
|
},
|
||||||
|
queryBlurry() {
|
||||||
|
if (this.query.blurry) {
|
||||||
|
this.query.pid = null
|
||||||
|
}
|
||||||
|
this.crud.toQuery()
|
||||||
|
},
|
||||||
|
changetype() {
|
||||||
|
const sysType = this.dict.dict.system_type[this.query.system_type]
|
||||||
|
this.query.pid = sysType.para1
|
||||||
|
this.crud.toQuery()
|
||||||
|
},
|
||||||
|
[CRUD.HOOK.beforeRefresh]() {
|
||||||
|
// if (this.crud.query.system_type == null) {
|
||||||
|
// this.crud.query.system_type = '1'
|
||||||
|
// }
|
||||||
|
return true
|
||||||
|
},
|
||||||
// 新增与编辑前做的操作
|
// 新增与编辑前做的操作
|
||||||
[CRUD.HOOK.afterToCU](crud, form) {
|
[CRUD.HOOK.afterToCU](crud, form) {
|
||||||
|
console.log(this.dict)
|
||||||
this.menus = []
|
this.menus = []
|
||||||
if (form.menuId) { // 修改
|
if (form.menu_id) { // 修改
|
||||||
if (!form.pid) { // 一级菜单,一级的父级菜单的pid为0.
|
if (!form.pid) { // 一级菜单,一级的父级菜单的pid为0.
|
||||||
form.pid = 0
|
form.pid = 0
|
||||||
}
|
}
|
||||||
this.getSupDepts(form.menuId)
|
this.getSupDepts(form.menu_id)
|
||||||
} else { // 新增
|
} else { // 新增
|
||||||
this.menus.push({ menuId: 0, title: '顶级类目', children: null })
|
this.menus.push({ menu_id: 0, title: '顶级类目', children: null })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[CRUD.HOOK.afterSubmit](crud, form) {
|
||||||
|
if (this.$options.dicts instanceof Array) {
|
||||||
|
new Dict(this.dict).init(this.$options.dicts, () => {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$emit('dictReady')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[CRUD.HOOK.afterDelete](crud, form) {
|
||||||
|
if (this.$options.dicts instanceof Array) {
|
||||||
|
new Dict(this.dict).init(this.$options.dicts, () => {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$emit('dictReady')
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getMenus(tree, treeNode, resolve) {
|
getMenus(tree, treeNode, resolve) {
|
||||||
const params = { pid: tree.menuId }
|
const params = { pid: tree.menu_id, system_type: tree.system_type }
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
crudMenu.getMenus(params).then(res => {
|
crudMenu.getMenus(params).then(res => {
|
||||||
resolve(res.content)
|
resolve(res.content)
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
},
|
},
|
||||||
getSupDepts(menuId) {
|
getSupDepts(menu_id) {
|
||||||
crudMenu.getMenuSuperior(menuId).then(res => {
|
crudMenu.getMenuSuperior(menu_id).then(res => {
|
||||||
const children = res.map(function(obj) {
|
const children = res.map(function(obj) {
|
||||||
if (!obj.leaf && !obj.children) {
|
if (!obj.leaf && !obj.children) {
|
||||||
obj.children = null
|
obj.children = null
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
this.menus = [{ menuId: 0, title: '顶级类目', children: children }]
|
this.menus = [{ menu_id: 0, title: '顶级类目', children: children }]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadMenus({ action, parentNode, callback }) {
|
loadMenus({ action, parentNode, callback }) {
|
||||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||||
crudMenu.getMenusTree(parentNode.menuId).then(res => {
|
crudMenu.getMenusTree(parentNode.menu_id).then(res => {
|
||||||
parentNode.children = res.map(function(obj) {
|
parentNode.children = res.map(function(obj) {
|
||||||
if (!obj.leaf) {
|
if (!obj.leaf) {
|
||||||
obj.children = null
|
obj.children = null
|
||||||
|
|||||||
76
nladmin-ui/src/views/system/menu/menu.js
Normal file
76
nladmin-ui/src/views/system/menu/menu.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getMenusTree(pid) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus/lazy?pid=' + pid,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMenus(params) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMenusByRole(params) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus/getMenusByRole',
|
||||||
|
method: 'post',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMenuSuperior(ids) {
|
||||||
|
// const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
|
||||||
|
const data = {
|
||||||
|
'ids': ids
|
||||||
|
}
|
||||||
|
return request({
|
||||||
|
url: 'api/menus/superior',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getChild(id) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus/child?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildMenus(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus/build?system_type=' + data,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function add(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function del(ids) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function edit(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/menus',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { add, edit, del, getMenusTree, getMenuSuperior, getMenus, getChild, getMenusByRole }
|
||||||
Reference in New Issue
Block a user