Skip to content

Commit 9314673

Browse files
committed
fix ui
1 parent afbd7ec commit 9314673

6 files changed

Lines changed: 55 additions & 31 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/form/FormFieldMeta.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.flow.form;
22

3+
import com.codingapi.flow.utils.RandomUtils;
34
import lombok.Data;
45

56
/**
@@ -8,6 +9,8 @@
89
@Data
910
public class FormFieldMeta {
1011

12+
// 字段编号
13+
private String id;
1114
// 字段名称
1215
private String name;
1316
// 字段编号
@@ -19,4 +22,8 @@ public class FormFieldMeta {
1922
// 默认值
2023
private String defaultValue;
2124

25+
public FormFieldMeta() {
26+
this.id = RandomUtils.generateStringId();
27+
}
28+
2229
}

flow-engine-framework/src/main/java/com/codingapi/flow/form/FormMeta.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public static FormMeta fromMap(Map<String, Object> map) {
7272
if(fields!=null && !fields.isEmpty()) {
7373
for (Map<String, Object> field : fields) {
7474
FormFieldMeta fieldMeta = new FormFieldMeta();
75+
fieldMeta.setId((String) field.get("id"));
7576
fieldMeta.setName((String) field.get("name"));
7677
fieldMeta.setCode((String) field.get("code"));
7778
fieldMeta.setType((String) field.get("type"));

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

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export class WorkflowFormManager {
1313

1414
private loadFormList(): void {
1515
this.formList.push(this.form);
16-
if(this.form.subForms && this.form.subForms.length>0) {
16+
if (this.form.subForms && this.form.subForms.length > 0) {
1717
for (const subForm of this.form.subForms) {
1818
this.formList.push(subForm);
1919
}
2020
}
2121
}
2222

23-
public getFormFields(code:string){
24-
let result:FormField[] = [];
23+
public getFormFields(code: string) {
24+
let result: FormField[] = [];
2525
for (const subForm of this.formList) {
2626
if (subForm.code == code) {
2727
result = subForm.fields || [];
@@ -30,56 +30,59 @@ export class WorkflowFormManager {
3030
return result;
3131
}
3232

33-
public removeSubForm(code:string){
33+
public removeSubForm(code: string) {
3434
const currentSubForms = this.form.subForms || [];
3535
const subForms = currentSubForms.filter(subForm => subForm.code !== code);
3636
return {
3737
...this.form,
38-
subForms:subForms
38+
subForms: subForms
3939
}
4040
}
4141

42-
public addSubForm(values:any){
42+
public addSubForm(values: any) {
4343
const subForms = [...this.form.subForms || []];
4444
subForms.push(values);
4545
return {
4646
...this.form,
47-
subForms:subForms
47+
subForms: subForms
4848
}
4949
}
5050

51-
public mergeValue(code: string, values: any):FlowForm {
51+
public updateFieldValue(code: string, values: any): FlowForm {
5252
const currentFields = this.getFormFields(code);
53-
const currentFieldCode = values['code'];
54-
const list:FormField[] = [];
53+
const currentFieldId = values['id'];
54+
const list: FormField[] = [];
5555
let exist = false;
5656
for (const field of currentFields) {
57-
if(field.code === currentFieldCode) {
57+
if (field.id === currentFieldId) {
5858
list.push(values);
5959
exist = true;
60-
}else {
60+
} else {
6161
list.push(field);
6262
}
6363
}
64-
if(!exist){
65-
list.push(values);
64+
if (!exist) {
65+
list.push({
66+
...values,
67+
id:crypto.randomUUID(),
68+
});
6669
}
6770
const mainCode = this.form.code;
68-
if(code===mainCode){
71+
if (code === mainCode) {
6972
return {
7073
...this.form,
71-
fields:list,
74+
fields: list,
7275
}
73-
}else {
76+
} else {
7477
return {
7578
...this.form,
76-
subForms:this.form.subForms.map(item=>{
77-
if(item.code===code){
79+
subForms: this.form.subForms.map(item => {
80+
if (item.code === code) {
7881
return {
7982
...item,
80-
fields:list
83+
fields: list
8184
}
82-
}else {
85+
} else {
8386
return item;
8487
}
8588
}),
@@ -92,22 +95,22 @@ export class WorkflowFormManager {
9295
const fields = [...currentFields];
9396
const list = fields.filter(file => file.code !== fieldCode);
9497
const mainCode = this.form.code;
95-
if(formCode==mainCode){
98+
if (formCode == mainCode) {
9699
return {
97100
...this.form,
98-
fields:list,
101+
fields: list,
99102
}
100-
}else {
103+
} else {
101104
return {
102105
...this.form,
103-
fields:list,
104-
subForms:this.form.subForms.map(item=>{
105-
if(item.code===formCode){
106+
fields: list,
107+
subForms: this.form.subForms.map(item => {
108+
if (item.code === formCode) {
106109
return {
107110
...item,
108-
fields:list
111+
fields: list
109112
}
110-
}else {
113+
} else {
111114
return item;
112115
}
113116
}),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class Presenter {
9797

9898
public updateWorkflowFormField(code: string, values: any) {
9999
const workflowFormManager = new WorkflowFormManager(this.state.workflow.form);
100-
const form = workflowFormManager.mergeValue(code, values);
100+
const form = workflowFormManager.updateFieldValue(code, values);
101101
this.updateWorkflowForm(form);
102102
}
103103

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ const FormFieldModal: React.FC<FormFieldModalProps> = (props) => {
4848
props.onClose?.();
4949
}}
5050
>
51+
<Form.Item
52+
name={"id"}
53+
hidden={true}
54+
>
55+
<Input/>
56+
</Form.Item>
57+
5158
<Form.Item
5259
name={"name"}
5360
label={"字段名称"}
@@ -185,6 +192,11 @@ const FormTable: React.FC<FormTableProps> = (props) => {
185192
const [editable, setEditable] = useState(false);
186193

187194
const columns: TableProps<any>['columns'] = [
195+
{
196+
dataIndex: 'id',
197+
title: 'id',
198+
hidden: true,
199+
},
188200
{
189201
dataIndex: 'name',
190202
title: '字段名称',
@@ -246,7 +258,7 @@ const FormTable: React.FC<FormTableProps> = (props) => {
246258
<>
247259
<Table
248260
columns={columns}
249-
rowKey={"code"}
261+
rowKey={"id"}
250262
dataSource={workflowFormManager.getFormFields(props.code)}
251263
title={() => {
252264
return (

frontend/packages/flow-design/src/pages/design-panel/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface DesignPanelProps {
3434

3535
// 表单字段
3636
export interface FormField{
37+
id:string;
3738
name: string;
3839
code: string;
3940
type: string;

0 commit comments

Comments
 (0)