mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-23 23:09:47 +08:00
update 添加抄送设置和变量枚举,优化扩展节点配置逻辑
This commit is contained in:
@ -0,0 +1,20 @@
|
|||||||
|
package org.dromara.workflow.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抄送设置枚举
|
||||||
|
*
|
||||||
|
* @author AprilWind
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum CopySettingEnum implements NodeExtEnum {
|
||||||
|
;
|
||||||
|
private final String label;
|
||||||
|
private final String value;
|
||||||
|
private final boolean selected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
package org.dromara.workflow.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量枚举
|
||||||
|
*
|
||||||
|
* @author AprilWind
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum VariablesEnum implements NodeExtEnum {
|
||||||
|
;
|
||||||
|
private final String label;
|
||||||
|
private final String value;
|
||||||
|
private final boolean selected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,9 @@ import org.dromara.warm.flow.ui.service.NodeExtService;
|
|||||||
import org.dromara.warm.flow.ui.vo.NodeExt;
|
import org.dromara.warm.flow.ui.vo.NodeExt;
|
||||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||||
import org.dromara.workflow.common.enums.ButtonPermissionEnum;
|
import org.dromara.workflow.common.enums.ButtonPermissionEnum;
|
||||||
|
import org.dromara.workflow.common.enums.CopySettingEnum;
|
||||||
import org.dromara.workflow.common.enums.NodeExtEnum;
|
import org.dromara.workflow.common.enums.NodeExtEnum;
|
||||||
|
import org.dromara.workflow.common.enums.VariablesEnum;
|
||||||
import org.dromara.workflow.domain.vo.ButtonPermissionVo;
|
import org.dromara.workflow.domain.vo.ButtonPermissionVo;
|
||||||
import org.dromara.workflow.service.IFlwNodeExtService;
|
import org.dromara.workflow.service.IFlwNodeExtService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -36,14 +38,35 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
|||||||
/**
|
/**
|
||||||
* 存储不同 dictType 对应的配置信息
|
* 存储不同 dictType 对应的配置信息
|
||||||
*/
|
*/
|
||||||
private static final Map<String, ButtonPermission> CHILD_NODE_MAP = new HashMap<>();
|
private static final Map<String, Map<String, Object>> CHILD_NODE_MAP;
|
||||||
|
|
||||||
record ButtonPermission(String label, Integer type, Boolean must, Boolean multiple) {
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CHILD_NODE_MAP.put(ButtonPermissionEnum.class.getSimpleName(),
|
CHILD_NODE_MAP = Map.of(
|
||||||
new ButtonPermission("权限按钮", 4, false, true));
|
CopySettingEnum.class.getSimpleName(),
|
||||||
|
Map.of(
|
||||||
|
"label", "抄送对象",
|
||||||
|
"type", 2,
|
||||||
|
"must", false,
|
||||||
|
"multiple", false,
|
||||||
|
"desc", "设置该节点的抄送办理人"
|
||||||
|
),
|
||||||
|
VariablesEnum.class.getSimpleName(),
|
||||||
|
Map.of(
|
||||||
|
"label", "自定义参数",
|
||||||
|
"type", 2,
|
||||||
|
"must", false,
|
||||||
|
"multiple", false,
|
||||||
|
"desc", "节点执行时可以使用的自定义参数"
|
||||||
|
),
|
||||||
|
ButtonPermissionEnum.class.getSimpleName(),
|
||||||
|
Map.of(
|
||||||
|
"label", "权限按钮",
|
||||||
|
"type", 4,
|
||||||
|
"must", false,
|
||||||
|
"multiple", true,
|
||||||
|
"desc", "控制该节点的按钮权限"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final DictService dictService;
|
private final DictService dictService;
|
||||||
@ -56,6 +79,9 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
|||||||
@Override
|
@Override
|
||||||
public List<NodeExt> getNodeExt() {
|
public List<NodeExt> getNodeExt() {
|
||||||
List<NodeExt> nodeExtList = new ArrayList<>();
|
List<NodeExt> nodeExtList = new ArrayList<>();
|
||||||
|
// 构建基础设置页面
|
||||||
|
nodeExtList.add(buildNodeExt("wf_basic_tab", "基础设置", 1,
|
||||||
|
List.of(CopySettingEnum.class, VariablesEnum.class)));
|
||||||
// 构建按钮权限页面
|
// 构建按钮权限页面
|
||||||
nodeExtList.add(buildNodeExt("wf_button_tab", "权限", 2,
|
nodeExtList.add(buildNodeExt("wf_button_tab", "权限", 2,
|
||||||
List.of(ButtonPermissionEnum.class)));
|
List.of(ButtonPermissionEnum.class)));
|
||||||
@ -105,9 +131,20 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String simpleName = enumClass.getSimpleName();
|
String simpleName = enumClass.getSimpleName();
|
||||||
NodeExt.ChildNode childNode = buildChildNodeMap(simpleName);
|
NodeExt.ChildNode childNode = new NodeExt.ChildNode();
|
||||||
|
Map<String, Object> map = CHILD_NODE_MAP.get(simpleName);
|
||||||
// 编码,此json中唯
|
// 编码,此json中唯
|
||||||
childNode.setCode(simpleName);
|
childNode.setCode(simpleName);
|
||||||
|
// label名称
|
||||||
|
childNode.setLabel(Convert.toStr(map.get("label")));
|
||||||
|
// 1:输入框 2:文本域 3:下拉框 4:选择框
|
||||||
|
childNode.setType(Convert.toInt(map.get("type"), 1));
|
||||||
|
// 是否必填
|
||||||
|
childNode.setMust(Convert.toBool(map.get("must"), false));
|
||||||
|
// 是否多选
|
||||||
|
childNode.setMultiple(Convert.toBool(map.get("multiple"), true));
|
||||||
|
// 描述
|
||||||
|
childNode.setDesc(Convert.toStr(map.get("desc"), null));
|
||||||
// 字典,下拉框和复选框时用到
|
// 字典,下拉框和复选框时用到
|
||||||
childNode.setDict(Arrays.stream(enumClass.getEnumConstants())
|
childNode.setDict(Arrays.stream(enumClass.getEnumConstants())
|
||||||
.map(NodeExtEnum.class::cast)
|
.map(NodeExtEnum.class::cast)
|
||||||
@ -128,12 +165,18 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
|||||||
if (ObjectUtil.isNull(dictTypeDTO)) {
|
if (ObjectUtil.isNull(dictTypeDTO)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NodeExt.ChildNode childNode = buildChildNodeMap(dictType);
|
NodeExt.ChildNode childNode = new NodeExt.ChildNode();
|
||||||
// 编码,此json中唯一
|
// 编码,此json中唯一
|
||||||
childNode.setCode(dictType);
|
childNode.setCode(dictType);
|
||||||
// label名称
|
// label名称
|
||||||
childNode.setLabel(dictTypeDTO.getDictName());
|
childNode.setLabel(dictTypeDTO.getDictName());
|
||||||
// 描述
|
// 1:输入框 2:文本域 3:下拉框 4:选择框
|
||||||
|
childNode.setType(3);
|
||||||
|
// 是否必填
|
||||||
|
childNode.setMust(false);
|
||||||
|
// 是否多选
|
||||||
|
childNode.setMultiple(true);
|
||||||
|
// 描述 (可根据描述参数解析更多配置,如type,must,multiple等)
|
||||||
childNode.setDesc(dictTypeDTO.getRemark());
|
childNode.setDesc(dictTypeDTO.getRemark());
|
||||||
// 字典,下拉框和复选框时用到
|
// 字典,下拉框和复选框时用到
|
||||||
childNode.setDict(dictService.getDictData(dictType)
|
childNode.setDict(dictService.getDictData(dictType)
|
||||||
@ -143,33 +186,6 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
|||||||
return childNode;
|
return childNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 CHILD_NODE_MAP 中的配置信息,构建一个基本的 ChildNode 对象
|
|
||||||
* 该方法用于设置 ChildNode 的常规属性,例如 label、type、是否必填、是否多选等
|
|
||||||
*
|
|
||||||
* @param key CHILD_NODE_MAP 的 key
|
|
||||||
* @return 返回构建好的 ChildNode 对象
|
|
||||||
*/
|
|
||||||
private NodeExt.ChildNode buildChildNodeMap(String key) {
|
|
||||||
NodeExt.ChildNode childNode = new NodeExt.ChildNode();
|
|
||||||
ButtonPermission bp = CHILD_NODE_MAP.get(key);
|
|
||||||
if (bp == null) {
|
|
||||||
childNode.setType(1);
|
|
||||||
childNode.setMust(false);
|
|
||||||
childNode.setMultiple(true);
|
|
||||||
return childNode;
|
|
||||||
}
|
|
||||||
// label名称
|
|
||||||
childNode.setLabel(bp.label());
|
|
||||||
// 1:输入框 2:输入框 3:下拉框 4:选择框
|
|
||||||
childNode.setType(bp.type());
|
|
||||||
// 是否必填
|
|
||||||
childNode.setMust(bp.must());
|
|
||||||
// 是否多选
|
|
||||||
childNode.setMultiple(bp.multiple());
|
|
||||||
return childNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从扩展属性构建按钮权限列表:根据 ext 中记录的权限值,标记每个按钮是否勾选
|
* 从扩展属性构建按钮权限列表:根据 ext 中记录的权限值,标记每个按钮是否勾选
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user