mirror of
				https://gitee.com/lab1024/smart-admin.git
				synced 2025-11-04 18:33:43 +08:00 
			
		
		
		
	v1.1.0
This commit is contained in:
		@@ -124,7 +124,6 @@ SmartAdmin微信群(**加我微信拉你入群!**)
 | 
			
		||||
</tr>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
作者简介:
 | 
			
		||||
[卓大](https://zhuoluodada.cn), 1024创新实验室主任,混迹于各个技术圈,研究过计算机,熟悉点java,略懂点前端。
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
EmployeeController.updatePwd
 | 
			
		||||
 | 
			
		||||
2 更新功能点
 | 
			
		||||
PrivilegeController functionSaveOrUpdate和menuBatchSave
 | 
			
		||||
PrivilegeController functionSaveOrUpdate和menuBatchSave、batchSaveFunctionList
 | 
			
		||||
 | 
			
		||||
3 超管默认账号
 | 
			
		||||
sa/123456
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ public enum IdGeneratorEnum {
 | 
			
		||||
 | 
			
		||||
    ORDER(1, "order");
 | 
			
		||||
 | 
			
		||||
    private int id;
 | 
			
		||||
    private long id;
 | 
			
		||||
    private String keyName;
 | 
			
		||||
 | 
			
		||||
    IdGeneratorEnum(int id, String keyName) {
 | 
			
		||||
@@ -34,7 +34,7 @@ public enum IdGeneratorEnum {
 | 
			
		||||
        return "IdGeneratorEnum{" + "id=" + id + ", keyName='" + keyName + '\'' + '}';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getId() {
 | 
			
		||||
    public long getId() {
 | 
			
		||||
        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 MENU_NOT_EXIST = new PrivilegeResponseCodeConst(7003, "菜单不存在,清先保存菜单!");
 | 
			
		||||
 | 
			
		||||
    public static final PrivilegeResponseCodeConst POINT_NOT_EXIST = new PrivilegeResponseCodeConst(7004, "功能点不存在,清先保存功能点!");
 | 
			
		||||
 | 
			
		||||
    public PrivilegeResponseCodeConst(int code, String msg) {
 | 
			
		||||
        super(code, msg);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -41,8 +41,8 @@ public class PrivilegeController {
 | 
			
		||||
    @ApiOperation(value = "菜单批量保存")
 | 
			
		||||
    @PostMapping("/privilege/menu/batchSaveMenu")
 | 
			
		||||
    public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
 | 
			
		||||
//        return privilegeService.menuBatchSave(menuList);
 | 
			
		||||
        return ResponseDTO.succ();
 | 
			
		||||
        return privilegeService.menuBatchSave(menuList);
 | 
			
		||||
//        return ResponseDTO.succ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -56,10 +56,18 @@ public class PrivilegeController {
 | 
			
		||||
    @ApiOperation(value = "保存更新功能点")
 | 
			
		||||
    @PostMapping("/privilege/function/saveOrUpdate")
 | 
			
		||||
    public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
 | 
			
		||||
//        return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
 | 
			
		||||
        return ResponseDTO.succ();
 | 
			
		||||
        return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
 | 
			
		||||
//        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 = "更新")
 | 
			
		||||
    @PostMapping("/privilege/function/query/{menuKey}")
 | 
			
		||||
    public ResponseDTO<List<PrivilegeFunctionVO>> functionQuery(@PathVariable String menuKey) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,20 @@
 | 
			
		||||
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.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.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.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.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -150,7 +149,7 @@ public class PrivilegeService {
 | 
			
		||||
            return ResponseDTO.succData(Lists.newArrayList());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<PrivilegeMenuVO> voList = privilegeEntityList.stream().map(e-> {
 | 
			
		||||
        List<PrivilegeMenuVO> voList = privilegeEntityList.stream().map(e -> {
 | 
			
		||||
            PrivilegeMenuVO vo = new PrivilegeMenuVO();
 | 
			
		||||
            vo.setMenuKey(e.getKey());
 | 
			
		||||
            vo.setMenuName(e.getName());
 | 
			
		||||
@@ -174,23 +173,14 @@ public class PrivilegeService {
 | 
			
		||||
        String functionKey = privilegeFunctionDTO.getFunctionKey();
 | 
			
		||||
        PrivilegeEntity functionEntity = privilegeDao.selectByKey(functionKey);
 | 
			
		||||
        if (functionEntity == null) {
 | 
			
		||||
            functionEntity = new PrivilegeEntity();
 | 
			
		||||
            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);
 | 
			
		||||
            return ResponseDTO.wrap(PrivilegeResponseCodeConst.POINT_NOT_EXIST);
 | 
			
		||||
        }
 | 
			
		||||
        functionEntity.setUrl(privilegeFunctionDTO.getUrl());
 | 
			
		||||
        functionEntity.setName(privilegeFunctionDTO.getFunctionName());
 | 
			
		||||
        functionEntity.setParentKey(privilegeFunctionDTO.getMenuKey());
 | 
			
		||||
        functionEntity.setSort(privilegeFunctionDTO.getSort());
 | 
			
		||||
        privilegeDao.updateById(functionEntity);
 | 
			
		||||
 | 
			
		||||
        return ResponseDTO.succ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -206,9 +196,8 @@ public class PrivilegeService {
 | 
			
		||||
            return ResponseDTO.succData(Lists.newArrayList());
 | 
			
		||||
        }
 | 
			
		||||
        List<PrivilegeFunctionVO> functionList = Lists.newArrayList();
 | 
			
		||||
        PrivilegeFunctionVO functionDTO;
 | 
			
		||||
        for (PrivilegeEntity functionEntity : functionPrivilegeList) {
 | 
			
		||||
            functionDTO = new PrivilegeFunctionVO();
 | 
			
		||||
            PrivilegeFunctionVO functionDTO = new PrivilegeFunctionVO();
 | 
			
		||||
            functionDTO.setFunctionKey(functionEntity.getKey());
 | 
			
		||||
            functionDTO.setFunctionName(functionEntity.getName());
 | 
			
		||||
            functionDTO.setMenuKey(functionEntity.getParentKey());
 | 
			
		||||
@@ -219,4 +208,70 @@ public class PrivilegeService {
 | 
			
		||||
        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) {
 | 
			
		||||
        Page page = SmartPageUtil.convert2QueryPage(queryDTO);
 | 
			
		||||
        if(queryDTO.getKey() != null){
 | 
			
		||||
            queryDTO.setKey(queryDTO.getKey().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
        List<SystemConfigEntity> entityList = systemConfigDao.selectSystemSettingList(page, queryDTO);
 | 
			
		||||
        PageResultDTO<SystemConfigVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, entityList, SystemConfigVO.class);
 | 
			
		||||
        return ResponseDTO.succData(pageResultDTO);
 | 
			
		||||
@@ -94,7 +97,9 @@ public class SystemConfigService {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public ResponseDTO<SystemConfigVO> selectByKey(String configKey) {
 | 
			
		||||
        configKey = configKey.toLowerCase();
 | 
			
		||||
        if(configKey != null){
 | 
			
		||||
            configKey = configKey.toLowerCase();
 | 
			
		||||
        }
 | 
			
		||||
        SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
 | 
			
		||||
        if (entity == null) {
 | 
			
		||||
            return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
 | 
			
		||||
@@ -112,7 +117,9 @@ public class SystemConfigService {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public <T> T selectByKey2Obj(String configKey, Class<T> clazz) {
 | 
			
		||||
        configKey = configKey.toLowerCase();
 | 
			
		||||
        if(configKey != null){
 | 
			
		||||
            configKey = configKey.toLowerCase();
 | 
			
		||||
        }
 | 
			
		||||
        SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
 | 
			
		||||
        if (entity == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
@@ -150,6 +157,7 @@ public class SystemConfigService {
 | 
			
		||||
        if(!valueValid.isSuccess()){
 | 
			
		||||
            return valueValid;
 | 
			
		||||
        }
 | 
			
		||||
        configAddDTO.setConfigKey(configAddDTO.getConfigKey().toLowerCase());
 | 
			
		||||
        SystemConfigEntity addEntity = SmartBeanUtil.copy(configAddDTO, SystemConfigEntity.class);
 | 
			
		||||
        addEntity.setIsUsing(JudgeEnum.YES.getValue());
 | 
			
		||||
        systemConfigDao.insert(addEntity);
 | 
			
		||||
@@ -171,7 +179,7 @@ public class SystemConfigService {
 | 
			
		||||
        if (entity == null) {
 | 
			
		||||
            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) {
 | 
			
		||||
            return ResponseDTO.wrap(SystemConfigResponseCodeConst.ALREADY_EXIST);
 | 
			
		||||
        }
 | 
			
		||||
@@ -180,6 +188,7 @@ public class SystemConfigService {
 | 
			
		||||
            return valueValid;
 | 
			
		||||
        }
 | 
			
		||||
        entity = SmartBeanUtil.copy(updateDTO, SystemConfigEntity.class);
 | 
			
		||||
        updateDTO.setConfigKey(updateDTO.getConfigKey().toLowerCase());
 | 
			
		||||
        systemConfigDao.updateById(entity);
 | 
			
		||||
 | 
			
		||||
        //刷新缓存
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -13,6 +13,10 @@ export const privilegeApi = {
 | 
			
		||||
  addBatchSaveMenu: data => {
 | 
			
		||||
    return postAxios('/privilege/menu/batchSaveMenu', data);
 | 
			
		||||
  },
 | 
			
		||||
  // 功能点批量保存
 | 
			
		||||
  addBatchSavePoints: data => {
 | 
			
		||||
    return postAxios('/privilege/function/batchSave', data);
 | 
			
		||||
  },
 | 
			
		||||
  // 查询菜单功能点
 | 
			
		||||
  queryPrivilegeFunctionList: menuKey => {
 | 
			
		||||
    return postAxios('/privilege/function/query/' + menuKey);
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
      v-show="!collapsed"
 | 
			
		||||
      width="auto"
 | 
			
		||||
    >
 | 
			
		||||
      <template v-for="item in menuList">
 | 
			
		||||
 <template v-for="item in menuList">
 | 
			
		||||
        <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>
 | 
			
		||||
          <menu-item
 | 
			
		||||
@@ -179,9 +179,6 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    // 从激活菜单的名称中获取打开的菜单
 | 
			
		||||
    getOpenedNamesByActiveName(name) {
 | 
			
		||||
      // return this.$route.matched
 | 
			
		||||
      //   .map(item => item.name)
 | 
			
		||||
      //   .filter(item => item !== name);
 | 
			
		||||
        let array =  this.menuNameMatchedMap.get(name);
 | 
			
		||||
        if(array){
 | 
			
		||||
            return array;
 | 
			
		||||
@@ -190,8 +187,6 @@ export default {
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    updateOpenName(name) {
 | 
			
		||||
      // if (name === this.$config.homeName) this.openedNames = [];
 | 
			
		||||
      // else this.openedNames = this.getOpenedNamesByActiveName(name);
 | 
			
		||||
      this.openedNames = this.menuNameMatchedMap.get(name);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -363,11 +363,17 @@ export default {
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      console.log('privilegeTree',privilegeTree)
 | 
			
		||||
      this.menuList = privilegeTree;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    recursion(children, parentMenu) {
 | 
			
		||||
      for (const router of children) {
 | 
			
		||||
          //验证权限
 | 
			
		||||
        if (this.$store.state.user.privilegeMenuKeyList.indexOf(router.name) ===-1) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }  
 | 
			
		||||
 | 
			
		||||
        //过滤非菜单
 | 
			
		||||
        if (!router.meta.hideInMenu) {
 | 
			
		||||
          //验证权限
 | 
			
		||||
@@ -393,7 +399,6 @@ export default {
 | 
			
		||||
 | 
			
		||||
          let menuNameArray = this.menuNameMatchedMap.get(parentMenu.name);
 | 
			
		||||
          this.menuNameMatchedMap.set(menu.name, [...menuNameArray, menu.name]);
 | 
			
		||||
 | 
			
		||||
          parentMenu.children.push(menu);
 | 
			
		||||
          //存在孩子节点,开始递归
 | 
			
		||||
          if (router.children && router.children.length > 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ import config from '@/config';
 | 
			
		||||
 | 
			
		||||
const { homeName } = config;
 | 
			
		||||
 | 
			
		||||
Vue.use(Router);
 | 
			
		||||
Vue.use(Router); 
 | 
			
		||||
const router = new Router({
 | 
			
		||||
  // routes: routers,
 | 
			
		||||
  routes: buildRouters(routers)
 | 
			
		||||
@@ -211,9 +211,6 @@ if (process.env.NODE_ENV === 'development') {
 | 
			
		||||
  delete tempCheckObj.checkRouterPathMap;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
delete tempCheckObj.checkRouterNameMap;
 | 
			
		||||
delete tempCheckObj.checkRouterPathMap;
 | 
			
		||||
 | 
			
		||||
const topMenuArray = routers.filter(e => e.meta.topMenu);
 | 
			
		||||
export { topMenuArray };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -48,6 +48,10 @@ export const systemSetting = [
 | 
			
		||||
              title: '编辑',
 | 
			
		||||
              name: 'privilege-main-update'
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              title: '批量保存功能点',
 | 
			
		||||
              name: 'privilege-batch-save-points'
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              title: '查询',
 | 
			
		||||
              name: 'privilege-main-search'
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,17 @@
 | 
			
		||||
        <div class="card-title" slot="title">
 | 
			
		||||
          <Icon type="ios-cog"></Icon>功能点
 | 
			
		||||
        </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>
 | 
			
		||||
          <Table :columns="privilegeTableColumn" :data="privilegeTableData" border></Table>
 | 
			
		||||
        </Row>
 | 
			
		||||
@@ -135,8 +146,11 @@ export default {
 | 
			
		||||
      },
 | 
			
		||||
      menuTree: [],
 | 
			
		||||
      menusChange: false,
 | 
			
		||||
      //菜单差异数量
 | 
			
		||||
      menusChangeNum: 0,
 | 
			
		||||
      menuList: [],
 | 
			
		||||
      //功能点差异数量
 | 
			
		||||
      pointsChangeNum:0,
 | 
			
		||||
      routerMap: new Map(),
 | 
			
		||||
      privilegeTableData: [],
 | 
			
		||||
      privilegeTableColumn: [
 | 
			
		||||
@@ -290,7 +304,24 @@ console.error(privilegeTree)
 | 
			
		||||
        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() {
 | 
			
		||||
      this.$Spin.show();
 | 
			
		||||
      let result = await privilegeApi.addBatchSaveMenu(this.menuList);
 | 
			
		||||
@@ -312,33 +343,45 @@ console.error(privilegeTree)
 | 
			
		||||
      this.formData.show = true;
 | 
			
		||||
    },
 | 
			
		||||
    // 查询菜单对应的页面以及功能点
 | 
			
		||||
    async getPrivilegeList(menuKey) {
 | 
			
		||||
    async getPrivilegeList(menuKey,frontPrivilegeData) {
 | 
			
		||||
      this.$Spin.show();
 | 
			
		||||
      this.formData.show = false;
 | 
			
		||||
      let result = await privilegeApi.queryPrivilegeFunctionList(menuKey);
 | 
			
		||||
      this.$Spin.hide();
 | 
			
		||||
      let datas = result.data;
 | 
			
		||||
      let functionKey = new Map();
 | 
			
		||||
      datas.map(item => {
 | 
			
		||||
        functionKey.set(item.functionKey, item.url);
 | 
			
		||||
      //处理服务端存储的功能点
 | 
			
		||||
      let serverPointData = result.data;
 | 
			
		||||
      let serverFunctionKeyUrlMap = new Map();
 | 
			
		||||
      serverPointData.map(item => {
 | 
			
		||||
        serverFunctionKeyUrlMap.set(item.functionKey, {url:item.url?item.url:''});
 | 
			
		||||
      });
 | 
			
		||||
      let privilegeTableData = [];
 | 
			
		||||
      this.privilegeTableData.map(item => {
 | 
			
		||||
        let url = functionKey.get(item.name) || '';
 | 
			
		||||
        item.url = url;
 | 
			
		||||
        privilegeTableData.push(item);
 | 
			
		||||
      });
 | 
			
		||||
      this.privilegeTableData = privilegeTableData;
 | 
			
		||||
      
 | 
			
		||||
      let pointsChangeNum = 0;
 | 
			
		||||
      for (let frontPrivilege of frontPrivilegeData) {
 | 
			
		||||
        let serverUrlObject = serverFunctionKeyUrlMap.get(frontPrivilege.name);
 | 
			
		||||
        if(serverUrlObject){
 | 
			
		||||
            frontPrivilege.url = serverUrlObject.url;
 | 
			
		||||
        }else{
 | 
			
		||||
          frontPrivilege.url = '';
 | 
			
		||||
          //服务端没有此功能点
 | 
			
		||||
          pointsChangeNum++;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      this.pointsChangeNum = pointsChangeNum;
 | 
			
		||||
      this.privilegeTableData = frontPrivilegeData;
 | 
			
		||||
    },
 | 
			
		||||
    // 点击菜单事件
 | 
			
		||||
    loadPrivilegeTableData(name) {
 | 
			
		||||
      let router = this.routerMap.get(name);
 | 
			
		||||
      let frontPrivilegeData = [];
 | 
			
		||||
      if (!_.isUndefined(router) && router.meta && router.meta.privilege) {
 | 
			
		||||
        this.privilegeTableData = router.meta.privilege.map(e =>
 | 
			
		||||
          Object.assign({}, e, { parentKey: name })
 | 
			
		||||
        let sort = 0;
 | 
			
		||||
        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>
 | 
			
		||||
		Reference in New Issue
	
	Block a user