|
@@ -1,67 +1,56 @@
|
|
|
-import {FilterField, FilterButtonGroup, FilterSelect, FilterFieldWrapper} from '@components';
|
|
|
+import {FilterButtonGroup, FilterFieldWrapper, FilterSelectorModal} from '@components';
|
|
|
import {Card} from 'antd';
|
|
|
import {FC} from 'react';
|
|
|
import {
|
|
|
useContextSection,
|
|
|
- useDictionaryOptions,
|
|
|
+ useFilterDB,
|
|
|
useFilterField,
|
|
|
- useTableExportEvent,
|
|
|
- useTableSearchEvent,
|
|
|
+ useTableSearchToolEvents,
|
|
|
+ useFieldGroup,
|
|
|
} from '@hooks';
|
|
|
-import {context, pageContext, searchContext} from '../context';
|
|
|
-import {exportStorage} from '@apis';
|
|
|
-
|
|
|
-const disableOptions = [
|
|
|
- {label: '全部', value: ''},
|
|
|
- {label: '是', value: '1'},
|
|
|
- {label: '否', value: '0'},
|
|
|
-];
|
|
|
+import {context, contextState, searchContext} from '../context';
|
|
|
+import {fixedMap, sourceMap} from './state';
|
|
|
|
|
|
const Filter: FC = function () {
|
|
|
- const [{code, name, isNotDisable, type}, onChange] = useFilterField({
|
|
|
- name: '',
|
|
|
- code: '',
|
|
|
- type: '',
|
|
|
- isNotDisable: '',
|
|
|
- });
|
|
|
- const onSearch = useTableSearchEvent(context, {
|
|
|
- storageLocationName: name,
|
|
|
- storageLocationCode: code,
|
|
|
- storageLocationType: type,
|
|
|
- isNotDisable,
|
|
|
+ const [fields, {onChange, resetState}] = useFilterField({...contextState}, true);
|
|
|
+ const [visible, {onSearch, onReset, onShowModal, onCloseModal}] = useTableSearchToolEvents(
|
|
|
+ context,
|
|
|
+ fields,
|
|
|
+ {
|
|
|
+ resetCallback: resetState,
|
|
|
+ },
|
|
|
+ );
|
|
|
+ const {isSearching} = useContextSection(searchContext, state => state[0]);
|
|
|
+ const [filterList, {set}] = useFilterDB();
|
|
|
+ const FilterFields = useFieldGroup(filterList, sourceMap, {
|
|
|
+ fields,
|
|
|
+ fixedMap,
|
|
|
+ onChange,
|
|
|
+ onSearch,
|
|
|
});
|
|
|
- const [isExporting, onExport] = useTableExportEvent({pageContext, context, fn: exportStorage});
|
|
|
- const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
|
|
|
- const typeOptions = useDictionaryOptions('物料类型', true);
|
|
|
|
|
|
return (
|
|
|
- <Card>
|
|
|
- <FilterFieldWrapper>
|
|
|
- <FilterField name='storageCode' label='库位编号' value={code} onChange={onChange('code')} />
|
|
|
- <FilterField name='storageName' label='库位名称' value={name} onChange={onChange('name')} />
|
|
|
- <FilterSelect
|
|
|
- name='storageState'
|
|
|
- label='混合库位'
|
|
|
- value={isNotDisable}
|
|
|
- onChange={onChange('isNotDisable')}
|
|
|
- options={disableOptions}
|
|
|
- />
|
|
|
- <FilterSelect
|
|
|
- name='storageState'
|
|
|
- label='物料类型'
|
|
|
- value={type}
|
|
|
- onChange={onChange('type')}
|
|
|
- options={typeOptions}
|
|
|
- />
|
|
|
- <FilterButtonGroup
|
|
|
- isSearching={isSearching}
|
|
|
- isExporting={isExporting}
|
|
|
- onSearch={onSearch}
|
|
|
- onExport={onExport}
|
|
|
- onRefresh={refetch}
|
|
|
- />
|
|
|
- </FilterFieldWrapper>
|
|
|
- </Card>
|
|
|
+ <>
|
|
|
+ <Card>
|
|
|
+ <FilterFieldWrapper>
|
|
|
+ {FilterFields}
|
|
|
+ <FilterButtonGroup
|
|
|
+ isSearching={isSearching}
|
|
|
+ onSearch={onSearch}
|
|
|
+ onReset={onReset}
|
|
|
+ onFilter={onShowModal}
|
|
|
+ />
|
|
|
+ </FilterFieldWrapper>
|
|
|
+ </Card>
|
|
|
+
|
|
|
+ <FilterSelectorModal
|
|
|
+ visible={visible}
|
|
|
+ onClose={onCloseModal}
|
|
|
+ source={filterList}
|
|
|
+ filtermap={sourceMap}
|
|
|
+ onConfirm={set}
|
|
|
+ />
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|