| | |
| | | |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) |
| | | const PasteComponent = asyncIconComponent(() => import('../paste')) |
| | | const PasteController = asyncIconComponent(() => import('@/menu/pastecontroller')) |
| | | const TabComponents = asyncComponent(() => import('../tabcomponents')) |
| | | |
| | | const { TabPane } = Tabs |
| | |
| | | |
| | | delTab = (tab) => { |
| | | let tabs = fromJS(this.state.tabs).toJS() |
| | | const _this = this |
| | | const that = this |
| | | |
| | | tabs.subtabs = tabs.subtabs.filter(t => t.uuid !== tab.uuid) |
| | | |
| | |
| | | title: '确定删除标签?', |
| | | content: '', |
| | | onOk() { |
| | | _this.setState({tabs}) |
| | | _this.props.updateConfig(tabs) |
| | | that.setState({tabs}) |
| | | that.props.updateConfig(tabs) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | |
| | | this.props.updateConfig(tabs) |
| | | } |
| | | |
| | | insert = (item, tab) => { |
| | | insert = (item, tabId) => { |
| | | let tabs = fromJS(this.state.tabs).toJS() |
| | | |
| | | tabs.subtabs.forEach(stab => { |
| | | if (stab.uuid === tab.uuid) { |
| | | if (stab.uuid === tabId) { |
| | | stab.components.push(item) |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | getTabForms = (tab) => { |
| | | const { tabs } = this.state |
| | | |
| | | if (!tab) { |
| | | tab = { |
| | | uuid: '', |
| | |
| | | editab: tab |
| | | }) |
| | | |
| | | return getTabForm(tab, tabs.setting) |
| | | return getTabForm(tab) |
| | | } |
| | | |
| | | updateTab = (res) => { |
| | |
| | | editab.icon = res.icon |
| | | editab.hide = res.hide || 'false' |
| | | editab.backgroundColor = res.backgroundColor |
| | | editab.controlVal = res.controlVal || '' |
| | | editab.selectVal = res.selectVal || '' |
| | | // editab.controlVal = res.controlVal || '' |
| | | // editab.selectVal = res.selectVal || '' |
| | | editab.blacklist = res.blacklist |
| | | |
| | | if (/^\s+$/.test(editab.label) && editab.icon) { |
| | | editab.taType = 'only-icon' |
| | | } else { |
| | | delete editab.taType |
| | | } |
| | | |
| | | if (editab.uuid) { |
| | | tabs.subtabs = tabs.subtabs.map(t => { |
| | |
| | | getTabsForms = () => { |
| | | const { tabs } = this.state |
| | | |
| | | return getTabsSetForm(tabs.setting, tabs.uuid) |
| | | return getTabsSetForm(tabs.setting, tabs.uuid, tabs.subtabs) |
| | | } |
| | | |
| | | updateTabs = (res) => { |
| | | this.updateComponent({...this.state.tabs, setting: res}) |
| | | let tabs = fromJS(this.state.tabs).toJS() |
| | | |
| | | if (res.controlVals) { |
| | | let values = {} |
| | | res.controlVals.forEach(item => { |
| | | values[item.uuid] = item.value |
| | | }) |
| | | tabs.subtabs.forEach(tab => { |
| | | tab.controlVal = values[tab.uuid] |
| | | }) |
| | | |
| | | delete res.controlVals |
| | | } |
| | | if (res.selectVals) { |
| | | let values = {} |
| | | res.selectVals.forEach(item => { |
| | | values[item.uuid] = item.value |
| | | }) |
| | | tabs.subtabs.forEach(tab => { |
| | | tab.selectVal = values[tab.uuid] |
| | | }) |
| | | |
| | | delete res.selectVals |
| | | } |
| | | |
| | | res.tabStyle = res.tabStyle || 'line' |
| | | res.cusClass = '' |
| | | |
| | | if (!['line', 'card'].includes(res.tabStyle)) { |
| | | res.cusClass = res.tabStyle |
| | | res.tabStyle = 'line' |
| | | } |
| | | |
| | | tabs.setting = res |
| | | |
| | | this.updateComponent(tabs) |
| | | } |
| | | |
| | | onChange = (key) => { |
| | |
| | | let _style = resetStyle(tabs.style) |
| | | |
| | | return ( |
| | | <div className={'menu-tabs-edit-box ' + (tabs.setting.display || '')} style={_style} id={tabs.uuid}> |
| | | <div className="menu-tabs-edit-box" style={_style} id={tabs.uuid}> |
| | | <DraggableTabs defaultActiveKey={defaultActiveKey} tabBarStyle={{background: tabs.setting.backgroundColor || 'transparent'}} tabPosition={tabs.setting.position} type={tabs.setting.tabStyle} tabsMove={this.moveSwitch} onChange={this.onChange}> |
| | | {tabs.subtabs.map(tab => ( |
| | | <TabPane tab={ |
| | |
| | | <NormalForm title="标签编辑" width={800} update={this.updateTab} getForms={() => this.getTabForms(tab)}> |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <PasteComponent Tab={tab} insert={this.insert} /> |
| | | <PasteController type="tabs" tab={tab} insert={(item) => this.insert(item, tab.uuid)} /> |
| | | <CloseOutlined className="close" onClick={() => this.delTab(tab)} /> |
| | | </div> |
| | | } trigger="hover"> |