From 8000b51428e69e5542467b7dbe568b4f577a7fe1 Mon Sep 17 00:00:00 2001 From: quarkcms <869716224@qq.com> Date: Fri, 23 Jul 2021 17:00:45 +0800 Subject: [PATCH] fix field --- .umirc.ts | 2 +- mock/form.ts | 13 +++---------- src/components/Form/Field.tsx | 11 ++++++++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.umirc.ts b/.umirc.ts index 3a55bc0..9f1d4c3 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -6,7 +6,7 @@ export default defineConfig({ }, proxy: { '/api/': { - target: 'http://quark-admin.test', + target: 'http://www.web.com', changeOrigin: true, pathRewrite: { '^/api': '/api' }, }, diff --git a/mock/form.ts b/mock/form.ts index ff2bd3c..7c95114 100644 --- a/mock/form.ts +++ b/mock/form.ts @@ -33,11 +33,11 @@ export default { component: "when", items: [ { - condition: "<%=username == 'abc' %>", + condition: "<%=(['love','tt'].indexOf(username) !=-1) %>", body: [ { component: "text", - body: "您输入的用户名超过100个字符了", + body: "您输入的用户名中包含了${username}字符串", }, ] }, @@ -54,14 +54,7 @@ export default { } ] } - }, - { - component: "passwordField", - label: "密码", - name: "password", - displayWhen: "username === 'abcd'", - style: {width: 200} - }, + } ] } } diff --git a/src/components/Form/Field.tsx b/src/components/Form/Field.tsx index 0f14f96..327299b 100644 --- a/src/components/Form/Field.tsx +++ b/src/components/Form/Field.tsx @@ -29,6 +29,7 @@ import Geofence from './Geofence'; import Editor from './Editor'; import Cascader from './Cascader'; import Render from '@/components/Render'; +import { tplEngine } from '@/utils/template'; const Field : React.FC = (props:any) => { @@ -95,6 +96,7 @@ const Field : React.FC = (props:any) => { addonAfter={props.addonAfter} addonBefore={props.addonBefore} size={props.size} + onChange={(e)=>{onChange(e.target.value, props.name)}} /> ; break; @@ -118,6 +120,7 @@ const Field : React.FC = (props:any) => { onKeyPress={(e) => { e.stopPropagation(); }} + onChange={(e)=>{onChange(e.target.value, props.name)}} /> ; break; @@ -141,6 +144,7 @@ const Field : React.FC = (props:any) => { max={props.max} step={props.step} precision={props.precision} + onChange={(value)=>{onChange(value,props.name)}} /> ; break; @@ -191,6 +195,7 @@ const Field : React.FC = (props:any) => { style={props.style ? props.style : []} options={props.options} disabled={props.disabled} + onChange={(value)=>{onChange(value,props.name)}} /> ; break; @@ -208,6 +213,7 @@ const Field : React.FC = (props:any) => { style={props.style ? props.style : []} options={props.options} disabled={props.disabled} + onChange={(e)=>{onChange(e.target.value,props.name)}} /> ; break; @@ -271,6 +277,7 @@ const Field : React.FC = (props:any) => { disabled={props.disabled} checkedChildren={props.options.on} unCheckedChildren={props.options.off} + onChange={(value)=>{onChange(value,props.name)}} /> ; break; @@ -516,7 +523,9 @@ const Field : React.FC = (props:any) => { // 解析when if(props.when) { - return <>{component}; + let fieldData:any = {}; + fieldData[props.name] = window[props.data.formKey]?.getFieldValue(props.name); + return <>{component}; } else { return component; }