Skip to content

Commit 50e7421

Browse files
committed
update version
1 parent 498cadb commit 50e7421

13 files changed

Lines changed: 79 additions & 27 deletions

File tree

apps/app-mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@form-example/app-mobile",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"private": true,
55
"type": "module",
66
"scripts": {

apps/app-pc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@form-example/app-pc",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"private": true,
55
"type": "module",
66
"scripts": {

apps/app-pc/src/pages/home.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const HomePage = () => {
4848
<FormView
4949
meta={meta}
5050
form={form}
51+
onFinish={(values, formCode)=>{
52+
console.log(values, formCode);
53+
}}
5154
validators={[
5255
{
5356
target:'name',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-form/root",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

packages/form-engine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-form/form-engine",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "form-engine components",
55
"keywords": [
66
"coding-flow",

packages/form-engine/src/form/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,30 @@ export const FormViewContent: React.FC<FormViewContentProps> = (props) => {
2828

2929
const review = props.review || false;
3030

31+
const handleOnSubmit = (values:any,formCode:string) => {
32+
props.onFinish?.(values,formCode);
33+
}
34+
3135
return (
3236
<FormContext.Provider value={context}>
37+
{props.header}
3338
<FormSubView
3439
Form={Form}
3540
formCode={meta.code}
3641
review={review}
42+
onFinish={handleOnSubmit}
3743
/>
3844
{subFormList && subFormList.map(item=>{
3945
return (
4046
<FormSubView
4147
Form={Form}
4248
formCode={item.code}
4349
review={review}
50+
onFinish={handleOnSubmit}
4451
/>
4552
)
4653
})}
54+
{props.footer}
4755
</FormContext.Provider>
4856
)
4957
}

packages/form-engine/src/form/sub-view.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface FormSubViewProps {
55
formCode: string;
66
Form: React.ComponentType<any>;
77
review: boolean;
8+
onFinish: (values:any,formCode:string) => void;
89
}
910

1011
export const FormSubView: React.FC<FormSubViewProps> = (props) => {
@@ -50,6 +51,9 @@ export const FormSubView: React.FC<FormSubViewProps> = (props) => {
5051
return (
5152
<Form
5253
form={formTarget}
54+
onFinish={(values:any)=>{
55+
props.onFinish(values,props.formCode);
56+
}}
5357
>
5458
{layoutContext.render(props.formCode, fields, review, context)}
5559
</Form>

packages/form-engine/src/instance/control.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { NamePath } from "@/types";
2+
13
export class FormControl {
24

35
// 控制对象的表单编码
@@ -19,31 +21,31 @@ export class FormControl {
1921
return this.proxyTarget;
2022
}
2123

22-
public getFieldValue(name: string) {
24+
public getFieldValue(name: NamePath) {
2325
return this.proxyTarget.getFieldValue(name);
2426
}
2527

2628
public getFieldsValue() {
2729
return this.proxyTarget.getFieldsValue();
2830
}
2931

30-
public resetFields(nameList?: string[]) {
32+
public resetFields(nameList?: NamePath[]|NamePath) {
3133
this.proxyTarget.resetFields(nameList);
3234
}
3335

3436
public setFieldsValue(values: any) {
3537
this.proxyTarget.setFieldsValue(values);
3638
}
3739

38-
public setFieldValue(name: string, value: any) {
40+
public setFieldValue(name: NamePath, value: any) {
3941
this.proxyTarget.setFieldValue(name, value);
4042
}
4143

4244
public submit() {
4345
this.proxyTarget.submit();
4446
}
4547

46-
public validateFields(nameList?: string[]) {
48+
public validateFields(nameList?: NamePath[]|NamePath) {
4749
return new Promise<any>((resolve, reject) => {
4850
this.proxyTarget
4951
.validateFields(nameList)

packages/form-engine/src/instance/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {FormMeta} from "@/types";
1+
import {FormInstanceInterface, FormMeta, NamePath} from "@/types";
22
import {FormRegistry} from "@/register";
33
import {FormControl} from "./control";
44
import {FormPresenter} from "@/presenters";
55

6-
export class FormInstance {
6+
export class FormInstance implements FormInstanceInterface {
77

88
private readonly instanceList: FormControl[];
99

1010
private readonly meta: FormMeta;
1111

12-
private presenter: FormPresenter|undefined;
12+
private presenter: FormPresenter | undefined;
1313

1414
constructor(meta: FormMeta) {
1515
this.meta = meta;
@@ -67,31 +67,31 @@ export class FormInstance {
6767
return this.getFormControl(formCode)?.getProxyTarget();
6868
}
6969

70-
public getFieldValue(name: string, formCode?: string) {
70+
public getFieldValue(name: NamePath, formCode?: string) {
7171
this.getFormControl(formCode)?.getFieldValue(name);
7272
}
7373

7474
public getFieldsValue(formCode?: string) {
7575
return this.getFormControl(formCode)?.getFieldsValue();
7676
}
7777

78-
public resetFields(nameList?: string[], formCode?: string) {
78+
public resetFields(nameList?: NamePath[] | NamePath, formCode?: string) {
7979
this.getFormControl(formCode)?.resetFields(nameList);
8080
}
8181

8282
public setFieldsValue(values: any, formCode?: string) {
8383
this.getFormControl(formCode)?.setFieldsValue(values);
8484
}
8585

86-
public setFieldValue(name: string, value: any, formCode?: string) {
86+
public setFieldValue(name: NamePath, value: any, formCode?: string) {
8787
this.getFormControl(formCode)?.setFieldValue(name, value);
8888
}
8989

9090
public submit(formCode?: string) {
9191
this.getFormControl(formCode)?.submit();
9292
}
9393

94-
public validateFields(nameList?: string[], formCode?: string) {
94+
public validateFields(nameList?: NamePath[] | NamePath, formCode?: string) {
9595
const formControl = this.getFormControl(formCode);
9696
if (formControl) {
9797
return formControl.validateFields(nameList);
@@ -103,15 +103,15 @@ export class FormInstance {
103103
});
104104
}
105105

106-
public hiddenFields(hidden: boolean, nameList: string[]|string, formCode?: string) {
106+
public hiddenFields(hidden: boolean, nameList: NamePath[] | NamePath, formCode?: string) {
107107
this.presenter?.hiddenFields(hidden, nameList, formCode);
108108
}
109109

110-
public requiredFields(required: boolean, nameList: string[]|string, formCode?: string) {
110+
public requiredFields(required: boolean, nameList: NamePath[] | NamePath, formCode?: string) {
111111
this.presenter?.requiredFields(required, nameList, formCode);
112112
}
113113

114-
public refreshFields(nameList: string[]|string, formCode?: string) {
114+
public refreshFields(nameList: NamePath[] | NamePath, formCode?: string) {
115115
this.presenter?.refreshFields(nameList, formCode);
116116
}
117117

packages/form-engine/src/presenters/form-presenter.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Dispatch, FormMeta, FormState, StateField} from "@/types";
1+
import {Dispatch, FormMeta, FormState, NamePath, StateField} from "@/types";
22

33
export class FormPresenter {
44
private state: FormState;
@@ -19,7 +19,7 @@ export class FormPresenter {
1919
}
2020

2121

22-
public hiddenFields(hidden: boolean, nameList: string[]|string, formCode?: string) {
22+
public hiddenFields(hidden: boolean, nameList: NamePath[]|NamePath, formCode?: string) {
2323
this.dispatch(prevState => {
2424
const subFormList = prevState.subForms || [];
2525
return {
@@ -52,7 +52,7 @@ export class FormPresenter {
5252
}
5353

5454

55-
public refreshFields(nameList: string[]|string, formCode?: string){
55+
public refreshFields(nameList: NamePath[]|NamePath, formCode?: string){
5656
this.dispatch(prevState => {
5757
const subFormList = prevState.subForms || [];
5858
return {
@@ -84,7 +84,7 @@ export class FormPresenter {
8484
})
8585
}
8686

87-
public requiredFields(required: boolean, nameList: string[]|string, formCode?: string) {
87+
public requiredFields(required: boolean, nameList: NamePath[]|NamePath, formCode?: string) {
8888
this.dispatch(prevState => {
8989
const subFormList = prevState.subForms || [];
9090
return {
@@ -117,7 +117,7 @@ export class FormPresenter {
117117
}
118118

119119

120-
private hiddenMapFields(hidden: boolean,field:StateField,nameList: string[]|string) {
120+
private hiddenMapFields(hidden: boolean,field:StateField,nameList: NamePath[]|NamePath) {
121121
if(typeof nameList === 'string'){
122122
if(field.code ===nameList){
123123
return {
@@ -137,7 +137,7 @@ export class FormPresenter {
137137
}
138138

139139

140-
private refreshMapFields(field:StateField,nameList: string[]|string) {
140+
private refreshMapFields(field:StateField,nameList: NamePath[]|NamePath) {
141141
if(typeof nameList === 'string'){
142142
if(field.code ===nameList){
143143
const version = field.version?field.version:0;
@@ -158,7 +158,7 @@ export class FormPresenter {
158158
return field;
159159
}
160160

161-
private requiredMapFields(required: boolean,field:StateField,nameList: string[]|string) {
161+
private requiredMapFields(required: boolean,field:StateField,nameList: NamePath[]|NamePath) {
162162
if(typeof nameList === 'string'){
163163
if(field.code ===nameList){
164164
return {

0 commit comments

Comments
 (0)