From fb64bcf1fab18b33d21470c83f28d4cda8d309ce Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 26 十月 2022 12:15:59 +0800
Subject: [PATCH] 2022-10-26

---
 src/menu/components/tabs/table-tabs/index.jsx |   49 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/src/menu/components/tabs/table-tabs/index.jsx b/src/menu/components/tabs/table-tabs/index.jsx
index 1536bc0..9671afd 100644
--- a/src/menu/components/tabs/table-tabs/index.jsx
+++ b/src/menu/components/tabs/table-tabs/index.jsx
@@ -4,19 +4,16 @@
 import { Tabs, Popover, Modal } from 'antd'
 import { PlusOutlined, CloseOutlined, EditOutlined, DeleteOutlined, ToolOutlined } from '@ant-design/icons'
 
-import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
 import MkIcon from '@/components/mk-icon'
 import DraggableTabs from './dragabletabs'
-import MenuUtils from '@/utils/utils-custom.js'
 import Utils from '@/utils/utils.js'
 import { getTabForm } from './options'
 import './index.scss'
 
 const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
-// const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
-const PasteComponent = asyncIconComponent(() => import('../paste'))
+const PasteBaseTable = asyncIconComponent(() => import('@/menu/components/share/pastebasetable'))
 const BaseTable = asyncComponent(() => import('@/menu/components/table/base-table'))
 
 const { TabPane } = Tabs
@@ -80,18 +77,12 @@
 
     tabs.subtabs = tabs.subtabs.filter(t => t.uuid !== tab.uuid)
 
-    let uuids = MenuUtils.getDelButtonIds({...tab, type: 'group'})
-
     confirm({
       title: '纭畾鍒犻櫎鏍囩锛�',
       content: '',
       onOk() {
         _this.setState({tabs})
         _this.props.updateConfig(tabs)
-
-        if (uuids.length === 0) return
-        
-        MKEmitter.emit('delButtons', uuids)
       },
       onCancel() {}
     })
@@ -149,16 +140,36 @@
     }
   }
 
-  insert = (item, tab) => {
+  plusTable = () => {
+    let tabs = fromJS(this.state.tabs).toJS()
+    let name = '瀛愯〃' + (tabs.subtabs.length + 1)
+    let tab = { uuid: Utils.getuuid(), label: name, icon: '', components: [{uuid: Utils.getuuid(), type: 'table', name: name, subtype: 'basetable', isNew: true}]}
+
+    tabs.subtabs.push(tab)
+
+    this.setState({tabs}, () => {
+      setTimeout(() => {
+        let node = document.getElementById(tab.uuid)
+        node && node.click()
+      }, 200)
+    })
+    this.props.updateConfig(tabs)
+  }
+
+  insert = (item) => {
     let tabs = fromJS(this.state.tabs).toJS()
 
-    tabs.subtabs.forEach(stab => {
-      if (stab.uuid === tab.uuid) {
-        stab.components.push(item)
-      }
-    })
+    let name = item.name || ('瀛愯〃' + (tabs.subtabs.length + 1))
+    let tab = { uuid: Utils.getuuid(), label: name, icon: '', components: [item]}
 
-    this.setState({tabs})
+    tabs.subtabs.push(tab)
+
+    this.setState({tabs}, () => {
+      setTimeout(() => {
+        let node = document.getElementById(tab.uuid)
+        node && node.click()
+      }, 200)
+    })
     this.props.updateConfig(tabs)
   }
 
@@ -246,8 +257,8 @@
         </DraggableTabs>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <PlusOutlined className="plus" title="娣诲姞瀛愯〃"/>
-            <PasteComponent insert={this.insert} />
+            <PlusOutlined className="plus" title="娣诲姞瀛愯〃" onClick={this.plusTable}/>
+            <PasteBaseTable insert={this.insert} />
             <DeleteOutlined className="close" onClick={() => this.props.deletecomponent(tabs.uuid)} />
           </div>
         } trigger="hover">

--
Gitblit v1.8.0