dispatch参数修改

This commit is contained in:
xujiahao01 2022-02-15 17:36:10 +08:00
parent a76d34a414
commit 5d3b1da5d6
5 changed files with 25 additions and 23 deletions

View File

@ -89,13 +89,13 @@ export default class TagControl extends React.PureComponent<
}
@autobind
async dispatchEvent(eventName: string, e: any = {}) {
async dispatchEvent(eventName: string, eventData: any = {}) {
const {dispatchEvent, options, data} = this.props;
const rendererEvent = await dispatchEvent(
eventName,
createObject(e, {
createObject(data, {
options,
...data
...eventData
})
);
// 返回阻塞标识

View File

@ -269,9 +269,11 @@ export default class MatrixCheckbox extends React.Component<
}
}
const rendererEvent = await dispatchEvent('change', createObject({
value: value.concat(),
}, data));
const rendererEvent = await dispatchEvent('change',
createObject(data, {
value: value.concat(),
})
);
if (rendererEvent?.prevented) {
return;
}

View File

@ -458,11 +458,10 @@ export function registerOptionsControl(config: OptionsConfig) {
const {dispatchEvent, options, data} = this.props;
const rendererEvent = await dispatchEvent(
'change',
{
createObject(data, {
value: eventData,
options,
...data
}
})
);
// 返回阻塞标识
return !!rendererEvent?.prevented;

View File

@ -52,13 +52,12 @@ export default class RadiosControl extends React.Component<RadiosProps, any> {
option = option[valueField || 'value'];
}
const rendererEvent = await dispatchEvent('change', createObject(
{
const rendererEvent = await dispatchEvent('change',
createObject(data, {
value: option,
options,
},
data
));
})
);
if (rendererEvent?.prevented) {
return;
}

View File

@ -151,21 +151,21 @@ export default class SelectControl extends React.Component<SelectProps, any> {
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 {dispatchEvent, options, data} = this.props;
// 触发渲染器事件
const rendererEvent = await dispatchEvent(
eventName,
createObject(e, {
createObject(data, {
options,
...data
...eventData
})
);
if (rendererEvent?.prevented) {
return;
}
this.props[event](e);
this.props[event](eventData);
}
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));
const rendererEvent = await dispatchEvent('change', {
value: newValue,
options,
...data
});
const rendererEvent = await dispatchEvent(
'change',
createObject(data, {
value: newValue,
options,
})
);
if (rendererEvent?.prevented) {
return;
}