From a7ddedc4c5d6cda66a83623d9d318437a19d8338 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 25 九月 2021 19:01:48 +0800 Subject: [PATCH] 2021-09-25 --- src/components/tabview/index.jsx | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index a853921..3760c85 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -136,10 +136,27 @@ } } - modifyTabs = (tab, type) => { - const { tabviews } = this.state + modifyTabs = (tab, type, fixed) => { + const { tabviews, activeId } = this.state - if (type === 'plus') { + if (type === 'plus' && fixed) { + let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID) + let index = _tabs.findIndex(item => item.MenuID === activeId) + + this.setState({ + tabviews: _tabs + }, () => { + if (index > -1) { + _tabs.splice(index + 1, 0, tab) + } else { + _tabs.push(tab) + } + this.setState({ + tabviews: _tabs, + activeId: tab.MenuID + }) + }) + } else if (type === 'plus') { if (tabviews.findIndex(item => item.MenuID === tab.MenuID) > -1) { let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID) this.setState({ -- Gitblit v1.8.0