mirror of https://gitee.com/stylefeng/roses
【7.2.3】删掉半联动状态标识
parent
3c6ed94d05
commit
946b2f7f9d
|
@ -69,12 +69,6 @@ public class MenuAndButtonTreeResponse implements AbstractTreeNode<MenuAndButton
|
||||||
@ChineseDescription("是否选择(已拥有的是true)")
|
@ChineseDescription("是否选择(已拥有的是true)")
|
||||||
private Boolean checked;
|
private Boolean checked;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否是半开状态(一部分选中)
|
|
||||||
*/
|
|
||||||
@ChineseDescription("是否是半开状态(一部分选中)")
|
|
||||||
private Boolean indeterminate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前节点的按钮集合
|
* 当前节点的按钮集合
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -212,26 +212,6 @@ public class AntdMenusFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 遍历一遍后,当前菜单没按钮,则直接略过
|
|
||||||
if (ObjectUtil.isEmpty(menuButtonList)) {
|
|
||||||
menuAndButtonTreeResponse.setButtons(menuButtonList);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
long checkedButtonsNumber = menuButtonList.stream().filter(MenuAndButtonTreeResponse::getChecked).count();
|
|
||||||
|
|
||||||
// 统计选中的数量
|
|
||||||
if (checkedButtonsNumber == 0) {
|
|
||||||
menuAndButtonTreeResponse.setChecked(false);
|
|
||||||
menuAndButtonTreeResponse.setIndeterminate(false);
|
|
||||||
} else if (checkedButtonsNumber == menuButtonList.size()) {
|
|
||||||
menuAndButtonTreeResponse.setChecked(true);
|
|
||||||
menuAndButtonTreeResponse.setIndeterminate(false);
|
|
||||||
} else {
|
|
||||||
menuAndButtonTreeResponse.setChecked(false);
|
|
||||||
menuAndButtonTreeResponse.setIndeterminate(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
menuAndButtonTreeResponse.setButtons(menuButtonList);
|
menuAndButtonTreeResponse.setButtons(menuButtonList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
|
||||||
*
|
|
||||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
|
||||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
|
||||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
|
||||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
|
||||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
|
||||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
|
||||||
*/
|
|
||||||
package cn.stylefeng.roses.kernel.system.modular.menu.factory;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.stylefeng.roses.kernel.system.api.pojo.menu.MenuAndButtonTreeResponse;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填充是否必选状态
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2022/6/24 18:35
|
|
||||||
*/
|
|
||||||
public class IndeterminateFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填充菜单的半开状态
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2022/6/24 18:36
|
|
||||||
*/
|
|
||||||
public static void fillIndeterminate(List<MenuAndButtonTreeResponse> menuAndButtonTreeResponses) {
|
|
||||||
for (MenuAndButtonTreeResponse menuAndButtonTreeRespons : menuAndButtonTreeResponses) {
|
|
||||||
List<MenuAndButtonTreeResponse> children = menuAndButtonTreeRespons.getChildren();
|
|
||||||
if (ObjectUtil.isEmpty(children)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取选中状态子节点数量
|
|
||||||
long selectedCount = children.stream().filter(MenuAndButtonTreeResponse::getChecked).count();
|
|
||||||
|
|
||||||
// 获取子节点数量
|
|
||||||
int childrenSize = children.size();
|
|
||||||
|
|
||||||
// 统计选中的数量
|
|
||||||
if (selectedCount == 0) {
|
|
||||||
menuAndButtonTreeRespons.setChecked(false);
|
|
||||||
menuAndButtonTreeRespons.setIndeterminate(false);
|
|
||||||
} else if (selectedCount == childrenSize) {
|
|
||||||
menuAndButtonTreeRespons.setChecked(true);
|
|
||||||
menuAndButtonTreeRespons.setIndeterminate(false);
|
|
||||||
} else {
|
|
||||||
menuAndButtonTreeRespons.setChecked(false);
|
|
||||||
menuAndButtonTreeRespons.setIndeterminate(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 继续遍历子节点并填充
|
|
||||||
IndeterminateFactory.fillIndeterminate(children);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -59,7 +59,10 @@ import cn.stylefeng.roses.kernel.system.api.pojo.role.request.SysRoleRequest;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenuButton;
|
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenuButton;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenuResource;
|
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenuResource;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.factory.*;
|
import cn.stylefeng.roses.kernel.system.modular.menu.factory.AntdMenusFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.system.modular.menu.factory.Antdv3MenusFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.system.modular.menu.factory.LayuiMenusFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.system.modular.menu.factory.MenuTypeFactory;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.mapper.SysMenuMapper;
|
import cn.stylefeng.roses.kernel.system.modular.menu.mapper.SysMenuMapper;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuButtonService;
|
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuButtonService;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuResourceService;
|
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuResourceService;
|
||||||
|
@ -471,9 +474,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
AntdMenusFactory.fillButtons(menuAndButtonTreeResponses, buttonList, roleMenuButtonList);
|
AntdMenusFactory.fillButtons(menuAndButtonTreeResponses, buttonList, roleMenuButtonList);
|
||||||
|
|
||||||
// 菜单列表转化为一棵树
|
// 菜单列表转化为一棵树
|
||||||
List<MenuAndButtonTreeResponse> menuAndButtonTreeResponses1 = new DefaultTreeBuildFactory<MenuAndButtonTreeResponse>().doTreeBuild(menuAndButtonTreeResponses);
|
return new DefaultTreeBuildFactory<MenuAndButtonTreeResponse>().doTreeBuild(menuAndButtonTreeResponses);
|
||||||
IndeterminateFactory.fillIndeterminate(menuAndButtonTreeResponses1);
|
|
||||||
return menuAndButtonTreeResponses1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue