Skip to content

Commit

Permalink
fix(@uform/core): fix submit catch error (#603)
Browse files Browse the repository at this point in the history
* fix(@uform/core): fix submit catch error

* fix(@uform/core): fix ci

* fix(@uform/core): fix ci
  • Loading branch information
janryWang authored Jan 11, 2020
1 parent a2cf1c7 commit 406f9fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 98 deletions.
91 changes: 0 additions & 91 deletions docs/Examples/antd/Layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,97 +272,6 @@ ReactDOM.render(<App />, document.getElementById('root'))

## 分步表单

```jsx
import {
SchemaForm,
SchemaMarkupField as Field,
FormButtonGroup,
Submit,
FormEffectHooks,
createFormActions,
FormGridRow,
FormItemGrid,
FormGridCol,
FormPath,
FormLayout,
FormBlock,
FormCard,
FormTextBox,
FormStep
} from '@uform/antd'
import { Button } from 'antd'
import 'antd/dist/antd.css'

const { onFormInit$ } = FormEffectHooks

const actions = createFormActions()

let cache = {}

export default () => (
<SchemaForm
onSubmit={values => {
console.log('提交')
console.log(values)
}}
actions={actions}
labelCol={{ span: 8 }}
wrapperCol={{ span: 6 }}
validateFirst
effects={({ setFieldState, getFormGraph }) => {
onFormInit$().subscribe(() => {
setFieldState('col1', state => {
state.visible = false
})
})
}}
>
<FormStep
style={{ marginBottom: 20 }}
dataSource={[
{ title: '基本信息', name: 'step-1' },
{ title: '财务信息', name: 'step-2' },
{ title: '条款信息', name: 'step-3' }
]}
/>
<FormCard name="step-1" title="基本信息">
<Field name="a1" required title="A1" type="string" />
</FormCard>
<FormCard name="step-2" title="财务信息">
<Field name="a2" required title="A2" type="string" />
</FormCard>
<FormCard name="step-3" title="条款信息">
<Field name="a3" required title="A3" type="string" />
</FormCard>
<FormButtonGroup>
<Submit>提交</Submit>
<Button onClick={() => actions.dispatch(FormStep.ON_FORM_STEP_PREVIOUS)}>
上一步
</Button>
<Button onClick={() => actions.dispatch(FormStep.ON_FORM_STEP_NEXT)}>
下一步
</Button>
<Button
onClick={() => {
cache = actions.getFormGraph()
}}
>
存储当前状态
</Button>
<Button
onClick={() => {
actions.setFormGraph(cache)
}}
>
回滚状态
</Button>
</FormButtonGroup>
</SchemaForm>
)
```

## FormStep

> 分步表单,主要用于大量表单填写,需要区分步骤的场景,使用FormStep和FormSpy
#### Demo 示例
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,9 @@ export function createForm<FieldProps, VirtualFieldProps>(
try {
payload = await Promise.resolve(onSubmit(values))
} catch (e) {
if (e) {
console.error(e)
}
new Promise(() => {
throw e
})
}
}

Expand Down
9 changes: 5 additions & 4 deletions packages/react-schema-renderer/src/shared/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ const bindEffects = (
(event, key) => {
const prevEvent = key === 'onChange' ? props[key] : undefined
props[key] = (...args: any[]) => {
if (isFn(prevEvent)) {
prevEvent(...args)
}
if (isFn(event)) {
return event(...args)
event(...args)
}
if (isFn(prevEvent)) {
return prevEvent(...args)
}

}
}
)
Expand Down

0 comments on commit 406f9fb

Please sign in to comment.