mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:38:53 +08:00
dispatch参数修改
This commit is contained in:
parent
a76d34a414
commit
5d3b1da5d6
@ -89,13 +89,13 @@ export default class TagControl extends React.PureComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
async dispatchEvent(eventName: string, e: any = {}) {
|
async dispatchEvent(eventName: string, eventData: any = {}) {
|
||||||
const {dispatchEvent, options, data} = this.props;
|
const {dispatchEvent, options, data} = this.props;
|
||||||
const rendererEvent = await dispatchEvent(
|
const rendererEvent = await dispatchEvent(
|
||||||
eventName,
|
eventName,
|
||||||
createObject(e, {
|
createObject(data, {
|
||||||
options,
|
options,
|
||||||
...data
|
...eventData
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
// 返回阻塞标识
|
// 返回阻塞标识
|
||||||
|
@ -269,9 +269,11 @@ export default class MatrixCheckbox extends React.Component<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rendererEvent = await dispatchEvent('change', createObject({
|
const rendererEvent = await dispatchEvent('change',
|
||||||
value: value.concat(),
|
createObject(data, {
|
||||||
}, data));
|
value: value.concat(),
|
||||||
|
})
|
||||||
|
);
|
||||||
if (rendererEvent?.prevented) {
|
if (rendererEvent?.prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -458,11 +458,10 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|||||||
const {dispatchEvent, options, data} = this.props;
|
const {dispatchEvent, options, data} = this.props;
|
||||||
const rendererEvent = await dispatchEvent(
|
const rendererEvent = await dispatchEvent(
|
||||||
'change',
|
'change',
|
||||||
{
|
createObject(data, {
|
||||||
value: eventData,
|
value: eventData,
|
||||||
options,
|
options,
|
||||||
...data
|
})
|
||||||
}
|
|
||||||
);
|
);
|
||||||
// 返回阻塞标识
|
// 返回阻塞标识
|
||||||
return !!rendererEvent?.prevented;
|
return !!rendererEvent?.prevented;
|
||||||
|
@ -52,13 +52,12 @@ export default class RadiosControl extends React.Component<RadiosProps, any> {
|
|||||||
option = option[valueField || 'value'];
|
option = option[valueField || 'value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const rendererEvent = await dispatchEvent('change', createObject(
|
const rendererEvent = await dispatchEvent('change',
|
||||||
{
|
createObject(data, {
|
||||||
value: option,
|
value: option,
|
||||||
options,
|
options,
|
||||||
},
|
})
|
||||||
data
|
);
|
||||||
));
|
|
||||||
if (rendererEvent?.prevented) {
|
if (rendererEvent?.prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -151,21 +151,21 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|||||||
this.input && this.input.focus();
|
this.input && this.input.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
async dispatchEvent(eventName: SelectRendererEvent, e: any = {}) {
|
async dispatchEvent(eventName: SelectRendererEvent, eventData: any = {}) {
|
||||||
const event = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
|
const event = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
|
||||||
const {dispatchEvent, options, data} = this.props;
|
const {dispatchEvent, options, data} = this.props;
|
||||||
// 触发渲染器事件
|
// 触发渲染器事件
|
||||||
const rendererEvent = await dispatchEvent(
|
const rendererEvent = await dispatchEvent(
|
||||||
eventName,
|
eventName,
|
||||||
createObject(e, {
|
createObject(data, {
|
||||||
options,
|
options,
|
||||||
...data
|
...eventData
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (rendererEvent?.prevented) {
|
if (rendererEvent?.prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.props[event](e);
|
this.props[event](eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changeValue(value: Option | Array<Option> | string | void) {
|
async changeValue(value: Option | Array<Option> | string | void) {
|
||||||
@ -224,11 +224,13 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|||||||
// 不设置没法回显
|
// 不设置没法回显
|
||||||
additonalOptions.length && setOptions(options.concat(additonalOptions));
|
additonalOptions.length && setOptions(options.concat(additonalOptions));
|
||||||
|
|
||||||
const rendererEvent = await dispatchEvent('change', {
|
const rendererEvent = await dispatchEvent(
|
||||||
value: newValue,
|
'change',
|
||||||
options,
|
createObject(data, {
|
||||||
...data
|
value: newValue,
|
||||||
});
|
options,
|
||||||
|
})
|
||||||
|
);
|
||||||
if (rendererEvent?.prevented) {
|
if (rendererEvent?.prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user