add 增加按钮权限
This commit is contained in:
parent
df65670d3d
commit
fe27d8920a
@ -15,12 +15,42 @@ public enum ButtonPermissionEnum implements NodeExtEnum {
|
||||
/**
|
||||
* 是否弹窗选人
|
||||
*/
|
||||
APPROVE("是否弹窗选人", "1", false),
|
||||
POP("是否弹窗选人", "pop", false),
|
||||
|
||||
/**
|
||||
* 是否能委托
|
||||
*/
|
||||
REJECT("是否能委托", "2", false);
|
||||
TRUST("是否能委托", "trust", false),
|
||||
|
||||
/**
|
||||
* 是否能转办
|
||||
*/
|
||||
TRANSFER("是否能转办", "transfer", false),
|
||||
|
||||
/**
|
||||
* 是否能抄送
|
||||
*/
|
||||
COPY("是否能抄送", "copy", false),
|
||||
|
||||
/**
|
||||
* 是否显示退回
|
||||
*/
|
||||
BACK("是否显示退回", "back", true),
|
||||
|
||||
/**
|
||||
* 是否能加签
|
||||
*/
|
||||
ADD_SIGN("是否能加签", "addSign", false),
|
||||
|
||||
/**
|
||||
* 是否能减签
|
||||
*/
|
||||
SUB_SIGN("是否能减签", "subSign", false),
|
||||
|
||||
/**
|
||||
* 是否能终止
|
||||
*/
|
||||
TERMINATION("是否能终止", "termination", true);
|
||||
|
||||
private final String label;
|
||||
private final String value;
|
||||
|
@ -9,16 +9,22 @@ public interface NodeExtEnum {
|
||||
|
||||
/**
|
||||
* 选项label
|
||||
*
|
||||
* @return 选项label
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* 选项值
|
||||
*
|
||||
* @return 选项值
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* 是否默认选中
|
||||
*
|
||||
* @return 是否默认选中
|
||||
*/
|
||||
boolean isSelected();
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 按钮权限
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-02-28
|
||||
*/
|
||||
@Data
|
||||
public class ButtonPermission implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 枚举路径
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 按钮编码
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
private boolean show;
|
||||
}
|
@ -1,16 +1,20 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.warm.flow.core.entity.User;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.ButtonPermissionEnum;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 任务视图
|
||||
@ -173,4 +177,34 @@ public class FlowTaskVo implements Serializable {
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "createBy")
|
||||
private String createByName;
|
||||
|
||||
/**
|
||||
* 按钮权限
|
||||
*/
|
||||
private List<ButtonPermission> buttonList;
|
||||
|
||||
public List<ButtonPermission> getButtonList(String ext) {
|
||||
List<ButtonPermission> buttonPermissions = Arrays.stream(ButtonPermissionEnum.values())
|
||||
.map(value -> {
|
||||
ButtonPermission buttonPermission = new ButtonPermission();
|
||||
buttonPermission.setCode(value.getValue());
|
||||
buttonPermission.setShow(false);
|
||||
return buttonPermission;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
if (StringUtils.isNotBlank(ext)) {
|
||||
List<ButtonPermission> buttonCodeList = JSONUtil.toList(JSONUtil.parseArray(ext), ButtonPermission.class);
|
||||
if (CollUtil.isNotEmpty(buttonCodeList)) {
|
||||
Optional<ButtonPermission> firstPermission = buttonCodeList.stream().findFirst();
|
||||
firstPermission.ifPresent(permission -> {
|
||||
Set<String> codeSet = Arrays.stream(permission.getValue().split(","))
|
||||
.map(String::trim)
|
||||
.filter(code -> !code.isEmpty())
|
||||
.collect(Collectors.toSet());
|
||||
buttonPermissions.forEach(bp -> bp.setShow(codeSet.contains(bp.getCode())));
|
||||
});
|
||||
}
|
||||
}
|
||||
return buttonPermissions;
|
||||
}
|
||||
}
|
||||
|
@ -487,9 +487,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
flowTaskVo.setFlowCode(definition.getFlowCode());
|
||||
flowTaskVo.setFlowName(definition.getFlowName());
|
||||
flowTaskVo.setBusinessId(instance.getBusinessId());
|
||||
//设置按钮权限
|
||||
List<Node> nodeList = nodeService.getByNodeCodes(Collections.singletonList(flowTaskVo.getNodeCode()), instance.getDefinitionId());
|
||||
if (CollUtil.isNotEmpty(nodeList)) {
|
||||
Node node = nodeList.get(0);
|
||||
flowTaskVo.setButtonList(flowTaskVo.getButtonList(node.getExt()));
|
||||
flowTaskVo.setNodeRatio(node.getNodeRatio());
|
||||
}
|
||||
return flowTaskVo;
|
||||
|
Loading…
x
Reference in New Issue
Block a user