Skip to content

Commit afbd7ec

Browse files
committed
fix ui
1 parent 5d1cca9 commit afbd7ec

9 files changed

Lines changed: 103 additions & 43 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/workflow/Workflow.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public class Workflow {
5858
*/
5959
private long createdTime;
6060

61+
/**
62+
* 更新时间
63+
*/
64+
private long updatedTime;
65+
6166
/**
6267
* 流程表单
6368
*/
@@ -93,6 +98,7 @@ protected Workflow() {
9398
this.id = RandomUtils.generateStringId();
9499
this.code = RandomUtils.generateWorkflowCode();
95100
this.createdTime = System.currentTimeMillis();
101+
this.updatedTime = System.currentTimeMillis();
96102
this.operatorCreateScript = OperatorMatchScript.any();
97103
this.nodes = new ArrayList<>();
98104
this.edges = new ArrayList<>();
@@ -147,6 +153,10 @@ protected void setCreatedTime(long createdTime) {
147153
this.createdTime = createdTime;
148154
}
149155

156+
protected void setUpdatedTime(long updatedTime) {
157+
this.updatedTime = updatedTime;
158+
}
159+
150160
protected void setStrategies(List<IWorkflowStrategy> strategies) {
151161
this.strategies = strategies;
152162
}
@@ -172,6 +182,7 @@ public String toJson(boolean hasSchema) {
172182
map.put("nodes", nodes.stream().map(IFlowNode::toMap).toList());
173183
map.put("edges", edges);
174184
map.put("createdTime", String.valueOf(createdTime));
185+
map.put("updatedTime", String.valueOf(updatedTime));
175186
map.put("schema", hasSchema ? schema : null);
176187
map.put("strategies", strategies.stream().map(IWorkflowStrategy::toMap).toList());
177188
return JSON.toJSONString(map);
@@ -189,6 +200,7 @@ public static Workflow formJson(String json) {
189200
workflow.setTitle((String) data.get("title"));
190201
workflow.setSchema((String) data.get("schema"));
191202
workflow.setCreatedTime(Long.parseLong((String) data.get("createdTime")));
203+
workflow.setUpdatedTime(Long.parseLong((String) data.get("updatedTime")));
192204
workflow.setCreatedOperator(GatewayContext.getInstance().getFlowOperator(createOperator));
193205
workflow.setForm(FormMeta.fromMap((Map<String, Object>) data.get("form")));
194206
workflow.setOperatorCreateScript(new OperatorMatchScript((String) data.get("operatorCreateScript")));
@@ -376,4 +388,7 @@ public boolean isNextNode(IFlowNode currentNode, IFlowNode nextNode) {
376388
return false;
377389
}
378390

391+
public void updateTime() {
392+
this.updatedTime = System.currentTimeMillis();
393+
}
379394
}

flow-engine-starter-api/src/main/java/com/codingapi/flow/api/controller/WorkflowController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public Response save(@RequestBody JSONObject request) {
4444
request.put("createdOperator", String.valueOf(current.getUserId()));
4545
}
4646
Workflow workflow = Workflow.formJson(request.toJSONString());
47+
workflow.updateTime();
4748
workflowRepository.save(workflow);
4849
return Response.buildSuccess();
4950
}

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/convert/WorkflowConvertor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static WorkflowEntity convert(Workflow workflow){
2626

2727
entity.setCreatedOperator(flowOperatorConvertor.convertToDatabaseColumn(workflow.getCreatedOperator()));
2828
entity.setCreatedTime(workflow.getCreatedTime());
29+
entity.setUpdatedTime(workflow.getUpdatedTime());
2930
entity.setForm(formMetaConvertor.convertToDatabaseColumn(workflow.getForm()));
3031
entity.setOperatorCreateScript(operatorMatchScriptConvertor.convertToDatabaseColumn(workflow.getOperatorCreateScript()));
3132
entity.setNodes(flowNodeListConvertor.convertToDatabaseColumn(workflow.getNodes()));
@@ -44,6 +45,7 @@ public static Workflow convert(WorkflowEntity entity){
4445
entity.getTitle(),
4546
flowOperatorConvertor.convertToEntityAttribute(entity.getCreatedOperator()),
4647
entity.getCreatedTime(),
48+
entity.getUpdatedTime(),
4749
formMetaConvertor.convertToEntityAttribute(entity.getForm()),
4850
operatorMatchScriptConvertor.convertToEntityAttribute(entity.getOperatorCreateScript()),
4951
flowNodeListConvertor.convertToEntityAttribute(entity.getNodes()),

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/entity/WorkflowEntity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public class WorkflowEntity {
3535
*/
3636
private Long createdTime;
3737

38+
39+
/**
40+
* 更新时间
41+
*/
42+
private Long updatedTime;
43+
3844
/**
3945
* 流程表单
4046
*/

frontend/packages/flow-design/src/pages/design-list/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const DesignList: React.FC<DesignListProps> = (props) => {
1717
hidden: true,
1818
},
1919
{
20-
dataIndex: 'code',
21-
title: '编码',
20+
dataIndex: 'title',
21+
title: '流程标题',
2222
},
2323
{
24-
dataIndex: 'title',
25-
title: '名称',
24+
dataIndex: 'code',
25+
title: '流程编码',
2626
},
2727
{
2828
dataIndex: 'createdTime',
@@ -31,6 +31,13 @@ export const DesignList: React.FC<DesignListProps> = (props) => {
3131
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
3232
}
3333
},
34+
{
35+
dataIndex: 'updatedTime',
36+
title: '更新时间',
37+
render: (value, record) => {
38+
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
39+
}
40+
},
3441
{
3542
dataIndex: 'option',
3643
title: '操作',

frontend/packages/flow-design/src/pages/design-panel/manager/workflow/form.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export class WorkflowFormManager {
5050

5151
public mergeValue(code: string, values: any):FlowForm {
5252
const currentFields = this.getFormFields(code);
53-
const currentCode = values['code'];
53+
const currentFieldCode = values['code'];
5454
const list:FormField[] = [];
5555
let exist = false;
5656
for (const field of currentFields) {
57-
if(field.code == currentCode) {
57+
if(field.code === currentFieldCode) {
5858
list.push(values);
5959
exist = true;
6060
}else {
@@ -65,15 +65,14 @@ export class WorkflowFormManager {
6565
list.push(values);
6666
}
6767
const mainCode = this.form.code;
68-
if(code==mainCode){
68+
if(code===mainCode){
6969
return {
7070
...this.form,
7171
fields:list,
7272
}
7373
}else {
7474
return {
7575
...this.form,
76-
fields:list,
7776
subForms:this.form.subForms.map(item=>{
7877
if(item.code===code){
7978
return {

frontend/packages/flow-design/src/pages/design-panel/presenters/index.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,56 @@ export class Presenter {
2626
this.state = state;
2727
}
2828

29+
private mergeWorkflow(prevWorkflow: any, currentWorkflow: any) {
30+
return {
31+
...prevWorkflow,
32+
...currentWorkflow,
33+
form: {
34+
...prevWorkflow.form,
35+
...currentWorkflow.form,
36+
}
37+
}
38+
}
39+
2940
public updateViewPanelTab(tab: TabPanelType) {
30-
const values = this.formActionContext.save();
41+
const values = this.formActionContext.save() as any;
3142
this.dispatch((prevState: State) => {
3243
return {
3344
...prevState,
3445
view: {
3546
...prevState.view,
3647
tabPanel: tab,
3748
},
49+
workflow: this.mergeWorkflow(prevState.workflow, values),
50+
}
51+
});
52+
}
53+
54+
private updateWorkflowForm(form: any) {
55+
this.dispatch((prevState: State) => {
56+
return {
57+
...prevState,
3858
workflow: {
3959
...prevState.workflow,
40-
...values,
4160
form: {
4261
...prevState.workflow.form,
43-
...values,
62+
...form,
4463
}
4564
}
4665
}
4766
});
4867
}
4968

69+
public updateWorkflow(data: any) {
70+
this.dispatch((prevState: State) => {
71+
return {
72+
...prevState,
73+
workflow: this.mergeWorkflow(prevState.workflow, data),
74+
}
75+
});
76+
}
77+
78+
5079
public removeWorkflowFormField(formCode: string, fieldCode: string) {
5180
const workflowFormManager = new WorkflowFormManager(this.state.workflow.form);
5281
const form = workflowFormManager.removeField(formCode, fieldCode);
@@ -65,17 +94,6 @@ export class Presenter {
6594
this.updateWorkflowForm(form);
6695
}
6796

68-
private updateWorkflowForm(form: any) {
69-
this.dispatch((prevState: State) => {
70-
return {
71-
...prevState,
72-
workflow: {
73-
...prevState.workflow,
74-
form
75-
}
76-
}
77-
});
78-
}
7997

8098
public updateWorkflowFormField(code: string, values: any) {
8199
const workflowFormManager = new WorkflowFormManager(this.state.workflow.form);
@@ -84,31 +102,16 @@ export class Presenter {
84102
}
85103

86104
public async save() {
87-
const values = this.formActionContext.save();
105+
const values = this.formActionContext.save() as any;
88106
this.updateWorkflow(values);
89107
const latest = {
90108
...this.state,
91-
workflow: {
92-
...this.state.workflow,
93-
...values
94-
}
109+
workflow: this.mergeWorkflow(this.state.workflow, values),
95110
};
96111
await this.api.save(latest.workflow);
97112
console.log('save latest:', latest);
98113
}
99114

100-
public updateWorkflow(data: any) {
101-
this.dispatch((prevState: State) => {
102-
return {
103-
...prevState,
104-
workflow: {
105-
...prevState.workflow,
106-
...data
107-
}
108-
}
109-
});
110-
}
111-
112115

113116
public initState() {
114117
this.dispatch(initStateData);

frontend/packages/flow-design/src/pages/design-panel/tabs/base.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ export const TabBase = ()=>{
4848
>
4949
<CardForm.Item
5050
name={"title"}
51-
label={"流程名称"}
51+
label={"流程标题"}
5252
rules={[
5353
{
5454
required: true,
55-
message: '请输入流程名称'
55+
message: '请输入流程标题'
5656
}
5757
]}
5858
>
59-
<Input placeholder={"请输入流程名称"}/>
59+
<Input placeholder={"请输入流程标题"}/>
6060
</CardForm.Item>
6161

6262

frontend/packages/flow-design/src/pages/design-panel/tabs/form.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ const FormFieldModal: React.FC<FormFieldModalProps> = (props) => {
5252
name={"name"}
5353
label={"字段名称"}
5454
labelCol={labelCol}
55+
rules={[
56+
{
57+
required: true,
58+
message: '字段名称不能为空'
59+
}
60+
]}
5561
>
5662
<Input placeholder={"请输入字段名称"}/>
5763
</Form.Item>
@@ -60,6 +66,12 @@ const FormFieldModal: React.FC<FormFieldModalProps> = (props) => {
6066
name={"code"}
6167
label={"字段编码"}
6268
labelCol={labelCol}
69+
rules={[
70+
{
71+
required: true,
72+
message: '字段编码不能为空'
73+
}
74+
]}
6375
>
6476
<Input placeholder={"请输入字段编码"}/>
6577
</Form.Item>
@@ -68,6 +80,12 @@ const FormFieldModal: React.FC<FormFieldModalProps> = (props) => {
6880
name={"type"}
6981
label={"字段类型"}
7082
labelCol={labelCol}
83+
rules={[
84+
{
85+
required: true,
86+
message: '字段类型不能为空'
87+
}
88+
]}
7189
>
7290
<Select
7391
placeholder={"请输入字段类型"}
@@ -177,7 +195,16 @@ const FormTable: React.FC<FormTableProps> = (props) => {
177195
},
178196
{
179197
dataIndex: 'type',
180-
title: '字段类型'
198+
title: '字段类型',
199+
render: (value, record) => {
200+
let label = '';
201+
for(const option of FormFieldOptions) {
202+
if(option.value == value){
203+
label = option.label;
204+
}
205+
}
206+
return label
207+
}
181208
},
182209
{
183210
dataIndex: 'required',

0 commit comments

Comments
 (0)