mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
容器内可能直接放表单项的情况
This commit is contained in:
parent
f158aaac62
commit
f77921c6ff
@ -322,9 +322,16 @@ export default class Dialog extends React.Component<DialogProps> {
|
||||
store.setFormData(data);
|
||||
}
|
||||
|
||||
handleFormChange(data: any) {
|
||||
handleFormChange(data: any, name?: string) {
|
||||
const {store} = this.props;
|
||||
|
||||
// 如果 dialog 里面不放 form,而是直接放表单项就会进到这里来。
|
||||
if (typeof name === 'string') {
|
||||
data = {
|
||||
[name]: data
|
||||
};
|
||||
}
|
||||
|
||||
store.setFormData(data);
|
||||
}
|
||||
|
||||
|
@ -325,9 +325,15 @@ export default class Drawer extends React.Component<DrawerProps> {
|
||||
store.setFormData(data);
|
||||
}
|
||||
|
||||
handleFormChange(data: any) {
|
||||
handleFormChange(data: any, name?: string) {
|
||||
const {store} = this.props;
|
||||
|
||||
if (typeof name === 'string') {
|
||||
data = {
|
||||
[name]: data
|
||||
};
|
||||
}
|
||||
|
||||
store.setFormData(data);
|
||||
}
|
||||
|
||||
|
@ -192,6 +192,7 @@ export default class Page extends React.Component<PageProps> {
|
||||
// autobind 会让继承里面的 super 指向有问题,所以先这样!
|
||||
bulkBindFunctions<Page /*为毛 this 的类型自动识别不出来?*/>(this, [
|
||||
'handleAction',
|
||||
'handleChange',
|
||||
'handleQuery',
|
||||
'handleDialogConfirm',
|
||||
'handleDialogClose',
|
||||
@ -413,6 +414,22 @@ export default class Page extends React.Component<PageProps> {
|
||||
return value;
|
||||
}
|
||||
|
||||
handleChange(
|
||||
value: any,
|
||||
name: string,
|
||||
submit?: boolean,
|
||||
changePristine?: boolean
|
||||
) {
|
||||
const {store} = this.props;
|
||||
|
||||
// 注意 form 也有 onChange 会进来,但是传参会不一样,而且不应该处理。
|
||||
if (typeof name !== 'string' || !name) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.changeValue(name, value, changePristine);
|
||||
}
|
||||
|
||||
renderHeader() {
|
||||
const {
|
||||
title,
|
||||
@ -502,6 +519,7 @@ export default class Page extends React.Component<PageProps> {
|
||||
const subProps = {
|
||||
onAction: this.handleAction,
|
||||
onQuery: initApi ? this.handleQuery : undefined,
|
||||
onChange: this.handleChange,
|
||||
loading: store.loading
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user