import React from 'react';
|
import { Input, Button, Space, Select } from 'antd';
|
|
const TextFilter = (props) => {
|
return (
|
<div style={{ padding: 8 }}>
|
<Input
|
style={{ width: 188, marginBottom: 8, display: 'block' }}
|
value={props.selectedKeys[0]}
|
onChange={e => {
|
props.setSelectedKeys(e.target.value ? [e.target.value] : [])
|
}}
|
/>
|
<Space>
|
<Button
|
type="primary"
|
onClick={() => {
|
props.confirm();
|
props.setSearchParam(prevState => ({
|
...prevState,
|
[props.name]: props.selectedKeys[0]
|
}));
|
props.actionRef.current?.reload();
|
}}
|
size="small"
|
style={{ width: 90 }}
|
>
|
确定
|
</Button>
|
<Button
|
onClick={() => props.clearFilters && props.clearFilters()}
|
size="small"
|
style={{ width: 90 }}
|
>
|
重置
|
</Button>
|
</Space>
|
</div>
|
);
|
}
|
|
const SelectFilter = (props) => {
|
return (
|
<div style={{ padding: 8 }}>
|
<Select
|
style={{ width: 188, marginBottom: 8 }}
|
placeholder="选择一个选项"
|
value={props.selectedKeys[0]}
|
onChange={value => props.setSelectedKeys(value ? [value] : [])}
|
>
|
{props.data.map(item => (
|
<Select.Option key={item.value} value={item.value}>
|
{item.label}
|
</Select.Option>
|
))}
|
</Select>
|
<Space>
|
<Button
|
type="primary"
|
onClick={() => {
|
props.confirm();
|
props.setSearchParam(prevState => ({
|
...prevState,
|
[props.name]: props.selectedKeys[0]
|
}));
|
props.actionRef.current?.reload();
|
}}
|
size="small"
|
style={{ width: 90 }}
|
>
|
确定
|
</Button>
|
<Button
|
onClick={() => {
|
setSelectedKeys([]);
|
clearFilters();
|
}}
|
size="small"
|
style={{ width: 90 }}
|
>
|
重置
|
</Button>
|
</Space>
|
</div>
|
);
|
}
|
|
export { TextFilter, SelectFilter };
|