From c98e45bfac25e9110ad0383faac54a54d98ea9d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 十一月 2021 20:47:04 +0800 Subject: [PATCH] 2021-11-18 --- src/mob/components/topbar/normal-navbar/index.jsx | 121 ++++++++++++++++++++++++++++++++++------ 1 files changed, 103 insertions(+), 18 deletions(-) diff --git a/src/mob/components/topbar/normal-navbar/index.jsx b/src/mob/components/topbar/normal-navbar/index.jsx index 9e82f76..fc6c79b 100644 --- a/src/mob/components/topbar/normal-navbar/index.jsx +++ b/src/mob/components/topbar/normal-navbar/index.jsx @@ -2,15 +2,17 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Icon, Popover } from 'antd' +import { ExpandOutlined, ReloadOutlined } from '@ant-design/icons' import asyncIconComponent from '@/utils/asyncIconComponent' - +import getWrapForm from './options' import MKEmitter from '@/utils/events.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import './index.scss' -const WrapComponent = asyncIconComponent(() => import('./wrapsetting')) +const NormalForm = asyncIconComponent(() => import('@/components/normalform')) +const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) class NormalNavbar extends Component { static propTpyes = { @@ -33,10 +35,11 @@ uuid: card.uuid, type: card.type, floor: card.floor, - width: card.width || 24, + width: 24, subtype: card.subtype, - wrap: { height: 50, title: 'NavBar', back: 'true', logout: 'false' }, - style: {borderBottomColor: '#bcbcbc', borderBottomWidth: '1px', paddingLeft: '10px', paddingRight: '10px', lineHeight: '2.8', fontSize: '18px' }, + wrap: { type: 'navbar', height: 50, title: 'NavBar', back: 'true', search: 'false', logout: 'false' }, + style: {boxShadow: '0 0 3px #D9D9D9', shadowColor: '#D9D9D9', shadowBlur: '3px', paddingLeft: '10px', paddingRight: '10px', lineHeight: '2.8', fontSize: '18px' }, + searchStyle: {} } if (card.config) { @@ -59,6 +62,7 @@ componentDidMount () { MKEmitter.addListener('submitStyle', this.getStyle) + MKEmitter.addListener('submitSearch', this.getSearch) } shouldComponentUpdate (nextProps, nextState) { @@ -73,6 +77,7 @@ return } MKEmitter.removeListener('submitStyle', this.getStyle) + MKEmitter.removeListener('submitSearch', this.getSearch) } /** @@ -83,9 +88,6 @@ card: component }) - component.width = component.wrap.width - component.name = component.wrap.name - this.props.updateConfig(component) } @@ -94,7 +96,13 @@ if (comIds[0] !== card.uuid) return - let _card = {...card, style} + let _card = fromJS(card).toJS() + + if (comIds[1] === 'search') { + _card.searchStyle = style + } else { + _card.style = style + } this.setState({ card: _card @@ -109,6 +117,12 @@ MKEmitter.emit('changeStyle', [card.uuid], ['font', 'background', 'border', 'padding', 'shadow'], card.style) } + changeSearchStyle = () => { + const { card } = this.state + + MKEmitter.emit('changeStyle', [card.uuid, 'search'], ['font', 'background', 'border'], card.searchStyle || {}) + } + clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() @@ -121,7 +135,6 @@ window.open(menu.link) } else { MKEmitter.emit('changeEditMenu', { - fixed: menu.property === 'menu', MenuID: menu.property === 'linkmenu' ? menu.linkMenuId : menu.MenuID, copyMenuId: menu.property === 'menu' ? menu.copyMenuId : '', MenuNo: menu.MenuNo, @@ -130,20 +143,78 @@ } } + getSearch = (config) => { + const { card } = this.state + + if (card.uuid !== config.uuid) return + + this.setState({ + card: config + }) + + this.props.updateConfig(config) + } + + setSearch = () => { + let card = fromJS(this.state.card).toJS() + + if (!card.search) { + card.search = { + floor: 1, + setting: { type: 'title', field: '', title: '', focus: 'true', btn: 'hidden' }, + groups: [], + fields: [] + } + } + this.props.updateConfig(card) + MKEmitter.emit('changeSearch', card) + } + + getWrapForms = () => { + const { wrap } = this.state.card + + return getWrapForm(wrap) + } + + updateWrap = (res) => { + this.updateComponent({...this.state.card, wrap: res}) + } + + skip = () => { + const { wrap } = this.state.card + + if (!wrap.linkmenu) return + + MKEmitter.emit('changeEditMenu', { + MenuID: wrap.linkmenu, + copyMenuId: '', + MenuNo: '', + MenuName: '', + }) + } + render() { const { card } = this.state - let _style = {...card.style} - if (_style.shadow) { - _style.boxShadow = '0 0 4px ' + _style.shadow + let right = null + if (card.wrap.logout === 'true') { + right = <Icon type="logout" /> } - _style.height = card.wrap.height + if (card.wrap.scan === 'true') { + right = !right ? <ExpandOutlined onDoubleClick={this.skip}/> : <Icon type="ellipsis" /> + } + if (card.wrap.refresh === 'true') { + right = !right ? <ReloadOutlined /> : <Icon type="ellipsis" onDoubleClick={this.skip}/> + } return ( - <div className="normal-topbar-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}> + <div className="normal-topbar-edit-box" style={card.style} onClick={this.clickComponent} id={card.uuid}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <WrapComponent config={card} updateConfig={this.updateComponent} /> + <NormalForm title="瀵艰埅鏍忚缃�" width={750} update={this.updateWrap} getForms={this.getWrapForms}> + <Icon type="edit" style={{color: '#1890ff'}} title="缂栬緫"/> + </NormalForm> + <CopyComponent type="topbar" card={card}/> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> </div> @@ -154,9 +225,23 @@ <div className="am-navbar-left"> {card.wrap.back !== 'false' ? <Icon type="left" /> : null} </div> - <div className="am-navbar-title">{card.wrap.title || ''}</div> + {card.wrap.type !== 'search' ? + <div className="am-navbar-title">{card.wrap.title || ''}</div> : + <div className="am-navbar-search" onDoubleClick={this.setSearch}> + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeSearchStyle} type="font-colors" /> + </div> + } trigger="hover"> + <div style={card.searchStyle} className="search-bar"> + {card.search && card.search.setting.scan === 'true' ? <Icon type="scan" /> : <Icon type="search" />} + </div> + </Popover> + </div> + } <div className="am-navbar-right"> - {card.wrap.logout === 'true' ? <span>閫�鍑�</span> : null} + {card.wrap.search === 'true' ? <Icon type="search" onDoubleClick={this.setSearch}/> : null} + {right} </div> </div> </div> -- Gitblit v1.8.0