| | |
| | | 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 |
| | |
| | | |
| | | 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() {} |
| | | }) |
| | |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | } |
| | | |
| | |
| | | </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"> |