|
|
@@ -1,26 +1,32 @@
|
|
|
-import {FilterButtonGroup, FilterField} from '@components';
|
|
|
-import {Card, Row} from 'antd';
|
|
|
-import {FC, useState} from 'react';
|
|
|
-import {useContextSection, useTableSearchEvent} from '@hooks';
|
|
|
+import {FilterButtonGroup, FilterField, FilterFieldWrapper} from '@components';
|
|
|
+import {Card} from 'antd';
|
|
|
+import {FC} from 'react';
|
|
|
+import {useContextSection, useFilterField, useTableSearclToolEvents} from '@hooks';
|
|
|
import {context, searchContext} from '../context';
|
|
|
|
|
|
const Filter: FC = function () {
|
|
|
- const [value, onChange] = useState('');
|
|
|
- const onSearch = useTableSearchEvent(context, {name: value});
|
|
|
- const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
|
|
|
+ const [field, {onChange, resetState}] = useFilterField({name: ''}, true);
|
|
|
+ const [, {onSearch, onReset}] = useTableSearclToolEvents(context, field, {
|
|
|
+ resetCallback: resetState,
|
|
|
+ });
|
|
|
+ const {isSearching} = useContextSection(searchContext, state => state[0]);
|
|
|
|
|
|
return (
|
|
|
<Card>
|
|
|
- <Row>
|
|
|
- <FilterField name='childMenuName' label='菜单名称' value={value} onChange={onChange} />
|
|
|
+ <FilterFieldWrapper>
|
|
|
+ <FilterField
|
|
|
+ name='childMenuName'
|
|
|
+ label='菜单名称'
|
|
|
+ value={field.name}
|
|
|
+ onChange={onChange('name')}
|
|
|
+ />
|
|
|
<FilterButtonGroup
|
|
|
isSearching={isSearching}
|
|
|
- onRefresh={refetch}
|
|
|
onSearch={onSearch}
|
|
|
- offset={12}
|
|
|
+ onReset={onReset}
|
|
|
searchTestId='child_menu_search_btn'
|
|
|
/>
|
|
|
- </Row>
|
|
|
+ </FilterFieldWrapper>
|
|
|
</Card>
|
|
|
);
|
|
|
};
|