Skip to content
Merged

Dev #91

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class FlowCreateRequest {
private long operatorId;

/**
* 父流程id
* 父流程id,系统自动赋值
*/
private long parentRecordId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,32 @@ public FlowCreateRequest toCreateRequest(){
return flowSession.toCreateRequest();
}

/**
* 创建流程请求,用于自流程的创建
* @param workId 流程设计id
* @param actionId 动作类型
* @param formData 流程数据
*/
public FlowCreateRequest toCreateRequest(String workId,
long operatorId,
String actionId,
String formData){
return flowSession.toCreateRequest(workId, operatorId, actionId, formData);
}

/**
* 创建流程请求,用于自流程的创建
* @param workId 流程设计id
* @param actionId 动作类型
* @param formData 流程数据
*/
public FlowCreateRequest toCreateRequest(String workId,
long operatorId,
String actionId,
Map<String,Object> formData){
return flowSession.toCreateRequest(workId, operatorId, actionId, formData);
}


/**
* 获取表单字段值(Groovy脚本调用)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.codingapi.flow.session;

import com.alibaba.fastjson.JSONObject;
import com.codingapi.flow.action.ActionType;
import com.codingapi.flow.action.IFlowAction;
import com.codingapi.flow.form.FormData;
import com.codingapi.flow.mock.MockRepositoryHolder;
Expand All @@ -15,6 +17,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* 流程会话对象
Expand Down Expand Up @@ -139,22 +142,56 @@ public static FlowSession startSession(


/**
* 创建流程请求
* 创建流程请求,用于自流程的创建
*/
public FlowCreateRequest toCreateRequest() {
FlowCreateRequest request = new FlowCreateRequest();
IFlowNode startNode = workflow.getStartNode();
IFlowAction action = startNode.actionManager().getFirstAction();
request.setWorkId(workflow.getId());
request.setFormData(formData.toMapData());
request.setActionId(action.id());
request.setOperatorId(currentOperator.getUserId());
IFlowAction action = startNode.actionManager().getActionByType(ActionType.SAVE.name());
return this.toCreateRequest(workflow.getId(),currentOperator.getUserId(),action.id(),formData.toMapData());
}


/**
* 创建流程请求,用于自流程的创建
* @param workId 流程设计id
* @param actionId 动作类型
* @param formData 流程数据
*/
public FlowCreateRequest toCreateRequest(String workId,
long operatorId,
String actionId,
String formData){

FlowCreateRequest request = new FlowCreateRequest();
request.setActionId(actionId);
request.setWorkId(workId);
request.setOperatorId(operatorId);
request.setFormData(JSONObject.parseObject(formData));
return request;
}

/**
* 创建流程请求,用于自流程的创建
* @param workId 流程设计id
* @param actionId 动作类型
* @param formData 流程数据
*/
public FlowCreateRequest toCreateRequest(String workId,
long operatorId,
String actionId,
Map<String,Object> formData){

FlowCreateRequest request = new FlowCreateRequest();
request.setActionId(actionId);
request.setWorkId(workId);
request.setOperatorId(operatorId);
request.setFormData(formData);
return request;
}


/**
* 创建流程动作请求
* 创建流程动作请求,用于自定义脚本的执行
*/
public FlowActionRequest toActionRequest() {
FlowActionRequest request = new FlowActionRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.alibaba.fastjson.JSONObject;
import com.codingapi.flow.api.pojo.NodeCreateRequest;
import com.codingapi.flow.api.pojo.WorkflowMeta;
import com.codingapi.flow.api.pojo.WorkflowUpdateVersionNameRequest;
import com.codingapi.flow.exception.FlowNotFoundException;
import com.codingapi.flow.exception.FlowPermissionException;
import com.codingapi.flow.gateway.FlowOperatorGateway;
import com.codingapi.flow.mock.MockInstance;
Expand Down Expand Up @@ -53,6 +55,15 @@ public Response updateVersionName(@RequestBody WorkflowUpdateVersionNameRequest
return Response.buildSuccess();
}

@GetMapping("/meta")
public SingleResponse<WorkflowMeta> getMeta(IdRequest request){
Workflow workflow = workflowService.getWorkflow(request.getStringId());
if(workflow!=null){
return SingleResponse.of(new WorkflowMeta(workflow));
}
throw FlowNotFoundException.workflow(request.getStringId());
}


@PostMapping("/changeVersion")
public Response changeVersion(@RequestBody IdRequest request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.codingapi.flow.api.pojo;

import com.codingapi.flow.action.IFlowAction;
import com.codingapi.flow.form.FlowForm;
import com.codingapi.flow.manager.ActionManager;
import com.codingapi.flow.node.IFlowNode;
import com.codingapi.flow.workflow.Workflow;
import lombok.Data;

import java.util.List;

@Data
public class WorkflowMeta {

private String workId;
private List<ActionOption> actions;
private FlowForm form;

public WorkflowMeta(Workflow workflow) {
this.workId = workflow.getId();
this.form = workflow.getForm();
IFlowNode startNode = workflow.getStartNode();
ActionManager actionManager = startNode.actionManager();
this.actions = actionManager.getActions().stream().map(ActionOption::new).toList();
}


@Data
public static class ActionOption {
private String actionId;
private String title;
private String type;

public ActionOption(IFlowAction action) {
this.actionId = action.id();
this.title = action.title();
this.type = action.type();
}
}
}
2 changes: 1 addition & 1 deletion flow-frontend
Submodule flow-frontend updated 25 files
+8 −0 packages/flow-design/src/api/workflow.ts
+8 −0 packages/flow-design/src/plugins/sub-process-operator-view-type.ts
+32 −0 packages/flow-design/src/plugins/view/sub-process-opreator-view.tsx
+37 −9 packages/flow-design/src/plugins/view/sub-process-view.tsx
+29 −0 packages/flow-design/src/script-components/components/form-data/components/list.tsx
+36 −0 packages/flow-design/src/script-components/components/form-data/components/value.tsx
+31 −0 packages/flow-design/src/script-components/components/form-data/context/index.ts
+50 −0 packages/flow-design/src/script-components/components/form-data/hooks/use-form-data-context.tsx
+64 −0 packages/flow-design/src/script-components/components/form-data/index.tsx
+92 −0 packages/flow-design/src/script-components/components/form-data/presenters/flow-form-presenter.tsx
+138 −0 packages/flow-design/src/script-components/components/form-data/presenters/form-data-presenter.ts
+2 −0 packages/flow-design/src/script-components/components/form-data/presenters/index.ts
+36 −0 packages/flow-design/src/script-components/components/form-data/store.tsx
+36 −0 packages/flow-design/src/script-components/components/form-data/types.ts
+7 −0 packages/flow-design/src/script-components/components/sub-process/hooks/use-current-workflow-presenter.ts
+14 −0 packages/flow-design/src/script-components/components/sub-process/hooks/use-sub-process-presenter.tsx
+33 −0 packages/flow-design/src/script-components/components/sub-process/hooks/use-target-workflow-presenter.tsx
+88 −0 packages/flow-design/src/script-components/components/sub-process/index.tsx
+24 −0 packages/flow-design/src/script-components/components/sub-process/models/index.ts
+26 −0 packages/flow-design/src/script-components/components/sub-process/presenters/current-workflow-presenter.ts
+3 −0 packages/flow-design/src/script-components/components/sub-process/presenters/index.ts
+47 −0 packages/flow-design/src/script-components/components/sub-process/presenters/sub-process-presenter.ts
+46 −0 packages/flow-design/src/script-components/components/sub-process/presenters/target-workflow-presenter.ts
+42 −0 packages/flow-design/src/script-components/components/sub-process/typings/index.ts
+1 −1 packages/flow-design/src/script-components/modal/sub-process-config-modal.tsx