Skip to content

Commit 8000b51

Browse files
committed
fix field
1 parent ce7f7d4 commit 8000b51

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

.umirc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
},
77
proxy: {
88
'/api/': {
9-
target: 'http://quark-admin.test',
9+
target: 'http://www.web.com',
1010
changeOrigin: true,
1111
pathRewrite: { '^/api': '/api' },
1212
},

mock/form.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export default {
3333
component: "when",
3434
items: [
3535
{
36-
condition: "<%=username == 'abc' %>",
36+
condition: "<%=(['love','tt'].indexOf(username) !=-1) %>",
3737
body: [
3838
{
3939
component: "text",
40-
body: "您输入的用户名超过100个字符了",
40+
body: "您输入的用户名中包含了${username}字符串",
4141
},
4242
]
4343
},
@@ -54,14 +54,7 @@ export default {
5454
}
5555
]
5656
}
57-
},
58-
{
59-
component: "passwordField",
60-
label: "密码",
61-
name: "password",
62-
displayWhen: "username === 'abcd'",
63-
style: {width: 200}
64-
},
57+
}
6558
]
6659
}
6760
}

src/components/Form/Field.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Geofence from './Geofence';
2929
import Editor from './Editor';
3030
import Cascader from './Cascader';
3131
import Render from '@/components/Render';
32+
import { tplEngine } from '@/utils/template';
3233

3334
const Field : React.FC<any> = (props:any) => {
3435

@@ -95,6 +96,7 @@ const Field : React.FC<any> = (props:any) => {
9596
addonAfter={props.addonAfter}
9697
addonBefore={props.addonBefore}
9798
size={props.size}
99+
onChange={(e)=>{onChange(e.target.value, props.name)}}
98100
/>
99101
</Form.Item>;
100102
break;
@@ -118,6 +120,7 @@ const Field : React.FC<any> = (props:any) => {
118120
onKeyPress={(e) => {
119121
e.stopPropagation();
120122
}}
123+
onChange={(e)=>{onChange(e.target.value, props.name)}}
121124
/>
122125
</Form.Item>;
123126
break;
@@ -141,6 +144,7 @@ const Field : React.FC<any> = (props:any) => {
141144
max={props.max}
142145
step={props.step}
143146
precision={props.precision}
147+
onChange={(value)=>{onChange(value,props.name)}}
144148
/>
145149
</Form.Item>;
146150
break;
@@ -191,6 +195,7 @@ const Field : React.FC<any> = (props:any) => {
191195
style={props.style ? props.style : []}
192196
options={props.options}
193197
disabled={props.disabled}
198+
onChange={(value)=>{onChange(value,props.name)}}
194199
/>
195200
</Form.Item>;
196201
break;
@@ -208,6 +213,7 @@ const Field : React.FC<any> = (props:any) => {
208213
style={props.style ? props.style : []}
209214
options={props.options}
210215
disabled={props.disabled}
216+
onChange={(e)=>{onChange(e.target.value,props.name)}}
211217
/>
212218
</Form.Item>;
213219
break;
@@ -271,6 +277,7 @@ const Field : React.FC<any> = (props:any) => {
271277
disabled={props.disabled}
272278
checkedChildren={props.options.on}
273279
unCheckedChildren={props.options.off}
280+
onChange={(value)=>{onChange(value,props.name)}}
274281
/>
275282
</Form.Item>;
276283
break;
@@ -516,7 +523,9 @@ const Field : React.FC<any> = (props:any) => {
516523

517524
// 解析when
518525
if(props.when) {
519-
return <>{component}<Render body={props.when} data={window[props.data.formKey]?.getFieldsValue()} callback={props.callback} /></>;
526+
let fieldData:any = {};
527+
fieldData[props.name] = window[props.data.formKey]?.getFieldValue(props.name);
528+
return <>{component}<Render body={props.when} data={fieldData} callback={props.callback} /></>;
520529
} else {
521530
return component;
522531
}

0 commit comments

Comments
 (0)