From 88e4ca036cc037f03db87954dd7d27ef484f261a Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 29 Jul 2022 15:26:43 +0800 Subject: [PATCH] fix: fix the filtered data is inconsistent with the refreshed data When using the front end to filter the data, when the data is refreshed, the filter param is also passed to the API, remove the filter params to fix the situation Change-Id: I60fc2a6ea3d6c345f0fdb2254c2018c2a07f56c5 --- src/containers/List/index.jsx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/containers/List/index.jsx b/src/containers/List/index.jsx index 1ecaf78a..91600a63 100644 --- a/src/containers/List/index.jsx +++ b/src/containers/List/index.jsx @@ -945,9 +945,32 @@ export default class BaseList extends React.Component { } }; + getPureParamsByFrontend = (params) => { + const { page, limit, sortKey, sortOrder, ...rest } = params; + const pureParams = { page, limit }; + if (this.isSortByBackend) { + pureParams.sortKey = sortKey; + pureParams.sortOrder = sortOrder; + } + if (!this.searchFilters.length) { + const { keywords, ...others } = rest; + return { + ...pureParams, + ...others, + }; + } + Object.keys(rest).forEach((key) => { + const item = this.searchFilters.find((it) => it.name === key); + if (!item) { + pureParams[key] = rest[key]; + } + }); + return pureParams; + }; + handleFetch = (params, refresh) => { if (refresh && !this.isFilterByBackend) { - this.getDataWithPolicy(params); + this.getDataWithPolicy(this.getPureParamsByFrontend(params)); return; } // eslint-disable-next-line no-unused-vars