diff --git a/src/components/search/DataTypeSelect.jsx b/src/components/search/DataTypeSelect.jsx index 9d30117..ec991f3 100644 --- a/src/components/search/DataTypeSelect.jsx +++ b/src/components/search/DataTypeSelect.jsx @@ -35,7 +35,7 @@ class DataTypeSelect extends Component { {...extProps} > {dateTypes.map((ele) => ( - + {ele.label} ))} diff --git a/src/components/search/Input.jsx b/src/components/search/Input.jsx index d821b7c..f56a746 100644 --- a/src/components/search/Input.jsx +++ b/src/components/search/Input.jsx @@ -91,7 +91,7 @@ class SearchInput extends React.Component { // const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {}); const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: typeof map[v] === 'string' ? { key: map[v] } : (map[v] || []).map(vi => ({ key: vi})) }), {}); - if (value || !isEmpty(param)) { + if ((value && this.state.data.length === 0) || !isEmpty(param)) { curl({ value, url: this.props.url || '', map: mapKey, resultkey, param }, (data) => this.setState({ data }, () => (typeof this.props.onSearchAfter === 'function' ? this.props.onSearchAfter(data, this.state.value) : '')) ); @@ -104,6 +104,10 @@ class SearchInput extends React.Component { this.setState({ value }, () => this.props.onChange(value, option)); }; + handleFilter = (value, option) => { + return String(option?.children || option?.label || option?.value || '').toLowerCase().includes(value.toLowerCase()); + }; + render() { const options = this.state.data.map(d => ); const { onSearchAfter, defaultOptions, autoGet, dependenciesFun, ...props } = this.props; @@ -117,7 +121,7 @@ class SearchInput extends React.Component { placeholder={this.props.placeholder} defaultActiveFirstOption={false} showArrow={false} - filterOption={false} + filterOption={this.handleFilter} onSearch={this.handleSearch} onChange={this.handleChange} onFocus={() => this.handleSearch('')} diff --git a/src/components/search/SearchForm.jsx b/src/components/search/SearchForm.jsx index e03074c..ccd4d02 100644 --- a/src/components/search/SearchForm.jsx +++ b/src/components/search/SearchForm.jsx @@ -378,7 +378,7 @@ function getFields(props) { 'DateType', 99, - + , fieldProps?.DateType?.col || 3 ),