From e1cee96b38805bcccf48e7bcb9d296f2bc54c720 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 24 一月 2025 11:10:32 +0800 Subject: [PATCH] 2025-01-24 --- src/mob/components/menubar/normal-menubar/index.jsx | 126 ++++++++++++++++++++++-------------------- 1 files changed, 66 insertions(+), 60 deletions(-) diff --git a/src/mob/components/menubar/normal-menubar/index.jsx b/src/mob/components/menubar/normal-menubar/index.jsx index 2e02fab..596f800 100644 --- a/src/mob/components/menubar/normal-menubar/index.jsx +++ b/src/mob/components/menubar/normal-menubar/index.jsx @@ -16,7 +16,6 @@ const MenuComponent = asyncComponent(() => import('./menucomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) -const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) @@ -41,17 +40,14 @@ let _card = { uuid: card.uuid, type: card.type, - tabId: '', - parentId: '', format: 'object', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� - dataName: card.dataName || '', width: card.width || 24, name: card.name, subtype: card.subtype, setting: { interType: 'system' }, - wrap: { name: card.name, width: card.width || 24, title: '' }, + wrap: { name: card.name, width: card.width || 24, title: '', permission: 'true' }, style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' }, headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, subMenus: [{ @@ -63,20 +59,6 @@ }] } - if (card.config) { - let config = fromJS(card.config).toJS() - - _card.wrap = config.wrap - _card.wrap.name = card.name - _card.style = config.style - _card.headerStyle = config.headerStyle - - _card.subMenus = config.subMenus.map(item => { - item.uuid = Utils.getuuid() - - return item - }) - } this.setState({ card: _card }) @@ -86,10 +68,6 @@ card: fromJS(card).toJS() }) } - } - - componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) } shouldComponentUpdate (nextProps, nextState) { @@ -103,7 +81,6 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) } /** @@ -144,34 +121,37 @@ /** * @description 鍗曚釜鍗$墖淇℃伅鏇存柊 */ - deleteCard = (cell) => { + deleteCard = (cell, type) => { let card = fromJS(this.state.card).toJS() - let _this = this + let that = this - confirm({ - content: '纭畾鍒犻櫎鍗$墖鍚楋紵', - onOk() { - card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid) - - _this.setState({card}) - _this.props.updateConfig(card) - }, - onCancel() {} - }) + if (type !== 'direct') { + confirm({ + content: '纭畾鍒犻櫎鍗$墖鍚楋紵', + onOk() { + card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid) + + that.setState({card}) + that.props.updateConfig(card) + }, + onCancel() {} + }) + } else { + card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid) + + this.setState({card}) + this.props.updateConfig(card) + } } changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], card.style) + MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow', 'clear'], card.style, this.getStyle) } - getStyle = (comIds, style) => { - const { card } = this.state - - if (comIds.length !== 1 || comIds[0] !== card.uuid) return - - let _card = {...card, style} + getStyle = (style) => { + let _card = {...this.state.card, style} this.setState({ card: _card @@ -185,7 +165,7 @@ let newcard = { uuid: Utils.getuuid(), - setting: { type: 'menu', width: 6, sign: 'icon', icon: 'user', name: '瀹㈡埛', url: '', color: '#ffffff', iconFont: 20, padding: 12, background: '#1890ff', imgWidth: '' }, + setting: { type: 'menu', width: 6, sign: 'icon', icon: '', name: '', url: '', color: '#ffffff', iconFont: 20, padding: 12, background: '#1890ff', imgWidth: '' }, style: { paddingTop: '15px', paddingBottom: '15px' } @@ -194,12 +174,44 @@ if (card.subMenus.length > 0) { newcard = fromJS(card.subMenus.slice(-1)[0]).toJS() newcard.uuid = Utils.getuuid() + + newcard.setting.clearMenu = 'true' + newcard.setting.icon = '' + newcard.setting.name = '' + newcard.setting.MenuNo = '' + newcard.setting.type = 'menu' + newcard.setting.copyMenuId = '' + newcard.setting.linkMenuId = '' + newcard.setting.linkurl = '' + newcard.setting.tip = '' + newcard.setting.url = '' } card.subMenus.push(newcard) this.setState({card}) this.props.updateConfig(card) + + setTimeout(() => { + let node = document.getElementById(newcard.uuid) + node && node.click() + }, 200) + } + + filterComponent = (config) => { + let item = null + config.subMenus.forEach(menu => { + if (menu.setting.type === 'linkmenu' && menu.setting.linkMenuId === '') { + item = menu + } + }) + + this.updateComponent(config) + + setTimeout(() => { + let node = document.getElementById(item.uuid) + node && node.click() + }, 200) } move = (item, direction) => { @@ -244,24 +256,18 @@ clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() - MKEmitter.emit('clickComponent', this.state.card) + MKEmitter.emit('clickComponent', this.state.card.uuid, null, (style) => { + let _card = {...this.state.card} + _card.style = {..._card.style, ...style} + + this.setState({ card: _card }) + this.props.updateConfig(_card) + }) } } render() { const { card } = this.state - - let offset = 0 - if (card.wrap.cardFloat && card.wrap.cardFloat !== 'left') { - let _width = 0 - card.subMenus.forEach(card => { - _width += card.setting.width - }) - offset = _width < 24 ? 24 - _width : 0 - if (card.wrap.cardFloat === 'center') { - offset = Math.floor(offset / 2) - } - } let _style = resetStyle(card.style) @@ -275,9 +281,8 @@ <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> </NormalForm> <CopyComponent type="menubar" card={card}/> - <PasteComponent config={card} options={['menucell']} updateConfig={this.updateComponent} /> + <PasteComponent config={card} options={['menucell']} updateConfig={this.filterComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} /> - <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> {card.wrap.datatype === 'dynamic' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null} {card.wrap.datatype !== 'dynamic' ? <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/> : null} @@ -286,8 +291,9 @@ <ToolOutlined /> </Popover> <div className={(card.wrap.layout || 'grid') + '-layout'}> - {card.subMenus.map((menu, index) => (<MenuComponent key={menu.uuid} offset={!index ? offset : 0} cards={card} card={menu} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))} + {card.subMenus.map((menu, index) => (<MenuComponent key={menu.uuid} cards={card} card={menu} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))} </div> + <div className="component-name"><div className="center">{card.name}</div></div> </div> ) } -- Gitblit v1.8.0