fix: Show the number of filters
This commit is contained in:
parent
c20d3a91de
commit
2e35947dae
@ -8,7 +8,7 @@ export function Filter(props) {
|
||||
const drawerRef = useRef<any>();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const { title, viewName, collection_name } = props.schema;
|
||||
const { activeTab = {}, item = {}, associatedName, associatedKey } = props;
|
||||
const { filterCount, activeTab = {}, item = {}, associatedName, associatedKey } = props;
|
||||
const { associationField } = activeTab;
|
||||
|
||||
const params = {};
|
||||
@ -53,7 +53,7 @@ export function Filter(props) {
|
||||
>
|
||||
<Button icon={<FilterOutlined />} onClick={() => {
|
||||
setVisible(true);
|
||||
}}>{title}</Button>
|
||||
}}>{filterCount ? `${filterCount} 个${title}项` : title}</Button>
|
||||
</Popover>
|
||||
</>
|
||||
)
|
||||
|
@ -31,6 +31,7 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
const { rowKey = 'id', name: viewName, actionDefaultParams = {}, fields = [], rowViewName, actions = [], paginated = true, defaultPerPage = 10 } = schema;
|
||||
const { sourceKey = 'id' } = activeTab.field||{};
|
||||
const drawerRef = useRef<any>();
|
||||
const [filterCount, setFilterCount] = useState(0);
|
||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||
const { data, loading, pagination, mutate, refresh, params, run } = useRequest((params = {}) => {
|
||||
const { current, pageSize, sorter, filter, ...restParams } = params;
|
||||
@ -78,12 +79,15 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
{...props}
|
||||
style={{ marginBottom: 14 }}
|
||||
actions={actions}
|
||||
filterCount={filterCount}
|
||||
onFinish={() => {
|
||||
refresh();
|
||||
}}
|
||||
onTrigger={{
|
||||
async filter(values) {
|
||||
console.log('filter', values);
|
||||
const items = values.filter.and || values.filter.or;
|
||||
setFilterCount(Object.keys(items).length);
|
||||
// @ts-ignore
|
||||
run({...params[0], filter: values.filter});
|
||||
},
|
||||
|
@ -30,6 +30,7 @@ export function Table(props: TableProps) {
|
||||
// const { data, mutate } = useRequest(() => api.resource(name).list({
|
||||
// associatedKey,
|
||||
// }));
|
||||
const [filterCount, setFilterCount] = useState(0);
|
||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||
const { data, loading, pagination, mutate, refresh, run, params } = useRequest((params = {}, ...args) => {
|
||||
const { current, pageSize, sorter, filter, ...restParams } = params;
|
||||
@ -78,6 +79,7 @@ export function Table(props: TableProps) {
|
||||
<Card bordered={false}>
|
||||
<Actions
|
||||
{...props}
|
||||
filterCount={filterCount}
|
||||
style={{ marginBottom: 14 }}
|
||||
actions={actions}
|
||||
onFinish={() => {
|
||||
@ -85,6 +87,8 @@ export function Table(props: TableProps) {
|
||||
}}
|
||||
onTrigger={{
|
||||
async filter(values) {
|
||||
const items = values.filter.and || values.filter.or;
|
||||
setFilterCount(Object.keys(items).length);
|
||||
// @ts-ignore
|
||||
run({...params[0], filter: values.filter});
|
||||
console.log('filter', values);
|
||||
|
Loading…
Reference in New Issue
Block a user