fix: search input label filter

feature/pivot
Lei OT 2 years ago
parent 51ae4c9cea
commit 9593e62573

@ -35,7 +35,7 @@ class DataTypeSelect extends Component {
{...extProps} {...extProps}
> >
{dateTypes.map((ele) => ( {dateTypes.map((ele) => (
<Select.Option key={ele.key} value={ele.key} disabled={extProps.disabledKeys.includes(ele.key)}> <Select.Option key={ele.key} value={ele.key} disabled={extProps.disabledkeys.includes(ele.key)}>
{ele.label} {ele.label}
</Select.Option> </Select.Option>
))} ))}

@ -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]: { 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})) }), {}); 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) => 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) : '')) 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)); this.setState({ value }, () => this.props.onChange(value, option));
}; };
handleFilter = (value, option) => {
return String(option?.children || option?.label || option?.value || '').toLowerCase().includes(value.toLowerCase());
};
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, dependenciesFun, ...props } = this.props; const { onSearchAfter, defaultOptions, autoGet, dependenciesFun, ...props } = this.props;
@ -117,7 +121,7 @@ class SearchInput extends React.Component {
placeholder={this.props.placeholder} placeholder={this.props.placeholder}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
showArrow={false} showArrow={false}
filterOption={false} filterOption={this.handleFilter}
onSearch={this.handleSearch} onSearch={this.handleSearch}
onChange={this.handleChange} onChange={this.handleChange}
onFocus={() => this.handleSearch('')} onFocus={() => this.handleSearch('')}

@ -378,7 +378,7 @@ function getFields(props) {
'DateType', 'DateType',
99, 99,
<Form.Item name={`DateType`} initialValue={at(props, 'initialValue.DateType')[0] || { key: 'applyDate', label: '提交日期' }}> <Form.Item name={`DateType`} initialValue={at(props, 'initialValue.DateType')[0] || { key: 'applyDate', label: '提交日期' }}>
<DateTypeSelect labelInValue={true} disabledKeys={fieldProps?.DateType?.disabledKeys || []} /> <DateTypeSelect labelInValue={true} disabledkeys={fieldProps?.DateType?.disabledkeys || []} />
</Form.Item>, </Form.Item>,
fieldProps?.DateType?.col || 3 fieldProps?.DateType?.col || 3
), ),

Loading…
Cancel
Save