|
|
@ -63,7 +63,8 @@ class SearchInput extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
|
if (this.props.autoGet === true) {
|
|
|
|
if (this.props.autoGet === true) {
|
|
|
|
const { map, resultkey, param } = this.props;
|
|
|
|
const { map, resultkey, dependenciesFun } = this.props;
|
|
|
|
|
|
|
|
const param = typeof dependenciesFun === 'function' ? dependenciesFun() : {};
|
|
|
|
const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {});
|
|
|
|
const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {});
|
|
|
|
curl({ value: '', url: this.props.url || '', map: mapKey, resultkey, param }, (data) =>
|
|
|
|
curl({ value: '', url: this.props.url || '', map: mapKey, resultkey, param }, (data) =>
|
|
|
|
this.setState({ data, autoData: data }, () => (typeof this.props.onSearchAfter === 'function' ? this.props.onSearchAfter(data, this.state.value) : ''))
|
|
|
|
this.setState({ data, autoData: data }, () => (typeof this.props.onSearchAfter === 'function' ? this.props.onSearchAfter(data, this.state.value) : ''))
|
|
|
@ -87,7 +88,8 @@ class SearchInput extends React.Component {
|
|
|
|
this.setState({ data: f || [] });
|
|
|
|
this.setState({ data: f || [] });
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { map, resultkey, param } = this.props;
|
|
|
|
const { map, resultkey, dependenciesFun } = this.props;
|
|
|
|
|
|
|
|
const param = typeof dependenciesFun === 'function' ? dependenciesFun() : {};
|
|
|
|
const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {});
|
|
|
|
const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {});
|
|
|
|
if (value) {
|
|
|
|
if (value) {
|
|
|
|
curl({ value, url: this.props.url || '', map: mapKey, resultkey, param }, (data) =>
|
|
|
|
curl({ value, url: this.props.url || '', map: mapKey, resultkey, param }, (data) =>
|
|
|
@ -99,13 +101,12 @@ class SearchInput extends React.Component {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
handleChange = (value, option) => {
|
|
|
|
handleChange = (value, option) => {
|
|
|
|
// console.log('invoke denpendencies change', value);
|
|
|
|
|
|
|
|
this.setState({ value }, () => this.props.onChange(value, option));
|
|
|
|
this.setState({ value }, () => this.props.onChange(value, option));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const options = this.state.data.map(d => <Option key={d.key} extradata={d.options}>{d.label}</Option>);
|
|
|
|
const options = this.state.data.map(d => <Option key={d.key} extradata={d.options}>{d.label}</Option>);
|
|
|
|
const { onSearchAfter, defaultOptions, autoGet, ...props } = this.props;
|
|
|
|
const { onSearchAfter, defaultOptions, autoGet, dependenciesFun, ...props } = this.props;
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
<Select
|
|
|
|
{...props}
|
|
|
|
{...props}
|
|
|
|