reload 逻辑优化

This commit is contained in:
liaoxuezhi 2019-12-06 10:53:36 +08:00
parent e67a89f931
commit a66f993b77
2 changed files with 18 additions and 4 deletions

View File

@ -429,7 +429,6 @@ export function registerOptionsControl(config: OptionsConfig) {
const {source, formItem, data, onChange} = this.props;
if (
config.autoLoadOptionsFromSource === false ||
!formItem ||
!isEffectiveApi(source, data)
) {

View File

@ -134,9 +134,23 @@ export default class PickerControl extends React.PureComponent<
};
}
crud: any;
@autobind
crudRef(ref: any) {
while (ref && ref.getWrappedInstance) {
ref = ref.getWrappedInstance();
}
this.crud = ref;
}
reload() {
const reload = this.props.reloadOptions;
reload && reload();
if (this.crud) {
this.crud.search();
} else {
const reload = this.props.reloadOptions;
reload && reload();
}
}
@autobind
@ -341,7 +355,8 @@ export default class PickerControl extends React.PureComponent<
valueField,
options: options,
multiple,
onSelect: embed ? this.handleChange : undefined
onSelect: embed ? this.handleChange : undefined,
ref: this.crudRef
}) as JSX.Element;
}