diff --git a/packages/app/src/components/views/SimpleTable.tsx b/packages/app/src/components/views/SimpleTable.tsx index a525e10cf..9f47aa518 100644 --- a/packages/app/src/components/views/SimpleTable.tsx +++ b/packages/app/src/components/views/SimpleTable.tsx @@ -32,6 +32,7 @@ export function SimpleTable(props: SimpleTableProps) { selectedRowKeys: srk, } = props; const { rowKey = 'id', name: viewName, actionDefaultParams = {}, fields = [], rowViewName, actions = [], paginated = true, defaultPerPage = 10 } = schema; + const { filter: defaultFilter = {} } = actionDefaultParams; const { sourceKey = 'id' } = activeTab.field||{}; const drawerRef = useRef(); const [filterCount, setFilterCount] = useState(0); @@ -43,9 +44,15 @@ export function SimpleTable(props: SimpleTableProps) { page: paginated ? current : 1, perPage: paginated ? pageSize : -1, sorter, - filter, + // filter, viewName, ...actionDefaultParams, + filter: { + and: [ + defaultFilter, + filter, + ].filter(obj => obj && Object.keys(obj).length) + } }) .then(({data = [], meta = {}}) => { return { diff --git a/packages/app/src/components/views/Table.tsx b/packages/app/src/components/views/Table.tsx index 94ccb95dc..505700a2c 100644 --- a/packages/app/src/components/views/Table.tsx +++ b/packages/app/src/components/views/Table.tsx @@ -34,6 +34,8 @@ export function Table(props: TableProps) { // const { data, mutate } = useRequest(() => api.resource(name).list({ // associatedKey, // })); + const { filter: defaultFilter = {} } = actionDefaultParams; + const [filterCount, setFilterCount] = useState(0); const name = associatedName ? `${associatedName}.${resourceName}` : resourceName; const { data, loading, pagination, mutate, refresh, run, params } = useRequest((params = {}, ...args) => { @@ -44,9 +46,15 @@ export function Table(props: TableProps) { page: paginated ? current : 1, perPage: paginated ? pageSize : -1, sorter, - filter, + // filter, viewName, ...actionDefaultParams, + filter: { + and: [ + defaultFilter, + filter, + ].filter(obj => obj && Object.keys(obj).length) + } // ...args2, }) .then(({data = [], meta = {}}) => {