【7.2.3】删掉半联动状态标识

pull/30/head
fengshuonan 2022-06-27 17:02:38 +08:00
parent 3c6ed94d05
commit 946b2f7f9d
4 changed files with 5 additions and 107 deletions

View File

@ -69,12 +69,6 @@ public class MenuAndButtonTreeResponse implements AbstractTreeNode<MenuAndButton
@ChineseDescription("是否选择(已拥有的是true)")
private Boolean checked;
/**
*
*/
@ChineseDescription("是否是半开状态(一部分选中)")
private Boolean indeterminate;
/**
*
*/

View File

@ -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);
}
}

View File

@ -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.
*
* GunsAPACHE 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);
}
}
}

View File

@ -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.SysMenuButton;
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.service.SysMenuButtonService;
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);
// 菜单列表转化为一棵树
List<MenuAndButtonTreeResponse> menuAndButtonTreeResponses1 = new DefaultTreeBuildFactory<MenuAndButtonTreeResponse>().doTreeBuild(menuAndButtonTreeResponses);
IndeterminateFactory.fillIndeterminate(menuAndButtonTreeResponses1);
return menuAndButtonTreeResponses1;
return new DefaultTreeBuildFactory<MenuAndButtonTreeResponse>().doTreeBuild(menuAndButtonTreeResponses);
}
@Override