mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
feat: 向导、评分 文档修改
This commit is contained in:
parent
2c4337a052
commit
07b29aa58d
@ -159,3 +159,16 @@ order: 37
|
||||
| className | `string` | - | 自定义样式类名 |
|
||||
| charClassName | `string` | - | 自定义字符类名 |
|
||||
| textClassName | `string` | - | 自定义文字类名 |
|
||||
|
||||
## 事件表
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
|----------------|------------------------|----------------------|
|
||||
| change | `value: number` | 数值变化 |
|
||||
|
||||
## 动作表
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
|----------------|-------------------------|---------------------|
|
||||
| clear | - | 清空 |
|
||||
| reset | `resetValue: number` | 重置 |
|
@ -93,3 +93,27 @@ order: 73
|
||||
| initFetch | `boolean` | | 当前步骤数据初始化接口是否初始拉取。 |
|
||||
| initFetchOn | [表达式](../../docs/concepts/expression) | | 当前步骤数据初始化接口是否初始拉取,用表达式来决定。 |
|
||||
| body | Array<[FormItem](./form/formItem)> | | 当前步骤的表单项集合,请参考 [FormItem](./form/formItem)。 |
|
||||
|
||||
|
||||
## 事件表
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
|-------------------|--------------------------------|----------------------|
|
||||
| inited | `data: object` | 初始化完成 |
|
||||
| finished | `data: object` | 点击完成 |
|
||||
| stepChange | `step: number, data: object` | 步骤切换 |
|
||||
| change | `data: object` | 数值变化 |
|
||||
| submitSucc | `data: object` | 提交成功 |
|
||||
| submitFail | `error: object` | 提交失败 |
|
||||
| stepSubmitSucc | `data: object` | 步骤提交成功 |
|
||||
| stepSubmitFail | `error: object` | 步骤提交失败 |
|
||||
|
||||
## 动作表
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
|-------------------|-------------------------|------------------------|
|
||||
| submit | - | 全部提交 |
|
||||
| step-submit | - | 分步提交 |
|
||||
| next | - | 下一步 |
|
||||
| prev | - | 上一步 |
|
||||
| goto-step | - | 定位步骤 |
|
@ -340,14 +340,14 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
async dispatchEvent(action: string, value?: object) {
|
||||
const {dispatchEvent, data} = this.props;
|
||||
|
||||
const rendererEvent = await dispatchEvent(action, createObject(data, value ? {value} : {}));
|
||||
const rendererEvent = await dispatchEvent(action, createObject(data, value ? value : {}));
|
||||
|
||||
return rendererEvent?.prevented ?? false;
|
||||
}
|
||||
|
||||
async handleInitEvent(data: any) {
|
||||
const {onInit} = this.props;
|
||||
(await this.dispatchEvent('inited', data)) && onInit && onInit(data);
|
||||
(await this.dispatchEvent('inited', {data})) && onInit && onInit(data);
|
||||
}
|
||||
|
||||
@autobind
|
||||
@ -383,7 +383,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
index = Math.max(Math.min(steps.length, index), 1);
|
||||
|
||||
if (index != this.state.currentStep) {
|
||||
if (await this.dispatchEvent('stepChange')) {
|
||||
if (await this.dispatchEvent('stepChange', {step: index, data: this.props.store.data})) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
const previous = store.data;
|
||||
const final = {...previous, ...values};
|
||||
|
||||
if (await this.dispatchEvent('change', final)) {
|
||||
if (await this.dispatchEvent('change', {data: final})) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -678,7 +678,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
onFinished
|
||||
} = this.props;
|
||||
|
||||
if (await this.dispatchEvent('finished', store.data)) {
|
||||
if (await this.dispatchEvent('finished', {data: store.data})) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -706,7 +706,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
formStore
|
||||
.saveRemote(action.api || step.api || api!, store.data, {
|
||||
onSuccess: () => {
|
||||
this.dispatchEvent('submitSucc', store.data);
|
||||
this.dispatchEvent('submitSucc', {data: store.data});
|
||||
|
||||
if (
|
||||
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
||||
@ -721,7 +721,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
cancel => (this.asyncCancel = cancel)
|
||||
);
|
||||
},
|
||||
onFailed: json => this.dispatchEvent('submitFail', json)
|
||||
onFailed: error => this.dispatchEvent('submitFail', {error})
|
||||
})
|
||||
.then(async value => {
|
||||
const feedback = action.feedback;
|
||||
@ -766,7 +766,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
return value;
|
||||
})
|
||||
.catch(error => {
|
||||
this.dispatchEvent('submitFail', error)
|
||||
this.dispatchEvent('submitFail', {error})
|
||||
store.markSaving(false);
|
||||
console.error(error);
|
||||
});
|
||||
@ -801,7 +801,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
store
|
||||
.saveRemote(action.api || step.api!, store.data, {
|
||||
onSuccess: () => {
|
||||
this.dispatchEvent('stepSubmitSucc', store.data);
|
||||
this.dispatchEvent('stepSubmitSucc', {data: store.data});
|
||||
|
||||
if (
|
||||
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
||||
@ -817,7 +817,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
);
|
||||
},
|
||||
onFailed: json => {
|
||||
this.dispatchEvent('stepSubmitFail', json);
|
||||
this.dispatchEvent('stepSubmitFail', {error: json});
|
||||
if (json.status === 422 && json.errors && this.form) {
|
||||
this.form.props.store.setFormItemErrors(json.errors);
|
||||
}
|
||||
@ -843,7 +843,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
||||
);
|
||||
})
|
||||
.catch(reason => {
|
||||
this.dispatchEvent('stepSubmitFail', reason);
|
||||
this.dispatchEvent('stepSubmitFail', {error: reason});
|
||||
if (reason instanceof SkipOperation) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user