package org.jeecg.modules.dnc.response;
|
|
import lombok.Data;
|
import lombok.NoArgsConstructor;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* Created by Administrator on 2019/9/6.
|
*/
|
@Data
|
@NoArgsConstructor
|
public class CommonJsonTree {
|
private String id; // 要显示的节点的ID
|
private String label; // 要显示的子节点的名称
|
private String iconClass; // 节点的图标
|
private String parentId; // 父节点的ID
|
private List<CommonJsonTree> children; // 孩子节点的List
|
private String rField; //绑定扩展鼠性
|
private boolean checked = false; //是否选中
|
private boolean disabled = false; //是否被禁用
|
/**
|
* 节点分类
|
* 产品树型 1 产品 2 部件 3 零件
|
* 设备树形 1 设备分组 2 设备
|
*/
|
private Integer type;
|
|
// 添加子节点的方法
|
public CommonJsonTree addChildren(CommonJsonTree node) {
|
if (this.children == null) {
|
this.children = new ArrayList<CommonJsonTree>();
|
}
|
this.children.add(node);
|
return node;
|
}
|
|
public boolean hasChildren() {
|
boolean bu = true;
|
if(getChildren() == null || getChildren().isEmpty()) {
|
bu = false;
|
return bu;
|
}
|
return bu;
|
}
|
|
/**
|
* 获取树的所有叶子节点
|
* @param tree
|
* @return
|
*/
|
public static Map<String, CommonJsonTree> getLeafNode(Map<String, CommonJsonTree> map, CommonJsonTree tree) {
|
if(tree == null)
|
return map;
|
if(tree.hasChildren()) {
|
List<CommonJsonTree> childrenNodes = tree.getChildren();
|
for(CommonJsonTree child : childrenNodes) {
|
map = getLeafNode(map, child);
|
}
|
map.put(tree.getId(), tree);
|
}else {
|
map.put(tree.getId(), tree);
|
}
|
return map;
|
}
|
}
|