From af6486b3629d23e426ce85b87dbc20dfa15b1afe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 07 十一月 2022 18:50:27 +0800 Subject: [PATCH] 2022-11-07 --- src/menu/components/tabs/table-tabs/index.jsx | 54 ++++++++++++++++++++++++++++++++---------------------- 1 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/menu/components/tabs/table-tabs/index.jsx b/src/menu/components/tabs/table-tabs/index.jsx index 5356b0f..293312c 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 @@ -43,7 +40,6 @@ uuid: tabs.uuid, type: tabs.type, subtype: 'tabletabs', - width: 24, setting: {}, style: {}, subtabs: [ @@ -80,18 +76,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 +139,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) } @@ -188,7 +198,7 @@ editab.label = res.label editab.icon = res.icon editab.hide = res.hide || 'false' - editab.blacklist = res.blacklist + editab.permission = res.permission || 'false' editab.components[0].name = res.label if (editab.uuid) { @@ -225,7 +235,7 @@ const { tabs } = this.state return ( - <div className="menu-tabs-edit-box" style={tabs.style} id={tabs.uuid}> + <div className="table-tabs-edit-box" style={tabs.style} id={tabs.uuid}> <DraggableTabs tabsMove={this.moveSwitch} tabsDrop={this.dropTable}> {tabs.subtabs.map((tab, i) => ( <TabPane tab={ @@ -246,8 +256,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