From 6f8c62d3484780e3767e7c2d79f5860128bbe155 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Mon, 15 Apr 2024 17:32:57 +0800 Subject: [PATCH] feat: update refresh tab data Stop refresh tab data when the action is opened in the detail page Change-Id: Ib99eb054da9b604e64bec0f7435b4a5095eb54bd --- src/containers/List/index.jsx | 8 ++++++++ src/containers/TabDetail/index.jsx | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/containers/List/index.jsx b/src/containers/List/index.jsx index 4f10fc8b..11c34fe9 100644 --- a/src/containers/List/index.jsx +++ b/src/containers/List/index.jsx @@ -145,6 +145,11 @@ export default class BaseList extends React.Component { return !!detail; } + get inDetailAction() { + const { inAction } = this.props; + return !!inAction; + } + get detailName() { if (!this.inDetailPage) { return ''; @@ -939,6 +944,9 @@ export default class BaseList extends React.Component { handleRefresh = (force) => { const { inAction, inSelect } = this; + if (this.inDetailPage && this.inDetailAction) { + return; + } if (inAction || (inSelect && !force)) { return; } diff --git a/src/containers/TabDetail/index.jsx b/src/containers/TabDetail/index.jsx index 0a6cc431..1e7d89c0 100644 --- a/src/containers/TabDetail/index.jsx +++ b/src/containers/TabDetail/index.jsx @@ -346,6 +346,21 @@ export default class DetailBase extends React.Component { const silence = !this.forceLoadingTabs.includes(this.tab.key); this.refreshDetailByAction(silence); } + this.setState({ + inAction: false, + }); + }; + + onClickAction = () => { + this.setState({ + inAction: true, + }); + }; + + onCancelAction = () => { + this.setState({ + inAction: false, + }); }; init() { @@ -412,6 +427,7 @@ export default class DetailBase extends React.Component { renderTabComponent(tabItem) { const { component, key, render } = tabItem; + const { inAction } = this.state; if (render) { return render; } @@ -421,6 +437,7 @@ export default class DetailBase extends React.Component { detail={this.detailData} detailName={`${this.name}-${this.id}`} refreshDetail={this.refreshDetailByTab} + inAction={inAction} /> ) : ( {key} @@ -467,6 +484,8 @@ export default class DetailBase extends React.Component { item={this.getActionData()} containerProps={{ isAdminPage: this.isAdminPage }} isAdminPage={this.isAdminPage} + onClickAction={this.onClickAction} + onCancelAction={this.onCancelAction} // firstActionClassName={styles['attach-btn']} /> );