mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-17 19:06:39 +08:00
v1.1.0
This commit is contained in:
commit
a34f5d5afa
@ -124,7 +124,6 @@ SmartAdmin微信群(**加我微信拉你入群!**)
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
作者简介:
|
作者简介:
|
||||||
[卓大](https://zhuoluodada.cn), 1024创新实验室主任,混迹于各个技术圈,研究过计算机,熟悉点java,略懂点前端。
|
[卓大](https://zhuoluodada.cn), 1024创新实验室主任,混迹于各个技术圈,研究过计算机,熟悉点java,略懂点前端。
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
EmployeeController.updatePwd
|
EmployeeController.updatePwd
|
||||||
|
|
||||||
2 更新功能点
|
2 更新功能点
|
||||||
PrivilegeController functionSaveOrUpdate和menuBatchSave
|
PrivilegeController functionSaveOrUpdate和menuBatchSave、batchSaveFunctionList
|
||||||
|
|
||||||
3 超管默认账号
|
3 超管默认账号
|
||||||
sa/123456
|
sa/123456
|
||||||
|
@ -21,7 +21,7 @@ public enum IdGeneratorEnum {
|
|||||||
|
|
||||||
ORDER(1, "order");
|
ORDER(1, "order");
|
||||||
|
|
||||||
private int id;
|
private long id;
|
||||||
private String keyName;
|
private String keyName;
|
||||||
|
|
||||||
IdGeneratorEnum(int id, String keyName) {
|
IdGeneratorEnum(int id, String keyName) {
|
||||||
@ -34,7 +34,7 @@ public enum IdGeneratorEnum {
|
|||||||
return "IdGeneratorEnum{" + "id=" + id + ", keyName='" + keyName + '\'' + '}';
|
return "IdGeneratorEnum{" + "id=" + id + ", keyName='" + keyName + '\'' + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,12 @@ public class PrivilegeResponseCodeConst extends ResponseCodeConst {
|
|||||||
|
|
||||||
public static final PrivilegeResponseCodeConst ROUTER_KEY_NO_REPEAT = new PrivilegeResponseCodeConst(7002, "模块和页面的“功能Key”值不能重复!");
|
public static final PrivilegeResponseCodeConst ROUTER_KEY_NO_REPEAT = new PrivilegeResponseCodeConst(7002, "模块和页面的“功能Key”值不能重复!");
|
||||||
|
|
||||||
|
public static final PrivilegeResponseCodeConst MENU_NOT_EXIST = new PrivilegeResponseCodeConst(7003, "菜单不存在,清先保存菜单!");
|
||||||
|
|
||||||
|
public static final PrivilegeResponseCodeConst POINT_NOT_EXIST = new PrivilegeResponseCodeConst(7004, "功能点不存在,清先保存功能点!");
|
||||||
|
|
||||||
public PrivilegeResponseCodeConst(int code, String msg) {
|
public PrivilegeResponseCodeConst(int code, String msg) {
|
||||||
super(code, msg);
|
super(code, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ public class PrivilegeController {
|
|||||||
@ApiOperation(value = "菜单批量保存")
|
@ApiOperation(value = "菜单批量保存")
|
||||||
@PostMapping("/privilege/menu/batchSaveMenu")
|
@PostMapping("/privilege/menu/batchSaveMenu")
|
||||||
public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
|
public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
|
||||||
// return privilegeService.menuBatchSave(menuList);
|
return privilegeService.menuBatchSave(menuList);
|
||||||
return ResponseDTO.succ();
|
// return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,10 +56,18 @@ public class PrivilegeController {
|
|||||||
@ApiOperation(value = "保存更新功能点")
|
@ApiOperation(value = "保存更新功能点")
|
||||||
@PostMapping("/privilege/function/saveOrUpdate")
|
@PostMapping("/privilege/function/saveOrUpdate")
|
||||||
public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
|
public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
|
||||||
// return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
|
return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
|
||||||
return ResponseDTO.succ();
|
// return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "批量保存功能点")
|
||||||
|
@PostMapping("/privilege/function/batchSave")
|
||||||
|
public ResponseDTO<String> batchSaveFunctionList(@Valid @RequestBody ValidateList<PrivilegeFunctionDTO> functionList) {
|
||||||
|
return privilegeService.batchSaveFunctionList(functionList);
|
||||||
|
// return ResponseDTO.succ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "查询菜单功能点", notes = "更新")
|
@ApiOperation(value = "查询菜单功能点", notes = "更新")
|
||||||
@PostMapping("/privilege/function/query/{menuKey}")
|
@PostMapping("/privilege/function/query/{menuKey}")
|
||||||
public ResponseDTO<List<PrivilegeFunctionVO>> functionQuery(@PathVariable String menuKey) {
|
public ResponseDTO<List<PrivilegeFunctionVO>> functionQuery(@PathVariable String menuKey) {
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package net.lab1024.smartadmin.module.system.privilege.service;
|
package net.lab1024.smartadmin.module.system.privilege.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.smartadmin.common.domain.ValidateList;
|
||||||
|
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.dao.PrivilegeDao;
|
import net.lab1024.smartadmin.module.system.privilege.dao.PrivilegeDao;
|
||||||
|
import net.lab1024.smartadmin.module.system.privilege.domain.dto.*;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
||||||
import net.lab1024.smartadmin.module.system.role.roleprivilege.RolePrivilegeDao;
|
import net.lab1024.smartadmin.module.system.role.roleprivilege.RolePrivilegeDao;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import net.lab1024.smartadmin.module.system.privilege.domain.dto.*;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +149,7 @@ public class PrivilegeService {
|
|||||||
return ResponseDTO.succData(Lists.newArrayList());
|
return ResponseDTO.succData(Lists.newArrayList());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PrivilegeMenuVO> voList = privilegeEntityList.stream().map(e-> {
|
List<PrivilegeMenuVO> voList = privilegeEntityList.stream().map(e -> {
|
||||||
PrivilegeMenuVO vo = new PrivilegeMenuVO();
|
PrivilegeMenuVO vo = new PrivilegeMenuVO();
|
||||||
vo.setMenuKey(e.getKey());
|
vo.setMenuKey(e.getKey());
|
||||||
vo.setMenuName(e.getName());
|
vo.setMenuName(e.getName());
|
||||||
@ -174,23 +173,14 @@ public class PrivilegeService {
|
|||||||
String functionKey = privilegeFunctionDTO.getFunctionKey();
|
String functionKey = privilegeFunctionDTO.getFunctionKey();
|
||||||
PrivilegeEntity functionEntity = privilegeDao.selectByKey(functionKey);
|
PrivilegeEntity functionEntity = privilegeDao.selectByKey(functionKey);
|
||||||
if (functionEntity == null) {
|
if (functionEntity == null) {
|
||||||
functionEntity = new PrivilegeEntity();
|
return ResponseDTO.wrap(PrivilegeResponseCodeConst.POINT_NOT_EXIST);
|
||||||
functionEntity.setName(privilegeFunctionDTO.getFunctionName());
|
|
||||||
functionEntity.setParentKey(privilegeFunctionDTO.getMenuKey());
|
|
||||||
functionEntity.setType(PrivilegeTypeEnum.POINTS.getValue());
|
|
||||||
functionEntity.setUrl(privilegeFunctionDTO.getUrl());
|
|
||||||
functionEntity.setKey(privilegeFunctionDTO.getFunctionKey());
|
|
||||||
functionEntity.setSort(privilegeFunctionDTO.getSort());
|
|
||||||
functionEntity.setCreateTime(new Date());
|
|
||||||
functionEntity.setUpdateTime(new Date());
|
|
||||||
privilegeDao.insert(functionEntity);
|
|
||||||
} else {
|
|
||||||
functionEntity.setUrl(privilegeFunctionDTO.getUrl());
|
|
||||||
functionEntity.setName(privilegeFunctionDTO.getFunctionName());
|
|
||||||
functionEntity.setParentKey(privilegeFunctionDTO.getMenuKey());
|
|
||||||
functionEntity.setSort(privilegeFunctionDTO.getSort());
|
|
||||||
privilegeDao.updateById(functionEntity);
|
|
||||||
}
|
}
|
||||||
|
functionEntity.setUrl(privilegeFunctionDTO.getUrl());
|
||||||
|
functionEntity.setName(privilegeFunctionDTO.getFunctionName());
|
||||||
|
functionEntity.setParentKey(privilegeFunctionDTO.getMenuKey());
|
||||||
|
functionEntity.setSort(privilegeFunctionDTO.getSort());
|
||||||
|
privilegeDao.updateById(functionEntity);
|
||||||
|
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +196,8 @@ public class PrivilegeService {
|
|||||||
return ResponseDTO.succData(Lists.newArrayList());
|
return ResponseDTO.succData(Lists.newArrayList());
|
||||||
}
|
}
|
||||||
List<PrivilegeFunctionVO> functionList = Lists.newArrayList();
|
List<PrivilegeFunctionVO> functionList = Lists.newArrayList();
|
||||||
PrivilegeFunctionVO functionDTO;
|
|
||||||
for (PrivilegeEntity functionEntity : functionPrivilegeList) {
|
for (PrivilegeEntity functionEntity : functionPrivilegeList) {
|
||||||
functionDTO = new PrivilegeFunctionVO();
|
PrivilegeFunctionVO functionDTO = new PrivilegeFunctionVO();
|
||||||
functionDTO.setFunctionKey(functionEntity.getKey());
|
functionDTO.setFunctionKey(functionEntity.getKey());
|
||||||
functionDTO.setFunctionName(functionEntity.getName());
|
functionDTO.setFunctionName(functionEntity.getName());
|
||||||
functionDTO.setMenuKey(functionEntity.getParentKey());
|
functionDTO.setMenuKey(functionEntity.getParentKey());
|
||||||
@ -219,4 +208,70 @@ public class PrivilegeService {
|
|||||||
return ResponseDTO.succData(functionList);
|
return ResponseDTO.succData(functionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ResponseDTO<String> batchSaveFunctionList(ValidateList<PrivilegeFunctionDTO> functionList) {
|
||||||
|
String menuKey = functionList.get(0).getMenuKey();
|
||||||
|
PrivilegeEntity privilegeEntity = privilegeDao.selectByKey(menuKey);
|
||||||
|
if (privilegeEntity == null) {
|
||||||
|
return ResponseDTO.wrap(PrivilegeResponseCodeConst.MENU_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//数据库中存在的数据
|
||||||
|
List<PrivilegeEntity> existFunctionList = privilegeDao.selectByParentKey(menuKey);
|
||||||
|
Map<String, PrivilegeEntity> privilegeEntityMap = existFunctionList.stream().collect(Collectors.toMap(PrivilegeEntity::getKey, e -> e));
|
||||||
|
|
||||||
|
//如果没有,则保存全部
|
||||||
|
if (existFunctionList.isEmpty()) {
|
||||||
|
List<PrivilegeEntity> privilegeEntityList = functionList.stream().map(e -> function2Privilege(e)).collect(Collectors.toList());
|
||||||
|
privilegeDao.batchInsert(privilegeEntityList);
|
||||||
|
return ResponseDTO.succ();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> functionKeySet = functionList.stream().map(PrivilegeFunctionDTO::getFunctionKey).collect(Collectors.toSet());
|
||||||
|
//删除的
|
||||||
|
List<Long> deleteIdList = existFunctionList.stream().filter(e -> !functionKeySet.contains(e.getKey())).map(PrivilegeEntity::getId).collect(Collectors.toList());
|
||||||
|
List<String> deleteKeyList = existFunctionList.stream().filter(e -> !functionKeySet.contains(e.getKey())).map(PrivilegeEntity::getKey).collect(Collectors.toList());
|
||||||
|
if (!deleteIdList.isEmpty()) {
|
||||||
|
privilegeDao.deleteBatchIds(deleteIdList);
|
||||||
|
rolePrivilegeDao.deleteByPrivilegeKey(deleteKeyList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//需要更新的
|
||||||
|
ArrayList<PrivilegeEntity> batchUpdateList = Lists.newArrayList();
|
||||||
|
for (PrivilegeFunctionDTO privilegeFunctionDTO : functionList) {
|
||||||
|
PrivilegeEntity existPrivilege = privilegeEntityMap.get(privilegeFunctionDTO.getFunctionKey());
|
||||||
|
if (existPrivilege != null) {
|
||||||
|
existPrivilege.setSort(privilegeFunctionDTO.getSort());
|
||||||
|
existPrivilege.setName(privilegeFunctionDTO.getFunctionName());
|
||||||
|
batchUpdateList.add(existPrivilege);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!batchUpdateList.isEmpty()) {
|
||||||
|
privilegeDao.batchUpdate(batchUpdateList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增的
|
||||||
|
List<PrivilegeEntity> batchInsertList = functionList.stream()
|
||||||
|
.filter(e -> !privilegeEntityMap.containsKey(e.getFunctionKey()))
|
||||||
|
.map(e -> function2Privilege(e))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!batchInsertList.isEmpty()) {
|
||||||
|
privilegeDao.batchInsert(batchInsertList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseDTO.succ();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrivilegeEntity function2Privilege(PrivilegeFunctionDTO privilegeFunction) {
|
||||||
|
PrivilegeEntity privilegeEntity = new PrivilegeEntity();
|
||||||
|
privilegeEntity.setKey(privilegeFunction.getFunctionKey());
|
||||||
|
privilegeEntity.setName(privilegeFunction.getFunctionName());
|
||||||
|
privilegeEntity.setParentKey(privilegeFunction.getMenuKey());
|
||||||
|
privilegeEntity.setType(PrivilegeTypeEnum.POINTS.getValue());
|
||||||
|
privilegeEntity.setSort(privilegeFunction.getSort());
|
||||||
|
privilegeEntity.setUrl("");
|
||||||
|
return privilegeEntity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,9 @@ public class SystemConfigService {
|
|||||||
*/
|
*/
|
||||||
public ResponseDTO<PageResultDTO<SystemConfigVO>> getSystemConfigPage(SystemConfigQueryDTO queryDTO) {
|
public ResponseDTO<PageResultDTO<SystemConfigVO>> getSystemConfigPage(SystemConfigQueryDTO queryDTO) {
|
||||||
Page page = SmartPageUtil.convert2QueryPage(queryDTO);
|
Page page = SmartPageUtil.convert2QueryPage(queryDTO);
|
||||||
|
if(queryDTO.getKey() != null){
|
||||||
|
queryDTO.setKey(queryDTO.getKey().toLowerCase());
|
||||||
|
}
|
||||||
List<SystemConfigEntity> entityList = systemConfigDao.selectSystemSettingList(page, queryDTO);
|
List<SystemConfigEntity> entityList = systemConfigDao.selectSystemSettingList(page, queryDTO);
|
||||||
PageResultDTO<SystemConfigVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, entityList, SystemConfigVO.class);
|
PageResultDTO<SystemConfigVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, entityList, SystemConfigVO.class);
|
||||||
return ResponseDTO.succData(pageResultDTO);
|
return ResponseDTO.succData(pageResultDTO);
|
||||||
@ -94,7 +97,9 @@ public class SystemConfigService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<SystemConfigVO> selectByKey(String configKey) {
|
public ResponseDTO<SystemConfigVO> selectByKey(String configKey) {
|
||||||
configKey = configKey.toLowerCase();
|
if(configKey != null){
|
||||||
|
configKey = configKey.toLowerCase();
|
||||||
|
}
|
||||||
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
|
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
|
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
|
||||||
@ -112,7 +117,9 @@ public class SystemConfigService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> T selectByKey2Obj(String configKey, Class<T> clazz) {
|
public <T> T selectByKey2Obj(String configKey, Class<T> clazz) {
|
||||||
configKey = configKey.toLowerCase();
|
if(configKey != null){
|
||||||
|
configKey = configKey.toLowerCase();
|
||||||
|
}
|
||||||
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
|
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -150,6 +157,7 @@ public class SystemConfigService {
|
|||||||
if(!valueValid.isSuccess()){
|
if(!valueValid.isSuccess()){
|
||||||
return valueValid;
|
return valueValid;
|
||||||
}
|
}
|
||||||
|
configAddDTO.setConfigKey(configAddDTO.getConfigKey().toLowerCase());
|
||||||
SystemConfigEntity addEntity = SmartBeanUtil.copy(configAddDTO, SystemConfigEntity.class);
|
SystemConfigEntity addEntity = SmartBeanUtil.copy(configAddDTO, SystemConfigEntity.class);
|
||||||
addEntity.setIsUsing(JudgeEnum.YES.getValue());
|
addEntity.setIsUsing(JudgeEnum.YES.getValue());
|
||||||
systemConfigDao.insert(addEntity);
|
systemConfigDao.insert(addEntity);
|
||||||
@ -171,7 +179,7 @@ public class SystemConfigService {
|
|||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
|
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
|
||||||
}
|
}
|
||||||
SystemConfigEntity alreadyEntity = systemConfigDao.getByKeyExcludeId(updateDTO.getConfigKey(), updateDTO.getId());
|
SystemConfigEntity alreadyEntity = systemConfigDao.getByKeyExcludeId(updateDTO.getConfigKey().toLowerCase(), updateDTO.getId());
|
||||||
if (alreadyEntity != null) {
|
if (alreadyEntity != null) {
|
||||||
return ResponseDTO.wrap(SystemConfigResponseCodeConst.ALREADY_EXIST);
|
return ResponseDTO.wrap(SystemConfigResponseCodeConst.ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
@ -180,6 +188,7 @@ public class SystemConfigService {
|
|||||||
return valueValid;
|
return valueValid;
|
||||||
}
|
}
|
||||||
entity = SmartBeanUtil.copy(updateDTO, SystemConfigEntity.class);
|
entity = SmartBeanUtil.copy(updateDTO, SystemConfigEntity.class);
|
||||||
|
updateDTO.setConfigKey(updateDTO.getConfigKey().toLowerCase());
|
||||||
systemConfigDao.updateById(entity);
|
systemConfigDao.updateById(entity);
|
||||||
|
|
||||||
//刷新缓存
|
//刷新缓存
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,10 @@ export const privilegeApi = {
|
|||||||
addBatchSaveMenu: data => {
|
addBatchSaveMenu: data => {
|
||||||
return postAxios('/privilege/menu/batchSaveMenu', data);
|
return postAxios('/privilege/menu/batchSaveMenu', data);
|
||||||
},
|
},
|
||||||
|
// 功能点批量保存
|
||||||
|
addBatchSavePoints: data => {
|
||||||
|
return postAxios('/privilege/function/batchSave', data);
|
||||||
|
},
|
||||||
// 查询菜单功能点
|
// 查询菜单功能点
|
||||||
queryPrivilegeFunctionList: menuKey => {
|
queryPrivilegeFunctionList: menuKey => {
|
||||||
return postAxios('/privilege/function/query/' + menuKey);
|
return postAxios('/privilege/function/query/' + menuKey);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
v-show="!collapsed"
|
v-show="!collapsed"
|
||||||
width="auto"
|
width="auto"
|
||||||
>
|
>
|
||||||
<template v-for="item in menuList">
|
<template v-for="item in menuList">
|
||||||
<template v-if="item.children && item.children.length === 1">
|
<template v-if="item.children && item.children.length === 1">
|
||||||
<side-menu-item :key="`menu-${item.name}`" :parent-item="item.children[0]" v-if="item.children[0].children && item.children[0].children.length > 0 "></side-menu-item>
|
<side-menu-item :key="`menu-${item.name}`" :parent-item="item.children[0]" v-if="item.children[0].children && item.children[0].children.length > 0 "></side-menu-item>
|
||||||
<menu-item
|
<menu-item
|
||||||
@ -179,9 +179,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// 从激活菜单的名称中获取打开的菜单
|
// 从激活菜单的名称中获取打开的菜单
|
||||||
getOpenedNamesByActiveName(name) {
|
getOpenedNamesByActiveName(name) {
|
||||||
// return this.$route.matched
|
|
||||||
// .map(item => item.name)
|
|
||||||
// .filter(item => item !== name);
|
|
||||||
let array = this.menuNameMatchedMap.get(name);
|
let array = this.menuNameMatchedMap.get(name);
|
||||||
if(array){
|
if(array){
|
||||||
return array;
|
return array;
|
||||||
@ -190,8 +187,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateOpenName(name) {
|
updateOpenName(name) {
|
||||||
// if (name === this.$config.homeName) this.openedNames = [];
|
|
||||||
// else this.openedNames = this.getOpenedNamesByActiveName(name);
|
|
||||||
this.openedNames = this.menuNameMatchedMap.get(name);
|
this.openedNames = this.menuNameMatchedMap.get(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,11 +363,17 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('privilegeTree',privilegeTree)
|
||||||
this.menuList = privilegeTree;
|
this.menuList = privilegeTree;
|
||||||
},
|
},
|
||||||
|
|
||||||
recursion(children, parentMenu) {
|
recursion(children, parentMenu) {
|
||||||
for (const router of children) {
|
for (const router of children) {
|
||||||
|
//验证权限
|
||||||
|
if (this.$store.state.user.privilegeMenuKeyList.indexOf(router.name) ===-1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//过滤非菜单
|
//过滤非菜单
|
||||||
if (!router.meta.hideInMenu) {
|
if (!router.meta.hideInMenu) {
|
||||||
//验证权限
|
//验证权限
|
||||||
@ -393,7 +399,6 @@ export default {
|
|||||||
|
|
||||||
let menuNameArray = this.menuNameMatchedMap.get(parentMenu.name);
|
let menuNameArray = this.menuNameMatchedMap.get(parentMenu.name);
|
||||||
this.menuNameMatchedMap.set(menu.name, [...menuNameArray, menu.name]);
|
this.menuNameMatchedMap.set(menu.name, [...menuNameArray, menu.name]);
|
||||||
|
|
||||||
parentMenu.children.push(menu);
|
parentMenu.children.push(menu);
|
||||||
//存在孩子节点,开始递归
|
//存在孩子节点,开始递归
|
||||||
if (router.children && router.children.length > 0) {
|
if (router.children && router.children.length > 0) {
|
||||||
|
@ -211,9 +211,6 @@ if (process.env.NODE_ENV === 'development') {
|
|||||||
delete tempCheckObj.checkRouterPathMap;
|
delete tempCheckObj.checkRouterPathMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tempCheckObj.checkRouterNameMap;
|
|
||||||
delete tempCheckObj.checkRouterPathMap;
|
|
||||||
|
|
||||||
const topMenuArray = routers.filter(e => e.meta.topMenu);
|
const topMenuArray = routers.filter(e => e.meta.topMenu);
|
||||||
export { topMenuArray };
|
export { topMenuArray };
|
||||||
|
|
||||||
|
@ -48,6 +48,10 @@ export const systemSetting = [
|
|||||||
title: '编辑',
|
title: '编辑',
|
||||||
name: 'privilege-main-update'
|
name: 'privilege-main-update'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '批量保存功能点',
|
||||||
|
name: 'privilege-batch-save-points'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '查询',
|
title: '查询',
|
||||||
name: 'privilege-main-search'
|
name: 'privilege-main-search'
|
||||||
|
@ -90,6 +90,17 @@
|
|||||||
<div class="card-title" slot="title">
|
<div class="card-title" slot="title">
|
||||||
<Icon type="ios-cog"></Icon>功能点
|
<Icon type="ios-cog"></Icon>功能点
|
||||||
</div>
|
</div>
|
||||||
|
<div slot="extra">
|
||||||
|
<Button
|
||||||
|
@click="addBatchSavePoints"
|
||||||
|
icon="ios-albums-outline"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
v-privilege="'privilege-batch-save-points'"
|
||||||
|
v-if="pointsChangeNum > 0"
|
||||||
|
>批量保存功能点</Button>
|
||||||
|
</div>
|
||||||
|
<Alert show-icon type="warning" v-if="pointsChangeNum > 0">有 {{this.pointsChangeNum}} 个功能点更新,请立即批量保存!</Alert>
|
||||||
<Row>
|
<Row>
|
||||||
<Table :columns="privilegeTableColumn" :data="privilegeTableData" border></Table>
|
<Table :columns="privilegeTableColumn" :data="privilegeTableData" border></Table>
|
||||||
</Row>
|
</Row>
|
||||||
@ -135,8 +146,11 @@ export default {
|
|||||||
},
|
},
|
||||||
menuTree: [],
|
menuTree: [],
|
||||||
menusChange: false,
|
menusChange: false,
|
||||||
|
//菜单差异数量
|
||||||
menusChangeNum: 0,
|
menusChangeNum: 0,
|
||||||
menuList: [],
|
menuList: [],
|
||||||
|
//功能点差异数量
|
||||||
|
pointsChangeNum:0,
|
||||||
routerMap: new Map(),
|
routerMap: new Map(),
|
||||||
privilegeTableData: [],
|
privilegeTableData: [],
|
||||||
privilegeTableColumn: [
|
privilegeTableColumn: [
|
||||||
@ -290,7 +304,24 @@ console.error(privilegeTree)
|
|||||||
this.menusChangeNum = this.menusChangeNum + 1;
|
this.menusChangeNum = this.menusChangeNum + 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 菜单批量保存
|
// 批量保存功能点
|
||||||
|
async addBatchSavePoints(){
|
||||||
|
this.$Spin.show();
|
||||||
|
let result = await privilegeApi.addBatchSavePoints(
|
||||||
|
this.privilegeTableData.map(e =>{
|
||||||
|
return Object.assign({},{
|
||||||
|
functionName:e.title,
|
||||||
|
menuKey:e.parentKey,
|
||||||
|
functionKey:e.name,
|
||||||
|
sort:e.sort
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
this.$Message.success('批量保存成功');
|
||||||
|
this.$Spin.hide();
|
||||||
|
this.loadPrivilegeTableData(this.privilegeTableData[0].parentKey);
|
||||||
|
},
|
||||||
|
// 批量保存菜单
|
||||||
async addBatchSaveMenu() {
|
async addBatchSaveMenu() {
|
||||||
this.$Spin.show();
|
this.$Spin.show();
|
||||||
let result = await privilegeApi.addBatchSaveMenu(this.menuList);
|
let result = await privilegeApi.addBatchSaveMenu(this.menuList);
|
||||||
@ -312,33 +343,45 @@ console.error(privilegeTree)
|
|||||||
this.formData.show = true;
|
this.formData.show = true;
|
||||||
},
|
},
|
||||||
// 查询菜单对应的页面以及功能点
|
// 查询菜单对应的页面以及功能点
|
||||||
async getPrivilegeList(menuKey) {
|
async getPrivilegeList(menuKey,frontPrivilegeData) {
|
||||||
this.$Spin.show();
|
this.$Spin.show();
|
||||||
this.formData.show = false;
|
this.formData.show = false;
|
||||||
let result = await privilegeApi.queryPrivilegeFunctionList(menuKey);
|
let result = await privilegeApi.queryPrivilegeFunctionList(menuKey);
|
||||||
this.$Spin.hide();
|
this.$Spin.hide();
|
||||||
let datas = result.data;
|
//处理服务端存储的功能点
|
||||||
let functionKey = new Map();
|
let serverPointData = result.data;
|
||||||
datas.map(item => {
|
let serverFunctionKeyUrlMap = new Map();
|
||||||
functionKey.set(item.functionKey, item.url);
|
serverPointData.map(item => {
|
||||||
|
serverFunctionKeyUrlMap.set(item.functionKey, {url:item.url?item.url:''});
|
||||||
});
|
});
|
||||||
let privilegeTableData = [];
|
|
||||||
this.privilegeTableData.map(item => {
|
let pointsChangeNum = 0;
|
||||||
let url = functionKey.get(item.name) || '';
|
for (let frontPrivilege of frontPrivilegeData) {
|
||||||
item.url = url;
|
let serverUrlObject = serverFunctionKeyUrlMap.get(frontPrivilege.name);
|
||||||
privilegeTableData.push(item);
|
if(serverUrlObject){
|
||||||
});
|
frontPrivilege.url = serverUrlObject.url;
|
||||||
this.privilegeTableData = privilegeTableData;
|
}else{
|
||||||
|
frontPrivilege.url = '';
|
||||||
|
//服务端没有此功能点
|
||||||
|
pointsChangeNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.pointsChangeNum = pointsChangeNum;
|
||||||
|
this.privilegeTableData = frontPrivilegeData;
|
||||||
},
|
},
|
||||||
// 点击菜单事件
|
// 点击菜单事件
|
||||||
loadPrivilegeTableData(name) {
|
loadPrivilegeTableData(name) {
|
||||||
let router = this.routerMap.get(name);
|
let router = this.routerMap.get(name);
|
||||||
|
let frontPrivilegeData = [];
|
||||||
if (!_.isUndefined(router) && router.meta && router.meta.privilege) {
|
if (!_.isUndefined(router) && router.meta && router.meta.privilege) {
|
||||||
this.privilegeTableData = router.meta.privilege.map(e =>
|
let sort = 0;
|
||||||
Object.assign({}, e, { parentKey: name })
|
frontPrivilegeData = router.meta.privilege.map(e =>{
|
||||||
|
sort++;
|
||||||
|
return Object.assign({}, e, { parentKey: name },{sort});
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.getPrivilegeList(name);
|
this.getPrivilegeList(name,frontPrivilegeData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
26
smart-admin-web/src/views/three-router/three-content.vue
Normal file
26
smart-admin-web/src/views/three-router/three-content.vue
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<Card class="warp-card" dis-hover>
|
||||||
|
<Alert>
|
||||||
|
<h3>三级路由页面</h3>
|
||||||
|
<pre>
|
||||||
|
这个是三级路由页面。
|
||||||
|
</pre>
|
||||||
|
</Alert>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ThreeContent',
|
||||||
|
components: {},
|
||||||
|
props: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user