From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 七月 2021 11:39:39 +0800 Subject: [PATCH] 2021-07-28 --- src/menu/components/tabs/antv-tabs/index.jsx | 86 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 69 insertions(+), 17 deletions(-) diff --git a/src/menu/components/tabs/antv-tabs/index.jsx b/src/menu/components/tabs/antv-tabs/index.jsx index 3879bea..0cb7d7d 100644 --- a/src/menu/components/tabs/antv-tabs/index.jsx +++ b/src/menu/components/tabs/antv-tabs/index.jsx @@ -7,7 +7,8 @@ import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' import DraggableTabs from './dragabletabs' - +import { resetStyle } from '@/utils/utils-custom.js' +import MenuUtils from '@/utils/utils-custom.js' import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -31,6 +32,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + appType: sessionStorage.getItem('appType'), tabs: null, editab: null, labelvisible: false @@ -74,6 +76,7 @@ componentDidMount () { MKEmitter.addListener('submitStyle', this.getStyle) + MKEmitter.addListener('submitSearch', this.getSearch) MKEmitter.addListener('tabsChange', this.handleTabsChange) MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) } @@ -86,6 +89,7 @@ return } MKEmitter.removeListener('submitStyle', this.getStyle) + MKEmitter.removeListener('submitSearch', this.getSearch) MKEmitter.removeListener('tabsChange', this.handleTabsChange) MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) } @@ -215,6 +219,7 @@ this.tabLabelRef.handleConfirm().then(res => { editab.label = res.label editab.icon = res.icon + editab.hasSearch = res.hasSearch || '' editab.blacklist = res.blacklist if (editab.uuid) { @@ -245,12 +250,18 @@ 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() {} }) @@ -288,6 +299,45 @@ this.props.updateConfig(tabs) } + getSearch = (config) => { + const { tabs } = this.state + + if (tabs.uuid !== config.uuid) return + + let _tabs = fromJS(tabs).toJS() + + _tabs.subtabs = _tabs.subtabs.map(t => { + if (t.uuid === config.tabId) { + t.search = config.search + } + return t + }) + + this.setState({ + tabs: _tabs + }) + this.props.updateConfig(_tabs) + } + + setSearch = (tab) => { + const { tabs } = this.state + let card = { + uuid: tabs.uuid, + tabId: tab.uuid, + search: tab.search + } + + if (!card.search) { + card.search = { + floor: 1, + setting: { type: 'title', field: '', title: '', focus: 'true', btn: 'hidden' }, + groups: [], + fields: [] + } + } + MKEmitter.emit('changeSearch', card) + } + clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() @@ -296,9 +346,11 @@ } render() { - const { tabs, dict, labelvisible, editab } = this.state + const { tabs, dict, labelvisible, editab, appType } = this.state + let _style = resetStyle(tabs.style) + return ( - <div className="menu-tabs-edit-box" style={tabs.style} onClick={this.clickComponent} id={tabs.uuid}> + <div className={'menu-tabs-edit-box ' + tabs.setting.display} style={_style} onClick={this.clickComponent} id={tabs.uuid}> <DraggableTabs tabPosition={tabs.setting.position} type={tabs.setting.tabStyle} tabsMove={this.moveSwitch}> {tabs.subtabs.map(tab => ( <TabPane tab={ @@ -312,24 +364,23 @@ <span>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span> </Popover> } key={tab.uuid}> + {appType === 'mob' && tabs.setting.position === 'top' && tabs.setting.display === 'inline-block' && tab.hasSearch === 'icon' ? + <Icon className="search-icon" onDoubleClick={() => this.setSearch(tab)} type="search" /> : null} <TabComponents config={tab} handleList={this.updateTabComponent} deleteCard={this.deleteCard} /> </TabPane> ))} - <TabPane disabled tab={ - <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ - <div className="mk-popover-control"> - <Icon className="plus" title="娣诲姞鏍囩" type="plus" onClick={this.tabAdd} /> - <SettingComponent config={tabs} updateConfig={this.updateComponent} /> - <CopyComponent type="tabs" card={tabs}/> - <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> - <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(tabs.uuid)} /> - </div> - } trigger="hover"> - <Icon type="tool" /> - </Popover> - } key="tool"> - </TabPane> </DraggableTabs> + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <Icon className="plus" title="娣诲姞鏍囩" type="plus" onClick={this.tabAdd} /> + <SettingComponent config={tabs} updateConfig={this.updateComponent} /> + <CopyComponent type="tabs" card={tabs}/> + <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> + <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(tabs.uuid)} /> + </div> + } trigger="hover"> + <Icon type="tool" /> + </Popover> <Modal wrapClassName="popview-modal" title={'鏍囩缂栬緫'} @@ -344,6 +395,7 @@ <TabLabelComponent dict={dict} tab={editab} + setting={tabs.setting} inputSubmit={this.tabLabelSubmit} wrappedComponentRef={(inst) => this.tabLabelRef = inst} /> -- Gitblit v1.8.0