From 12bc328c2488801446591524e4f7b644bd6564ab Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Thu, 28 Sep 2023 14:34:19 +0800 Subject: [PATCH] feat: update data mapper in the base store update the data mapper in the base store, add extra params for the function, which can be better rebuild the data used in the list page or detail page Change-Id: Idb02ff0cce8ef48318b6eb9f0b5c8c6521fc961b --- src/stores/base.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stores/base.js b/src/stores/base.js index 36372f54..41202937 100644 --- a/src/stores/base.js +++ b/src/stores/base.js @@ -69,8 +69,8 @@ export default class BaseStore { get mapper() { // update response items; - return (data) => data; - // return ObjectMapper[this.module] || (data => data); + // eslint-disable-next-line no-unused-vars + return (data, allProjects, originFilters) => data; } get mapperBeforeFetchProject() { @@ -395,7 +395,7 @@ export default class BaseStore { // eslint-disable-next-line no-console console.log(e); } - newData = newData.map(this.mapper); + newData = newData.map((d) => this.mapper(d, all_projects, filters)); this.list.update({ data: newData, total: newData.length || 0, @@ -476,7 +476,7 @@ export default class BaseStore { const allDataNew = allData.map(this.mapperBeforeFetchProject); let newData = await this.listDidFetchProject(allDataNew, all_projects); newData = await this.listDidFetch(newData, all_projects, filters); - newData = newData.map(this.mapper); + newData = newData.map((d) => this.mapper(d, all_projects, filters)); let count; let total; if (result.count || result.total) { @@ -529,7 +529,7 @@ export default class BaseStore { const item = this.mapperBeforeFetchProject(originData, rest, true); try { const newItem = await this.detailDidFetch(item, all_projects, rest); - const detail = this.mapper(newItem); + const detail = this.mapper(newItem, all_projects, rest); this.detail = detail; } catch (e) { // eslint-disable-next-line no-console