forked from p96170835/amis
Select autoComplet 支持配置 sendOn
This commit is contained in:
parent
f72b7f9ffc
commit
d497256005
|
@ -141,31 +141,29 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
||||||
options: combinedOptions
|
options: combinedOptions
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const ctx = createObject(data, {
|
||||||
|
term: input,
|
||||||
|
value: input
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isEffectiveApi(autoComplete, ctx)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
return (
|
return env
|
||||||
isEffectiveApi(autoComplete, data) &&
|
.fetcher(autoComplete, ctx)
|
||||||
env
|
.then(ret => {
|
||||||
.fetcher(
|
let options = (ret.data && (ret.data as any).options) || ret.data || [];
|
||||||
autoComplete,
|
this.cache[input] = options;
|
||||||
createObject(data, {
|
let combinedOptions = this.mergeOptions(options);
|
||||||
term: input,
|
setOptions(combinedOptions);
|
||||||
value: input
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.then(ret => {
|
|
||||||
let options =
|
|
||||||
(ret.data && (ret.data as any).options) || ret.data || [];
|
|
||||||
this.cache[input] = options;
|
|
||||||
let combinedOptions = this.mergeOptions(options);
|
|
||||||
setOptions(combinedOptions);
|
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
options: combinedOptions
|
options: combinedOptions
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => setLoading(false))
|
.finally(() => setLoading(false));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeOptions(options: Array<object>) {
|
mergeOptions(options: Array<object>) {
|
||||||
|
|
Loading…
Reference in New Issue