From a06655e10f4242c350a3450c6c21e77f33302e2e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 27 十一月 2020 22:09:04 +0800
Subject: [PATCH] 2020-11-27

---
 src/menu/components/tabs/antv-tabs/index.jsx |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/menu/components/tabs/antv-tabs/index.jsx b/src/menu/components/tabs/antv-tabs/index.jsx
index e5b9733..720b8b4 100644
--- a/src/menu/components/tabs/antv-tabs/index.jsx
+++ b/src/menu/components/tabs/antv-tabs/index.jsx
@@ -7,6 +7,7 @@
 import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
+import DraggableTabs from './dragabletabs'
 
 import Utils from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/model.js'
@@ -218,9 +219,20 @@
     })
   }
 
-  moveSwitch = (index, index1) => {
+  moveSwitch = (order) => {
     let tabs = fromJS(this.state.tabs).toJS()
-    tabs.subtabs[index] = tabs.subtabs.splice(index1, 1, tabs.subtabs[index])[0]
+    let subtab = {}
+    tabs.subtabs.forEach(item => {
+      subtab[item.uuid] = item
+    })
+
+    tabs.subtabs = []
+
+    order.forEach(item => {
+      if (subtab[item]) {
+        tabs.subtabs.push(subtab[item])
+      }
+    })
 
     this.setState({tabs})
     this.props.updateConfig(tabs)
@@ -231,14 +243,12 @@
 
     return (
       <div className="menu-tabs-edit-box" style={tabs.style}>
-        <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}>
-          {tabs.subtabs.map((tab, index) => (
+        <DraggableTabs tabPosition={tabs.setting.position} type={tabs.setting.tabStyle} tabsMove={this.moveSwitch}>
+          {tabs.subtabs.map(tab => (
             <TabPane tab={
               <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
                 <div className="mk-popover-control">
                   <Icon className="edit" title="edit" type="edit" onClick={() => this.editTab(tab)} />
-                  {index !== 0 ? <Icon className="edit" type="arrow-left" onClick={() => this.moveSwitch(index, index - 1)} /> : null}
-                  {(index + 1) !== tabs.subtabs.length ? <Icon className="edit" type="arrow-right" onClick={() => this.moveSwitch(index, index + 1)} /> : null}
                   <Icon className="close" title="delete" type="close" onClick={() => this.delTab(tab)} />
                 </div>
               } trigger="hover">
@@ -261,7 +271,7 @@
             </Popover>
           } key="tool">
           </TabPane>
-        </Tabs>
+        </DraggableTabs>
         <Modal
           wrapClassName="popview-modal"
           title={'鏍囩缂栬緫'}

--
Gitblit v1.8.0