完善前端框架
This commit is contained in:
parent
3273bc3d86
commit
e4a13c5fb2
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80200
|
||||
Source Host : localhost:3306
|
||||
Source Schema : qihang-oms
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80200
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 24/02/2024 21:21:11
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_menu
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_menu`;
|
||||
CREATE TABLE `sys_menu` (
|
||||
`menu_id` bigint NOT NULL AUTO_INCREMENT COMMENT '菜单ID',
|
||||
`menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单名称',
|
||||
`parent_id` bigint NULL DEFAULT 0 COMMENT '父菜单ID',
|
||||
`order_num` int NULL DEFAULT 0 COMMENT '显示顺序',
|
||||
`path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '路由地址',
|
||||
`component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件路径',
|
||||
`query` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '路由参数',
|
||||
`is_frame` int NULL DEFAULT 1 COMMENT '是否为外链(0是 1否)',
|
||||
`is_cache` int NULL DEFAULT 0 COMMENT '是否缓存(0缓存 1不缓存)',
|
||||
`menu_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单类型(M目录 C菜单 F按钮)',
|
||||
`visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '菜单状态(0显示 1隐藏)',
|
||||
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '菜单状态(0正常 1停用)',
|
||||
`perms` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识',
|
||||
`icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '#' COMMENT '菜单图标',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
||||
PRIMARY KEY (`menu_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2078 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单权限表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_menu` VALUES (1, '淘宝平台', 0, 99, '/tao', 'Layout', '', 1, 0, 'M', '0', '0', '', 'system', 'admin', '2023-12-27 15:00:27', 'admin', '2023-12-29 09:07:42.856856', '系统管理目录');
|
||||
INSERT INTO `sys_menu` VALUES (2, '京东平台', 0, 1, '/jd', 'Layout', '', 1, 0, 'M', '0', '0', '', 'monitor', 'admin', '2023-12-27 15:00:27', 'admin', '2024-01-06 23:55:21', '至简官网地址');
|
||||
INSERT INTO `sys_menu` VALUES (3, '抖店平台', 0, 9, '/dou', 'Layout', '', 1, 0, 'M', '0', '0', '', 'dict', 'admin', '2023-12-29 13:29:44', '', '', '');
|
||||
INSERT INTO `sys_menu` VALUES (4, '拼多多平台', 0, 2, '/pdd', 'Layout', '', 1, 0, 'M', '0', '0', '', 'peoples', 'admin', '2023-12-29 16:53:03', 'admin', '2024-01-03 14:06:38', '');
|
||||
INSERT INTO `sys_menu` VALUES (5, '系统设置', 0, 99, '/system', 'Layout', '', 1, 0, 'M', '0', '0', '', 'system', 'admin', '2023-12-27 15:00:27', 'admin', '2023-12-29 09:07:42.856856', '系统管理目录');
|
||||
INSERT INTO `sys_menu` VALUES (100, '订单管理', 1, 1, 'order_list', 'tao/order/index', '', 1, 0, 'C', '0', '0', '', 'user', 'admin', '2023-12-27 15:00:27', '', '', '用户管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (101, '商品管理', 1, 2, 'tao/goods/list', 'system/role/index', '', 1, 0, 'C', '0', '0', '', 'peoples', 'admin', '2023-12-27 15:00:27', '', '', '角色管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (102, '售后管理', 1, 3, 'tao/refund/list', 'system/menu/index', '', 1, 0, 'C', '0', '0', '', 'monitor', 'admin', '2023-12-27 15:00:27', '', '', '菜单管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (103, '店铺管理', 1, 4, 'tao/shop', 'system/dept/index', '', 1, 0, 'C', '0', '0', '', 'tree', 'admin', '2023-12-27 15:00:27', '', '', '部门管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (104, '订单管理', 2, 5, 'post', 'system/post/index', '', 1, 0, 'C', '0', '0', '', 'tree', 'admin', '2023-12-27 15:00:27', '', '', '岗位管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (105, '商品管理', 2, 6, 'jd/goods/list', 'system/dict/index', '', 1, 0, 'C', '0', '0', '', 'dict', 'admin', '2023-12-27 15:00:27', '', '', '字典管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (106, '售后设置', 2, 7, 'jd/refund/list', 'system/config/index', '', 1, 0, 'C', '0', '0', '', 'edit', 'admin', '2023-12-27 15:00:27', '', '', '参数设置菜单');
|
||||
INSERT INTO `sys_menu` VALUES (107, '店铺管理', 2, 8, 'jd/shop', 'system/notice/index', '', 1, 0, 'C', '0', '0', '', 'monitor', 'admin', '2023-12-27 15:00:27', '', '', '通知公告菜单');
|
||||
INSERT INTO `sys_menu` VALUES (108, '订单管理', 3, 9, 'dou/order/list', 'scm/supplier/index', '', 1, 0, 'C', '0', '0', '', 'tree', 'admin', '2023-12-29 09:14:02', 'admin', '2023-12-29 09:17:27.514466', '');
|
||||
INSERT INTO `sys_menu` VALUES (109, '商品管理', 3, 10, 'dou/goods/list', 'goods/index', '', 1, 0, 'C', '0', '0', '', 'peoples', 'admin', '2023-12-29 13:31:01', 'admin', '2023-12-29 15:02:40.869685', '');
|
||||
INSERT INTO `sys_menu` VALUES (110, '售后管理', 3, 88, 'dou/refund/list', 'goods/category/index', '', 1, 0, 'C', '0', '0', '', 'peoples', 'admin', '2023-12-29 13:32:41', 'admin', '2023-12-29 15:02:22.220534', '');
|
||||
INSERT INTO `sys_menu` VALUES (111, '店铺管理', 3, 99, 'dou/shop', 'goods/brand/index', '', 1, 0, 'C', '0', '0', '', 'monitor', 'admin', '2023-12-29 13:34:49', 'admin', '2023-12-29 13:58:43.724029', '');
|
||||
INSERT INTO `sys_menu` VALUES (112, '订单管理', 4, 1, 'dou/order/list', 'scm/purchase/order', '', 1, 0, 'C', '0', '0', '', 'tree', 'admin', '2023-12-29 16:35:55', 'admin', '2023-12-29 16:36:57.653118', '');
|
||||
INSERT INTO `sys_menu` VALUES (113, '商品管理', 4, 2, 'pdd/goods/list', 'scm/purchase/contract', '', 1, 0, 'C', '0', '0', '', 'peoples', 'admin', '2023-12-29 16:39:43', 'admin', '2023-12-30 18:07:58.363465', '');
|
||||
INSERT INTO `sys_menu` VALUES (114, '售后管理', 4, 3, 'pdd/refund/list', 'scm/purchase/ship', '', 1, 0, 'C', '0', '0', '', 'system', 'admin', '2023-12-29 16:45:42', 'admin', '2023-12-30 20:48:47.282509', '');
|
||||
INSERT INTO `sys_menu` VALUES (115, '店铺管理', 4, 4, 'pdd/shop', 'scm/purchase/cost', '', 1, 0, 'C', '0', '0', '', 'monitor', 'admin', '2023-12-29 16:47:07', 'admin', '2024-01-13 18:32:21', '');
|
||||
INSERT INTO `sys_menu` VALUES (116, '用户管理', 5, 1, 'user', 'system/user/index', '', 1, 0, 'C', '0', '0', '', 'user', 'admin', '2023-12-27 15:00:27', '', '', '用户管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (117, '菜单管理', 5, 1, 'menu', 'system/menu/index', '', 1, 0, 'C', '0', '0', '', 'user', 'admin', '2023-12-27 15:00:27', '', '', '用户管理菜单');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
CREATE TABLE `sys_user` (
|
||||
`user_id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
`dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
|
||||
`user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户账号',
|
||||
`nick_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户昵称',
|
||||
`user_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '00' COMMENT '用户类型(00系统用户)',
|
||||
`email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户邮箱',
|
||||
`phonenumber` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '手机号码',
|
||||
`sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '用户性别(0男 1女 2未知)',
|
||||
`avatar` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像地址',
|
||||
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '密码',
|
||||
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态(0正常 1停用)',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)',
|
||||
`login_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '最后登录IP',
|
||||
`login_date` datetime NULL DEFAULT NULL COMMENT '最后登录时间',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`user_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_user
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_user` VALUES (1, 103, 'admin', '启航oms', '00', '280645618@qq.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', '2024-02-24 20:20:36', 'admin', '2023-08-07 19:31:37', '', '2024-02-24 20:20:36', '管理员');
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
|
@ -3,150 +3,247 @@ package com.qihang.oms.api.controller;
|
|||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.qihang.oms.api.common.AjaxResult;
|
||||
import com.qihang.oms.api.domain.LoginUser;
|
||||
import com.qihang.oms.api.domain.SysMenu;
|
||||
import com.qihang.oms.api.domain.vo.MenusDetailVo;
|
||||
import com.qihang.oms.api.domain.vo.MenusVo;
|
||||
import com.qihang.oms.api.service.ISysMenuService;
|
||||
import com.qihang.oms.api.service.TokenService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@RequestMapping("/menus")
|
||||
@RestController
|
||||
public class MenusController {
|
||||
private final TokenService tokenService;
|
||||
private final ISysMenuService sysMenuService;
|
||||
|
||||
public MenusController(TokenService tokenService) {
|
||||
public MenusController(TokenService tokenService, ISysMenuService sysMenuService) {
|
||||
this.tokenService = tokenService;
|
||||
this.sysMenuService = sysMenuService;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/routes")
|
||||
public AjaxResult list(HttpServletRequest request) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
|
||||
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(loginUser.getUserId());
|
||||
|
||||
|
||||
// Map<Long, List<MenusVo>> treeList = menusVos.stream().collect(Collectors.groupingBy(MenusVo::getParentId));
|
||||
// menusVos.forEach(menu -> menu.setChildren(treeList.getOrDefault(menu.getId(), null)));
|
||||
// List<MenusVo> result = menusVos.stream().filter(m -> m.getParentId() == 0).collect(Collectors.toList());
|
||||
Map<Long, List<SysMenu>> sysMenuMap = sysMenuList.stream().collect(Collectors.groupingBy(SysMenu::getParentId));
|
||||
// menuList.forEach(menu -> menu.setChildren(treeList.getOrDefault(menu.getMenuId(), new ArrayList<>())));
|
||||
// List<SysMenu> result = menuList.stream().filter(node -> node.getParentId() == 0).collect(Collectors.toList());
|
||||
|
||||
// MenusDetailVo meta1 = new MenusDetailVo();
|
||||
// meta1.setTitle("系统管理");
|
||||
// meta1.setIcon("system");
|
||||
// meta1.setHidden(false);
|
||||
// meta1.setRoles(new String[]{"GUEST","ADMIN", "ADMIN6"});
|
||||
//
|
||||
// menuList.forEach(menu -> {
|
||||
// menu.setChildren(treeList.getOrDefault(menu.getMenuId(), new ArrayList<>()));
|
||||
// menu.setComponent("/system/user");
|
||||
// MenusDetailVo m = new MenusDetailVo();
|
||||
// m.setTitle(menu.getMenuName());
|
||||
// m.setIcon(menu.getIcon());
|
||||
// m.setHidden(false);
|
||||
// m.setRoles(new String[]{"GUEST","ADMIN", "ADMIN6"});
|
||||
// menu.setMeta(m);
|
||||
// menu.setName(menu.getPath());
|
||||
//// menu.setRedirect("/system/user");
|
||||
// });
|
||||
|
||||
// List<SysMenu> result = menuList.stream().filter(node -> node.getParentId() == 0).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<MenusVo> vo = new ArrayList<>();
|
||||
MenusVo m1 = new MenusVo();
|
||||
m1.setPath("/system");
|
||||
m1.setComponent("Layout");
|
||||
m1.setRedirect("/system/user");
|
||||
m1.setName("/system");
|
||||
MenusDetailVo meta1 = new MenusDetailVo();
|
||||
meta1.setTitle("系统管理");
|
||||
meta1.setIcon("system");
|
||||
meta1.setHidden(false);
|
||||
meta1.setRoles(new String[]{"ADMIN", "ADMIN6"});
|
||||
m1.setMeta(meta1);
|
||||
for (var entry : sysMenuMap.entrySet()) {
|
||||
Optional<SysMenu> first = sysMenuList.stream().filter(x -> Objects.equals(x.getMenuId(), entry.getKey())).findFirst();
|
||||
// SysMenu sysMenuStream = first.orElse(null);
|
||||
if(first.isPresent()) {
|
||||
MenusVo topMenu = new MenusVo();
|
||||
topMenu.setPath(first.get().getPath());
|
||||
topMenu.setComponent(first.get().getComponent());
|
||||
// topMenu.setRedirect("/system/user");
|
||||
topMenu.setName(first.get().getPath());
|
||||
MenusDetailVo meta = new MenusDetailVo();
|
||||
meta.setTitle(first.get().getMenuName());
|
||||
meta.setIcon(first.get().getIcon());
|
||||
meta.setHidden(false);
|
||||
meta.setRoles(new String[]{"ADMIN", "ADMIN6"});
|
||||
topMenu.setMeta(meta);
|
||||
var child = sysMenuMap.getOrDefault(entry.getKey(), null);
|
||||
if(child!=null){
|
||||
List<MenusVo> children = new ArrayList<>();
|
||||
for(var m : child) {
|
||||
MenusVo m1ch1 = new MenusVo();
|
||||
m1ch1.setPath(m.getPath());
|
||||
m1ch1.setComponent(m.getComponent());
|
||||
// m1ch1.setName(m.getPath().replace("/",""));
|
||||
MenusDetailVo meta11 = new MenusDetailVo();
|
||||
meta11.setTitle(m.getMenuName());
|
||||
meta11.setIcon(m.getIcon());
|
||||
meta11.setHidden(false);
|
||||
meta11.setRoles(new String[]{"ADMIN", "GUEST"});
|
||||
m1ch1.setMeta(meta11);
|
||||
children.add(m1ch1);
|
||||
}
|
||||
topMenu.setChildren(children);
|
||||
}
|
||||
vo.add(topMenu);
|
||||
// MenusVo m1 = new MenusVo();
|
||||
// m1.setPath("/"+first.get().getPath());
|
||||
// m1.setComponent(first.get().getComponent());
|
||||
// m1.setRedirect("/system/user");
|
||||
// m1.setName("/system");
|
||||
// MenusDetailVo meta1 = new MenusDetailVo();
|
||||
// meta1.setTitle(first.get().getMenuName());
|
||||
// meta1.setIcon(first.get().getIcon());
|
||||
// meta1.setHidden(false);
|
||||
// meta1.setRoles(new String[]{"ADMIN", "ADMIN6"});
|
||||
// m1.setMeta(meta1);
|
||||
// vo.add(m1);
|
||||
}
|
||||
System.out.println(entry.getKey() + " : " + entry.getValue());
|
||||
}
|
||||
|
||||
List<MenusVo> m1Ch = new ArrayList<>();
|
||||
MenusVo m1ch1 = new MenusVo();
|
||||
m1ch1.setPath("/user");
|
||||
m1ch1.setComponent("system/user/index");
|
||||
m1ch1.setName("User");
|
||||
MenusDetailVo meta11 = new MenusDetailVo();
|
||||
meta11.setTitle("用户管理");
|
||||
meta11.setIcon("user");
|
||||
meta11.setHidden(false);
|
||||
meta11.setRoles(new String[]{"ADMIN", "GUEST"});
|
||||
// meta11.setKeepAlive(true);
|
||||
m1ch1.setMeta(meta11);
|
||||
m1Ch.add(m1ch1);
|
||||
// vo = new ArrayList<>();
|
||||
// MenusVo m1 = new MenusVo();
|
||||
// m1.setPath("/system");
|
||||
// m1.setComponent("Layout");
|
||||
// m1.setRedirect("/system/user");
|
||||
// m1.setName("/system");
|
||||
// MenusDetailVo meta1 = new MenusDetailVo();
|
||||
// meta1.setTitle("系统管理");
|
||||
// meta1.setIcon("system");
|
||||
// meta1.setHidden(false);
|
||||
// meta1.setRoles(new String[]{"ADMIN", "ADMIN6"});
|
||||
// m1.setMeta(meta1);
|
||||
//
|
||||
// List<MenusVo> m1Ch = new ArrayList<>();
|
||||
// MenusVo m1ch1 = new MenusVo();
|
||||
// m1ch1.setPath("/user");
|
||||
// m1ch1.setComponent("system/user/index");
|
||||
// m1ch1.setName("User");
|
||||
// MenusDetailVo meta11 = new MenusDetailVo();
|
||||
// meta11.setTitle("用户管理");
|
||||
// meta11.setIcon("user");
|
||||
// meta11.setHidden(false);
|
||||
// meta11.setRoles(new String[]{"ADMIN", "GUEST"});
|
||||
//// meta11.setKeepAlive(true);
|
||||
// m1ch1.setMeta(meta11);
|
||||
// m1Ch.add(m1ch1);
|
||||
// m1Ch.add(m1ch1);
|
||||
//
|
||||
//
|
||||
// m1.setChildren(m1Ch);
|
||||
// vo.add(m1);
|
||||
|
||||
|
||||
m1.setChildren(m1Ch);
|
||||
vo.add(m1);
|
||||
JSONArray jsonArray = JSONArray.parseArray("[{\n" +
|
||||
" \"path\": \"/system\",\n" +
|
||||
" \"component\": \"Layout\",\n" +
|
||||
" \"redirect\": \"/system/user\",\n" +
|
||||
" \"name\": \"/system\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"系统管理\",\n" +
|
||||
" \"icon\": \"system\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"GUEST\",\n" +
|
||||
" \"ADMIN\",\n" +
|
||||
" \"ADMIN6\"\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" \"children\": [\n" +
|
||||
" {\n" +
|
||||
" \"path\": \"user\",\n" +
|
||||
" \"component\": \"system/user/index\",\n" +
|
||||
" \"name\": \"User\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"用户管理\",\n" +
|
||||
" \"icon\": \"user\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"ADMIN\",\n" +
|
||||
" \"GUEST\"\n" +
|
||||
" ],\n" +
|
||||
" \"keepAlive\": true\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"path\": \"role\",\n" +
|
||||
" \"component\": \"system/role/index\",\n" +
|
||||
" \"name\": \"Role\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"角色管理\",\n" +
|
||||
" \"icon\": \"role\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"ADMIN\",\n" +
|
||||
" \"ADMIN6\",\n" +
|
||||
" \"GUEST\"\n" +
|
||||
" ],\n" +
|
||||
" \"keepAlive\": true\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"path\": \"menu\",\n" +
|
||||
" \"component\": \"system/menu/index\",\n" +
|
||||
" \"name\": \"Menu\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"菜单管理\",\n" +
|
||||
" \"icon\": \"menu\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"ADMIN\"\n" +
|
||||
" ],\n" +
|
||||
" \"keepAlive\": true\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"path\": \"dept\",\n" +
|
||||
" \"component\": \"system/dept/index\",\n" +
|
||||
" \"name\": \"Dept\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"部门管理\",\n" +
|
||||
" \"icon\": \"tree\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"ADMIN\"\n" +
|
||||
" ],\n" +
|
||||
" \"keepAlive\": true\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"path\": \"dict\",\n" +
|
||||
" \"component\": \"system/dict/index\",\n" +
|
||||
" \"name\": \"Dict\",\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"title\": \"字典管理\",\n" +
|
||||
" \"icon\": \"dict\",\n" +
|
||||
" \"hidden\": false,\n" +
|
||||
" \"roles\": [\n" +
|
||||
" \"ADMIN\"\n" +
|
||||
" ],\n" +
|
||||
" \"keepAlive\": true\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}]");
|
||||
return AjaxResult.success(jsonArray);
|
||||
|
||||
return AjaxResult.success(JSONArray.from(vo));
|
||||
// return AjaxResult.success(JSONArray.from(result));
|
||||
// return AjaxResult.success(JSONArray.from(result));
|
||||
// JSONArray jsonArray = JSONArray.parseArray("[{\n" +
|
||||
// " \"path\": \"/system\",\n" +
|
||||
// " \"component\": \"Layout\",\n" +
|
||||
// " \"redirect\": \"/system/user\",\n" +
|
||||
// " \"name\": \"/system\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"系统管理\",\n" +
|
||||
// " \"icon\": \"system\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"GUEST\",\n" +
|
||||
// " \"ADMIN\",\n" +
|
||||
// " \"ADMIN6\"\n" +
|
||||
// " ]\n" +
|
||||
// " },\n" +
|
||||
// " \"children\": [\n" +
|
||||
// " {\n" +
|
||||
// " \"path\": \"user\",\n" +
|
||||
// " \"component\": \"system/user/index\",\n" +
|
||||
// " \"name\": \"User\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"用户管理\",\n" +
|
||||
// " \"icon\": \"user\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"ADMIN\",\n" +
|
||||
// " \"GUEST\"\n" +
|
||||
// " ],\n" +
|
||||
// " \"keepAlive\": true\n" +
|
||||
// " }\n" +
|
||||
// " },\n" +
|
||||
// " {\n" +
|
||||
// " \"path\": \"role\",\n" +
|
||||
// " \"component\": \"system/role/index\",\n" +
|
||||
// " \"name\": \"Role\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"角色管理\",\n" +
|
||||
// " \"icon\": \"role\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"ADMIN\",\n" +
|
||||
// " \"ADMIN6\",\n" +
|
||||
// " \"GUEST\"\n" +
|
||||
// " ],\n" +
|
||||
// " \"keepAlive\": true\n" +
|
||||
// " }\n" +
|
||||
// " },\n" +
|
||||
// " {\n" +
|
||||
// " \"path\": \"menu\",\n" +
|
||||
// " \"component\": \"system/menu/index\",\n" +
|
||||
// " \"name\": \"Menu\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"菜单管理\",\n" +
|
||||
// " \"icon\": \"menu\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"ADMIN\"\n" +
|
||||
// " ],\n" +
|
||||
// " \"keepAlive\": true\n" +
|
||||
// " }\n" +
|
||||
// " },\n" +
|
||||
// " {\n" +
|
||||
// " \"path\": \"dept\",\n" +
|
||||
// " \"component\": \"system/dept/index\",\n" +
|
||||
// " \"name\": \"Dept\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"部门管理\",\n" +
|
||||
// " \"icon\": \"tree\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"ADMIN\"\n" +
|
||||
// " ],\n" +
|
||||
// " \"keepAlive\": true\n" +
|
||||
// " }\n" +
|
||||
// " },\n" +
|
||||
// " {\n" +
|
||||
// " \"path\": \"dict\",\n" +
|
||||
// " \"component\": \"system/dict/index\",\n" +
|
||||
// " \"name\": \"Dict\",\n" +
|
||||
// " \"meta\": {\n" +
|
||||
// " \"title\": \"字典管理\",\n" +
|
||||
// " \"icon\": \"dict\",\n" +
|
||||
// " \"hidden\": false,\n" +
|
||||
// " \"roles\": [\n" +
|
||||
// " \"ADMIN\"\n" +
|
||||
// " ],\n" +
|
||||
// " \"keepAlive\": true\n" +
|
||||
// " }\n" +
|
||||
// " }\n" +
|
||||
// " ]\n" +
|
||||
// "}]");
|
||||
|
||||
// return AjaxResult.success(jsonArray);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,280 @@
|
|||
package com.qihang.oms.api.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.qihang.oms.api.domain.vo.MenusDetailVo;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单权限表 sys_menu
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
public class SysMenu extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜单ID */
|
||||
private Long menuId;
|
||||
|
||||
/** 菜单名称 */
|
||||
@JsonProperty("title")
|
||||
private String menuName;
|
||||
|
||||
/** 父菜单名称 */
|
||||
private String parentName;
|
||||
|
||||
/** 父菜单ID */
|
||||
private Long parentId;
|
||||
|
||||
/** 显示顺序 */
|
||||
private Integer orderNum;
|
||||
|
||||
/** 路由地址 */
|
||||
private String path;
|
||||
|
||||
/** 组件路径 */
|
||||
private String component;
|
||||
|
||||
/** 路由参数 */
|
||||
private String query;
|
||||
|
||||
/** 是否为外链(0是 1否) */
|
||||
private String isFrame;
|
||||
|
||||
/** 是否缓存(0缓存 1不缓存) */
|
||||
private String isCache;
|
||||
|
||||
/** 类型(M目录 C菜单 F按钮) */
|
||||
private String menuType;
|
||||
|
||||
/** 显示状态(0显示 1隐藏) */
|
||||
private String visible;
|
||||
|
||||
/** 菜单状态(0正常 1停用) */
|
||||
private String status;
|
||||
|
||||
/** 权限字符串 */
|
||||
private String perms;
|
||||
|
||||
/** 菜单图标 */
|
||||
private String icon;
|
||||
private String redirect;
|
||||
private String name;
|
||||
|
||||
/** 子菜单 */
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private MenusDetailVo meta;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRedirect() {
|
||||
return redirect;
|
||||
}
|
||||
|
||||
public void setRedirect(String redirect) {
|
||||
this.redirect = redirect;
|
||||
}
|
||||
|
||||
public MenusDetailVo getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(MenusDetailVo meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public Long getMenuId()
|
||||
{
|
||||
return menuId;
|
||||
}
|
||||
|
||||
public void setMenuId(Long menuId)
|
||||
{
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
public String getMenuName()
|
||||
{
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName)
|
||||
{
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName)
|
||||
{
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getComponent()
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component)
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getIsFrame()
|
||||
{
|
||||
return isFrame;
|
||||
}
|
||||
|
||||
public void setIsFrame(String isFrame)
|
||||
{
|
||||
this.isFrame = isFrame;
|
||||
}
|
||||
|
||||
public String getIsCache()
|
||||
{
|
||||
return isCache;
|
||||
}
|
||||
|
||||
public void setIsCache(String isCache)
|
||||
{
|
||||
this.isCache = isCache;
|
||||
}
|
||||
|
||||
public String getMenuType()
|
||||
{
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(String menuType)
|
||||
{
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public String getVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(String visible)
|
||||
{
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getPerms()
|
||||
{
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms)
|
||||
{
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
public String getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public List<SysMenu> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysMenu> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("menuId", getMenuId())
|
||||
.append("menuName", getMenuName())
|
||||
.append("parentId", getParentId())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("path", getPath())
|
||||
.append("component", getComponent())
|
||||
.append("isFrame", getIsFrame())
|
||||
.append("IsCache", getIsCache())
|
||||
.append("menuType", getMenuType())
|
||||
.append("visible", getVisible())
|
||||
.append("status ", getStatus())
|
||||
.append("perms", getPerms())
|
||||
.append("icon", getIcon())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package com.qihang.oms.api.domain.vo;
|
||||
|
||||
public class MenuMetaVo {
|
||||
}
|
||||
|
|
@ -8,8 +8,26 @@ public class MenusVo {
|
|||
private String redirect;
|
||||
private String name;
|
||||
private MenusDetailVo meta;
|
||||
private Long parentId;
|
||||
private Long id;
|
||||
private List<MenusVo> children;
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
package com.qihang.oms.api.mapper;
|
||||
|
||||
|
||||
import com.qihang.oms.api.domain.SysMenu;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单表 数据层
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
public interface SysMenuMapper
|
||||
{
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuList(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 根据用户所有权限
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
public List<String> selectMenuPerms();
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuListByUserId(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public List<String> selectMenuPermsByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public List<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuTreeAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
public List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
public SysMenu selectMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 是否存在菜单子节点
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int hasChildByMenuId(Long menuId);
|
||||
|
||||
/**
|
||||
* 新增菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 修改菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
* @param menuName 菜单名称
|
||||
* @param parentId 父菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
package com.qihang.oms.api.service;
|
||||
|
||||
import com.qihang.oms.api.domain.SysMenu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单 业务层
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
public interface ISysMenuService
|
||||
{
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuList(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单树信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
// public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
// public List<Long> selectMenuListByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 路由列表
|
||||
*/
|
||||
// public List<RouterVo> buildMenus(List<SysMenu> menus);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus);
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
// public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus);
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
public SysMenu selectMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 是否存在菜单子节点
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
public boolean hasChildByMenuId(Long menuId);
|
||||
|
||||
/**
|
||||
* 查询菜单是否存在角色
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
// public boolean checkMenuExistRole(Long menuId);
|
||||
|
||||
/**
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 修改保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkMenuNameUnique(SysMenu menu);
|
||||
}
|
||||
|
|
@ -0,0 +1,514 @@
|
|||
package com.qihang.oms.api.service.impl;
|
||||
|
||||
import com.qihang.oms.api.common.UserConstants;
|
||||
import com.qihang.oms.api.constant.Constants;
|
||||
import com.qihang.oms.api.domain.SysMenu;
|
||||
import com.qihang.oms.api.domain.SysUser;
|
||||
import com.qihang.oms.api.mapper.SysMenuMapper;
|
||||
import com.qihang.oms.api.service.ISysMenuService;
|
||||
import com.qihang.oms.api.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单 业务层处理
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl implements ISysMenuService
|
||||
{
|
||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper menuMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(Long userId)
|
||||
{
|
||||
return selectMenuList(new SysMenu(), userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
||||
{
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId)
|
||||
{
|
||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(perm))
|
||||
{
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId)
|
||||
{
|
||||
List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(perm))
|
||||
{
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户名称
|
||||
* @return 菜单列表
|
||||
*/
|
||||
// @Override
|
||||
// public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
||||
// {
|
||||
// List<SysMenu> menus = null;
|
||||
// if (SecurityUtils.isAdmin(userId))
|
||||
// {
|
||||
// menus = menuMapper.selectMenuTreeAll();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||
// }
|
||||
// return getChildPerms(menus, 0);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
// @Override
|
||||
// public List<Long> selectMenuListByRoleId(Long roleId)
|
||||
// {
|
||||
// SysRole role = roleMapper.selectRoleById(roleId);
|
||||
// return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 路由列表
|
||||
*/
|
||||
// @Override
|
||||
// public List<RouterVo> buildMenus(List<SysMenu> menus)
|
||||
// {
|
||||
// List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||
// for (SysMenu menu : menus)
|
||||
// {
|
||||
// RouterVo router = new RouterVo();
|
||||
// router.setHidden("1".equals(menu.getVisible()));
|
||||
// router.setName(getRouteName(menu));
|
||||
// router.setPath(getRouterPath(menu));
|
||||
// router.setComponent(getComponent(menu));
|
||||
// router.setQuery(menu.getQuery());
|
||||
// router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
// List<SysMenu> cMenus = menu.getChildren();
|
||||
// if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||
// {
|
||||
// router.setAlwaysShow(true);
|
||||
// router.setRedirect("noRedirect");
|
||||
// router.setChildren(buildMenus(cMenus));
|
||||
// }
|
||||
// else if (isMenuFrame(menu))
|
||||
// {
|
||||
// router.setMeta(null);
|
||||
// List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
// RouterVo children = new RouterVo();
|
||||
// children.setPath(menu.getPath());
|
||||
// children.setComponent(menu.getComponent());
|
||||
// children.setName(StringUtils.capitalize(menu.getPath()));
|
||||
// children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
// children.setQuery(menu.getQuery());
|
||||
// childrenList.add(children);
|
||||
// router.setChildren(childrenList);
|
||||
// }
|
||||
// else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
||||
// {
|
||||
// router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
// router.setPath("/");
|
||||
// List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
// RouterVo children = new RouterVo();
|
||||
// String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||
// children.setPath(routerPath);
|
||||
// children.setComponent(UserConstants.INNER_LINK);
|
||||
// children.setName(StringUtils.capitalize(routerPath));
|
||||
// children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
||||
// childrenList.add(children);
|
||||
// router.setChildren(childrenList);
|
||||
// }
|
||||
// routers.add(router);
|
||||
// }
|
||||
// return routers;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
||||
{
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
||||
{
|
||||
SysMenu menu = (SysMenu) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(menu.getParentId()))
|
||||
{
|
||||
recursionFn(menus, menu);
|
||||
returnList.add(menu);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = menus;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
// @Override
|
||||
// public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
|
||||
// {
|
||||
// List<SysMenu> menuTrees = buildMenuTree(menus);
|
||||
// return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
@Override
|
||||
public SysMenu selectMenuById(Long menuId)
|
||||
{
|
||||
return menuMapper.selectMenuById(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在菜单子节点
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId)
|
||||
{
|
||||
int result = menuMapper.hasChildByMenuId(menuId);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单使用数量
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
// @Override
|
||||
// public boolean checkMenuExistRole(Long menuId)
|
||||
// {
|
||||
// int result = roleMenuMapper.checkMenuExistRole(menuId);
|
||||
// return result > 0;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMenu(SysMenu menu)
|
||||
{
|
||||
return menuMapper.insertMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMenu(SysMenu menu)
|
||||
{
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMenuById(Long menuId)
|
||||
{
|
||||
return menuMapper.deleteMenuById(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuNameUnique(SysMenu menu)
|
||||
{
|
||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由名称
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 路由名称
|
||||
*/
|
||||
public String getRouteName(SysMenu menu)
|
||||
{
|
||||
String routerName = StringUtils.capitalize(menu.getPath());
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (isMenuFrame(menu))
|
||||
{
|
||||
routerName = StringUtils.EMPTY;
|
||||
}
|
||||
return routerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由地址
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 路由地址
|
||||
*/
|
||||
public String getRouterPath(SysMenu menu)
|
||||
{
|
||||
String routerPath = menu.getPath();
|
||||
// 内链打开外网方式
|
||||
if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
||||
{
|
||||
routerPath = innerLinkReplaceEach(routerPath);
|
||||
}
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
||||
&& UserConstants.NO_FRAME.equals(menu.getIsFrame()))
|
||||
{
|
||||
routerPath = "/" + menu.getPath();
|
||||
}
|
||||
// 非外链并且是一级目录(类型为菜单)
|
||||
else if (isMenuFrame(menu))
|
||||
{
|
||||
routerPath = "/";
|
||||
}
|
||||
return routerPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组件信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 组件信息
|
||||
*/
|
||||
public String getComponent(SysMenu menu)
|
||||
{
|
||||
String component = UserConstants.LAYOUT;
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu))
|
||||
{
|
||||
component = menu.getComponent();
|
||||
}
|
||||
else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
||||
{
|
||||
component = UserConstants.INNER_LINK;
|
||||
}
|
||||
else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
|
||||
{
|
||||
component = UserConstants.PARENT_VIEW;
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为菜单内部跳转
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isMenuFrame(SysMenu menu)
|
||||
{
|
||||
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为内链组件
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isInnerLink(SysMenu menu)
|
||||
{
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为parent_view组件
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isParentView(SysMenu menu)
|
||||
{
|
||||
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父节点的ID获取所有子节点
|
||||
*
|
||||
* @param list 分类表
|
||||
* @param parentId 传入的父节点ID
|
||||
* @return String
|
||||
*/
|
||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
|
||||
{
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
|
||||
{
|
||||
SysMenu t = (SysMenu) iterator.next();
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (t.getParentId() == parentId)
|
||||
{
|
||||
recursionFn(list, t);
|
||||
returnList.add(t);
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*
|
||||
* @param list 分类表
|
||||
* @param t 子节点
|
||||
*/
|
||||
private void recursionFn(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<SysMenu> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (SysMenu tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||
Iterator<SysMenu> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
SysMenu n = (SysMenu) it.next();
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内链域名特殊字符替换
|
||||
*
|
||||
* @return 替换后的内链域名
|
||||
*/
|
||||
public String innerLinkReplaceEach(String path)
|
||||
{
|
||||
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." },
|
||||
new String[] { "", "", "", "/" });
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.qihang.oms.api.mapper.SysMenuMapper">
|
||||
|
||||
<resultMap type="SysMenu" id="SysMenuResult">
|
||||
<id property="menuId" column="menu_id" />
|
||||
<result property="menuName" column="menu_name" />
|
||||
<result property="parentName" column="parent_name" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="path" column="path" />
|
||||
<result property="component" column="component" />
|
||||
<result property="query" column="query" />
|
||||
<result property="isFrame" column="is_frame" />
|
||||
<result property="isCache" column="is_cache" />
|
||||
<result property="menuType" column="menu_type" />
|
||||
<result property="visible" column="visible" />
|
||||
<result property="status" column="status" />
|
||||
<result property="perms" column="perms" />
|
||||
<result property="icon" column="icon" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMenuVo">
|
||||
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||
from sys_menu
|
||||
</sql>
|
||||
|
||||
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
<where>
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND menu_name like concat('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="visible != null and visible != ''">
|
||||
AND visible = #{visible}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by parent_id, order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_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
|
||||
where ur.user_id = #{params.userId}
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="visible != null and visible != ''">
|
||||
AND m.visible = #{visible}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND m.status = #{status}
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_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_user u on ur.user_id = u.user_id
|
||||
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByRoleId" resultType="Long">
|
||||
select m.menu_id
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where rm.role_id = #{roleId}
|
||||
<if test="menuCheckStrictly">
|
||||
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPerms" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where m.status = '0' and rm.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
where menu_id = #{menuId}
|
||||
</select>
|
||||
|
||||
<select id="hasChildByMenuId" resultType="Integer">
|
||||
select count(1) from sys_menu where parent_id = #{menuId}
|
||||
</select>
|
||||
|
||||
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateMenu" parameterType="SysMenu">
|
||||
update sys_menu
|
||||
<set>
|
||||
<if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="path != null and path != ''">path = #{path},</if>
|
||||
<if test="component != null">component = #{component},</if>
|
||||
<if test="query != null">`query` = #{query},</if>
|
||||
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
|
||||
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
|
||||
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
|
||||
<if test="visible != null">visible = #{visible},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="perms !=null">perms = #{perms},</if>
|
||||
<if test="icon !=null and icon != ''">icon = #{icon},</if>
|
||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = current_timestamp()
|
||||
</set>
|
||||
where menu_id = #{menuId}
|
||||
</update>
|
||||
|
||||
<insert id="insertMenu" parameterType="SysMenu">
|
||||
insert into sys_menu(
|
||||
<if test="menuId != null and menuId != 0">menu_id,</if>
|
||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||
<if test="menuName != null and menuName != ''">menu_name,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="path != null and path != ''">path,</if>
|
||||
<if test="component != null and component != ''">component,</if>
|
||||
<if test="query != null and query != ''">`query`,</if>
|
||||
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
||||
<if test="isCache != null and isCache != ''">is_cache,</if>
|
||||
<if test="menuType != null and menuType != ''">menu_type,</if>
|
||||
<if test="visible != null">visible,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="perms !=null and perms != ''">perms,</if>
|
||||
<if test="icon != null and icon != ''">icon,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="menuId != null and menuId != 0">#{menuId},</if>
|
||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||||
<if test="menuName != null and menuName != ''">#{menuName},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="path != null and path != ''">#{path},</if>
|
||||
<if test="component != null and component != ''">#{component},</if>
|
||||
<if test="query != null and query != ''">#{query},</if>
|
||||
<if test="isFrame != null and isFrame != ''">#{isFrame},</if>
|
||||
<if test="isCache != null and isCache != ''">#{isCache},</if>
|
||||
<if test="menuType != null and menuType != ''">#{menuType},</if>
|
||||
<if test="visible != null">#{visible},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="perms !=null and perms != ''">#{perms},</if>
|
||||
<if test="icon != null and icon != ''">#{icon},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
current_timestamp()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteMenuById" parameterType="Long">
|
||||
delete from sys_menu where menu_id = #{menuId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -16,6 +16,5 @@ export default {
|
|||
dashboard: "首页",
|
||||
logout: "注销",
|
||||
document: "项目文档",
|
||||
gitee: "码云",
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,18 +22,6 @@
|
|||
<router-link to="/">
|
||||
<el-dropdown-item>{{ $t("navbar.dashboard") }}</el-dropdown-item>
|
||||
</router-link>
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://github.com/youlaitech/vue3-element-admin"
|
||||
>
|
||||
<el-dropdown-item>Github</el-dropdown-item>
|
||||
</a>
|
||||
<a target="_blank" href="https://gitee.com/haoxr">
|
||||
<el-dropdown-item>{{ $t("navbar.gitee") }}</el-dropdown-item>
|
||||
</a>
|
||||
<a target="_blank" href="https://juejin.cn/post/7228990409909108793">
|
||||
<el-dropdown-item>{{ $t("navbar.document") }}</el-dropdown-item>
|
||||
</a>
|
||||
<el-dropdown-item divided @click="logout">
|
||||
{{ $t("navbar.logout") }}
|
||||
</el-dropdown-item>
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ function resolvePath(routePath: string) {
|
|||
<el-sub-menu v-else :index="resolvePath(item.path)" teleported>
|
||||
<template #title>
|
||||
<item
|
||||
v-if="item.meta"
|
||||
v-if="item"
|
||||
:icon="item.meta && item.meta.icon"
|
||||
:title="item.meta.title"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ const hasPermission = (roles: string[], route: RouteRecordRaw) => {
|
|||
return roles.some((role) => {
|
||||
if (route.meta?.roles) {
|
||||
return route.meta.roles.includes(role);
|
||||
// return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -38,9 +39,10 @@ const hasPermission = (roles: string[], route: RouteRecordRaw) => {
|
|||
*/
|
||||
const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) => {
|
||||
const asyncRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
// debugger
|
||||
routes.forEach((route) => {
|
||||
const tmpRoute = { ...route }; // ES6扩展运算符复制新对象
|
||||
console.log(tmpRoute)
|
||||
if (!route.name) {
|
||||
tmpRoute.name = route.path;
|
||||
}
|
||||
|
|
@ -88,6 +90,9 @@ export const usePermissionStore = defineStore("permission", () => {
|
|||
// 接口获取所有路由
|
||||
listRoutes()
|
||||
.then(({ data: asyncRoutes }) => {
|
||||
console.log("menus");
|
||||
console.log(roles);
|
||||
console.log(asyncRoutes);
|
||||
// 根据角色获取有访问权限的路由
|
||||
const accessedRoutes = filterAsyncRoutes(asyncRoutes, roles);
|
||||
setRoutes(accessedRoutes);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,508 @@
|
|||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: "Menu",
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
import { MenuQuery, MenuForm, MenuVO } from "@/api/menu/types";
|
||||
import {
|
||||
listMenus,
|
||||
getMenuForm,
|
||||
getMenuOptions,
|
||||
addMenu,
|
||||
deleteMenu,
|
||||
updateMenu,
|
||||
} from "@/api/menu";
|
||||
|
||||
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";
|
||||
|
||||
import SvgIcon from "@/components/SvgIcon/index.vue";
|
||||
import IconSelect from "@/components/IconSelect/index.vue";
|
||||
|
||||
const queryFormRef = ref(ElForm);
|
||||
const menuFormRef = ref(ElForm);
|
||||
|
||||
const loading = ref(false);
|
||||
const dialog = reactive({
|
||||
title: "",
|
||||
visible: false,
|
||||
});
|
||||
|
||||
const queryParams = reactive<MenuQuery>({});
|
||||
const menuList = ref<MenuVO[]>([]);
|
||||
|
||||
const menuOptions = ref<OptionType[]>([]);
|
||||
|
||||
const formData = reactive<MenuForm>({
|
||||
parentId: 0,
|
||||
visible: 1,
|
||||
sort: 1,
|
||||
type: MenuTypeEnum.MENU,
|
||||
alwaysShow: 0,
|
||||
keepAlive: 0,
|
||||
});
|
||||
|
||||
const rules = reactive({
|
||||
parentId: [{ required: true, message: "请选择顶级菜单", trigger: "blur" }],
|
||||
name: [{ required: true, message: "请输入菜单名称", trigger: "blur" }],
|
||||
type: [{ required: true, message: "请选择菜单类型", trigger: "blur" }],
|
||||
path: [{ required: true, message: "请输入路由路径", trigger: "blur" }],
|
||||
|
||||
component: [{ required: true, message: "请输入组件路径", trigger: "blur" }],
|
||||
visible: [{ required: true, message: "请输入路由路径", trigger: "blur" }],
|
||||
});
|
||||
|
||||
// 选择表格的行菜单ID
|
||||
const selectedRowMenuId = ref<number | undefined>();
|
||||
|
||||
const menuCacheData = reactive({
|
||||
type: "",
|
||||
path: "",
|
||||
});
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function handleQuery() {
|
||||
// 重置父组件
|
||||
loading.value = true;
|
||||
listMenus(queryParams)
|
||||
.then(({ data }) => {
|
||||
menuList.value = data;
|
||||
})
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
/** 重置查询 */
|
||||
function resetQuery() {
|
||||
queryFormRef.value.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/**行点击事件 */
|
||||
function onRowClick(row: MenuVO) {
|
||||
selectedRowMenuId.value = row.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开表单弹窗
|
||||
*
|
||||
* @param parentId 父菜单ID
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
function openDialog(parentId?: number, menuId?: number) {
|
||||
getMenuOptions()
|
||||
.then(({ data }) => {
|
||||
menuOptions.value = [{ value: 0, label: "顶级菜单", children: data }];
|
||||
})
|
||||
.then(() => {
|
||||
dialog.visible = true;
|
||||
if (menuId) {
|
||||
dialog.title = "编辑菜单";
|
||||
getMenuForm(menuId).then(({ data }) => {
|
||||
Object.assign(formData, data);
|
||||
menuCacheData.type = data.type;
|
||||
menuCacheData.path = data.path ?? "";
|
||||
});
|
||||
} else {
|
||||
dialog.title = "新增菜单";
|
||||
formData.parentId = parentId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 菜单类型切换事件处理 */
|
||||
function onMenuTypeChange() {
|
||||
// 如果菜单类型改变,清空路由路径;未改变在切换后还原路由路径
|
||||
if (formData.type !== menuCacheData.type) {
|
||||
formData.path = "";
|
||||
} else {
|
||||
formData.path = menuCacheData.path;
|
||||
}
|
||||
}
|
||||
|
||||
/** 菜单保存提交 */
|
||||
function submitForm() {
|
||||
menuFormRef.value.validate((isValid: boolean) => {
|
||||
if (isValid) {
|
||||
const menuId = formData.id;
|
||||
if (menuId) {
|
||||
updateMenu(menuId, formData).then(() => {
|
||||
ElMessage.success("修改成功");
|
||||
closeDialog();
|
||||
handleQuery();
|
||||
});
|
||||
} else {
|
||||
addMenu(formData).then(() => {
|
||||
ElMessage.success("新增成功");
|
||||
closeDialog();
|
||||
handleQuery();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除菜单 */
|
||||
function handleDelete(menuId: number) {
|
||||
if (!menuId) {
|
||||
ElMessage.warning("请勾选删除项");
|
||||
return false;
|
||||
}
|
||||
|
||||
ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
deleteMenu(menuId).then(() => {
|
||||
ElMessage.success("删除成功");
|
||||
handleQuery();
|
||||
});
|
||||
})
|
||||
.catch(() => ElMessage.info("已取消删除"));
|
||||
}
|
||||
|
||||
/** 关闭弹窗 */
|
||||
function closeDialog() {
|
||||
dialog.visible = false;
|
||||
resetForm();
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
function resetForm() {
|
||||
menuFormRef.value.resetFields();
|
||||
menuFormRef.value.clearValidate();
|
||||
|
||||
formData.id = undefined;
|
||||
formData.parentId = 0;
|
||||
formData.visible = 1;
|
||||
formData.sort = 1;
|
||||
formData.perm = undefined;
|
||||
formData.component = undefined;
|
||||
formData.path = undefined;
|
||||
formData.redirect = undefined;
|
||||
formData.alwaysShow = undefined;
|
||||
formData.keepAlive = undefined;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
handleQuery();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-container">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="关键字" prop="keywords">
|
||||
<el-input
|
||||
v-model="queryParams.keywords"
|
||||
placeholder="菜单名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery"
|
||||
><template #icon><i-ep-search /></template>搜索</el-button
|
||||
>
|
||||
<el-button @click="resetQuery">
|
||||
<template #icon><i-ep-refresh /></template>
|
||||
重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never" class="table-container">
|
||||
<template #header>
|
||||
<el-button
|
||||
v-hasPerm="['sys:menu:add']"
|
||||
type="success"
|
||||
@click="openDialog(0)"
|
||||
>
|
||||
<template #icon><i-ep-plus /></template>
|
||||
新增</el-button
|
||||
>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="menuList"
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
:expand-row-keys="['1']"
|
||||
@row-click="onRowClick"
|
||||
:tree-props="{
|
||||
children: 'children',
|
||||
hasChildren: 'hasChildren',
|
||||
}"
|
||||
>
|
||||
<el-table-column label="菜单名称" min-width="200">
|
||||
<template #default="scope">
|
||||
<svg-icon :icon-class="scope.row.icon" />
|
||||
{{ scope.row.name }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="类型" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
v-if="scope.row.type === MenuTypeEnum.CATALOG"
|
||||
type="warning"
|
||||
>目录</el-tag
|
||||
>
|
||||
<el-tag v-if="scope.row.type === MenuTypeEnum.MENU" type="success"
|
||||
>菜单</el-tag
|
||||
>
|
||||
<el-tag v-if="scope.row.type === MenuTypeEnum.BUTTON" type="danger"
|
||||
>按钮</el-tag
|
||||
>
|
||||
<el-tag v-if="scope.row.type === MenuTypeEnum.EXTLINK" type="info"
|
||||
>外链</el-tag
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="路由路径"
|
||||
align="left"
|
||||
width="150"
|
||||
prop="path"
|
||||
/>
|
||||
|
||||
<el-table-column
|
||||
label="组件路径"
|
||||
align="left"
|
||||
width="250"
|
||||
prop="component"
|
||||
/>
|
||||
|
||||
<el-table-column
|
||||
label="权限标识"
|
||||
align="center"
|
||||
width="200"
|
||||
prop="perm"
|
||||
/>
|
||||
|
||||
<el-table-column label="状态" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.visible === 1" type="success">显示</el-tag>
|
||||
<el-tag v-else type="info">隐藏</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="排序" align="center" width="80" prop="sort" />
|
||||
|
||||
<el-table-column fixed="right" align="center" label="操作" width="220">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.type == 'CATALOG' || scope.row.type == 'MENU'"
|
||||
v-hasPerm="['sys:menu:add']"
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="openDialog(scope.row.id)"
|
||||
>
|
||||
<i-ep-plus />新增
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-hasPerm="['sys:menu:edit']"
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="openDialog(undefined, scope.row.id)"
|
||||
>
|
||||
<i-ep-edit />编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPerm="['sys:menu:delete']"
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="handleDelete(scope.row.id)"
|
||||
><i-ep-delete />
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialog.visible"
|
||||
:title="dialog.title"
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
width="1000px"
|
||||
@close="closeDialog"
|
||||
top="5vh"
|
||||
>
|
||||
<el-form
|
||||
ref="menuFormRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
label-width="160px"
|
||||
>
|
||||
<el-form-item label="父级菜单" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="formData.parentId"
|
||||
placeholder="选择上级菜单"
|
||||
:data="menuOptions"
|
||||
filterable
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="菜单名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入菜单名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="菜单类型" prop="type">
|
||||
<el-radio-group v-model="formData.type" @change="onMenuTypeChange">
|
||||
<el-radio label="CATALOG">目录</el-radio>
|
||||
<el-radio label="MENU">菜单</el-radio>
|
||||
<el-radio label="BUTTON">按钮</el-radio>
|
||||
<el-radio label="EXTLINK">外链</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type == 'EXTLINK'"
|
||||
label="外链地址"
|
||||
prop="path"
|
||||
>
|
||||
<el-input v-model="formData.path" placeholder="请输入外链完整路径" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="
|
||||
formData.type == MenuTypeEnum.CATALOG ||
|
||||
formData.type == MenuTypeEnum.MENU
|
||||
"
|
||||
label="路由路径"
|
||||
prop="path"
|
||||
>
|
||||
<el-input
|
||||
v-if="formData.type == MenuTypeEnum.CATALOG"
|
||||
v-model="formData.path"
|
||||
placeholder="system"
|
||||
/>
|
||||
<el-input v-else v-model="formData.path" placeholder="user" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 组件页面完整路径 -->
|
||||
<el-form-item
|
||||
v-if="formData.type == MenuTypeEnum.MENU"
|
||||
label="页面路径"
|
||||
prop="component"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.component"
|
||||
placeholder="system/user/index"
|
||||
style="width: 95%"
|
||||
>
|
||||
<template v-if="formData.type == MenuTypeEnum.MENU" #prepend
|
||||
>src/views/</template
|
||||
>
|
||||
<template v-if="formData.type == MenuTypeEnum.MENU" #append
|
||||
>.vue</template
|
||||
>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type !== MenuTypeEnum.BUTTON"
|
||||
prop="visible"
|
||||
label="显示状态"
|
||||
>
|
||||
<el-radio-group v-model="formData.visible">
|
||||
<el-radio :label="1">显示</el-radio>
|
||||
<el-radio :label="0">隐藏</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type === MenuTypeEnum.CATALOG"
|
||||
label="根目录始终显示"
|
||||
>
|
||||
<template #label>
|
||||
<div>
|
||||
根目录始终显示
|
||||
<el-tooltip placement="bottom" effect="light">
|
||||
<template #content
|
||||
>是:根目录只有一个子路由显示目录
|
||||
<br />否:根目录只有一个子路由不显示目录,只显示子路由
|
||||
</template>
|
||||
<i-ep-QuestionFilled class="inline-block" />
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-radio-group v-model="formData.alwaysShow">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type === MenuTypeEnum.MENU"
|
||||
label="是否缓存"
|
||||
>
|
||||
<el-radio-group v-model="formData.keepAlive">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number
|
||||
v-model="formData.sort"
|
||||
style="width: 100px"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 权限标识 -->
|
||||
<el-form-item
|
||||
v-if="formData.type == MenuTypeEnum.BUTTON"
|
||||
label="权限标识"
|
||||
prop="perm"
|
||||
>
|
||||
<el-input v-model="formData.perm" placeholder="sys:user:add" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type !== MenuTypeEnum.BUTTON"
|
||||
label="图标"
|
||||
prop="icon"
|
||||
>
|
||||
<!-- 图标选择器 -->
|
||||
<icon-select v-model="formData.icon" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="formData.type == MenuTypeEnum.CATALOG"
|
||||
label="跳转路由"
|
||||
>
|
||||
<el-input v-model="formData.redirect" placeholder="跳转路由" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="closeDialog">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Reference in New Issue