From e9c48bd7356462ba9257540b130a47a65ad1861d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 26 八月 2021 17:17:11 +0800 Subject: [PATCH] 2021-08-26 --- src/mob/components/menubar/normal-menubar/menucomponent/index.jsx | 95 ++++++++++------------------------------------- 1 files changed, 20 insertions(+), 75 deletions(-) diff --git a/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx b/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx index b85cfd5..b09a66f 100644 --- a/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx +++ b/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx @@ -1,19 +1,17 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal, Popover, Icon, Col } from 'antd' +import { Popover, Icon, Col } from 'antd' import asyncIconComponent from '@/utils/asyncIconComponent' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import Utils from '@/utils/utils.js' -import SettingForm from './settingform' +import getSettingForm from './options' import { resetStyle } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import './index.scss' -const { confirm } = Modal const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) +const NormalForm = asyncIconComponent(() => import('@/components/normalform')) class MenuBoxComponent extends Component { static propTpyes = { @@ -26,10 +24,7 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - card: null, - formlist: null, - visible: false + card: null } UNSAFE_componentWillMount () { @@ -41,20 +36,11 @@ } componentDidMount () { - const { card } = this.props MKEmitter.addListener('submitStyle', this.getStyle) - - if (card.isnew) { - this.setState({ - visible: true - }) - } } shouldComponentUpdate (nextProps, nextState) { - const { cards } = this.props - - return !is(fromJS(cards.wrap), fromJS(nextProps.cards.wrap)) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) } /** @@ -93,43 +79,23 @@ MKEmitter.emit('changeStyle', [cards.uuid, card.uuid], options, _style) } - settingSubmit = () => { + getSettingForms = () => { const { card } = this.state - this.settingRef.handleConfirm().then(res => { - let _card = {...card, setting: res} - - if (!card.isnew && card.setting.type === 'menu' && _card.setting.type !== 'menu') { - const _this = this - confirm({ - content: '鑿滃崟灞炴�х敱鈥滆彍鍗曗�濆垏鎹㈣嚦鍏朵粬绫诲瀷鏃讹紝鑿滃崟灏嗚閲嶇疆锛屽嵆瑙i櫎涔嬪墠鑿滃崟鐨勭粦瀹氬叧绯伙紝纭畾淇敼鍚楋紵', - onOk() { - _card.uuid = Utils.getuuid() - _this.setState({ visible: false, card: _card }) - _this.props.updateElement(_card) - }, - onCancel() {} - }) - } else { - delete _card.isnew - this.setState({ visible: false, card: _card }) - this.props.updateElement(_card) - } - }) + return getSettingForm(card.setting) } - cancel = () => { + updateSetting = (res) => { const { card } = this.state + let _card = {...card, setting: res} - if (card.isnew) { - let _card = fromJS(card).toJS() - delete _card.isnew - - this.setState({ visible: false, card: _card }) - this.props.updateElement(_card) - } else { - this.setState({ visible: false }) + if (card.setting.type === 'menu' && _card.setting.type !== 'menu') { + _card.oriuuid = _card.uuid + _card.uuid = Utils.getuuid() } + + this.setState({ card: _card }) + this.props.updateElement(_card) } changeMenu = () => { @@ -148,14 +114,10 @@ } render() { - const { cards, offset } = this.props - const { card, visible, dict } = this.state + const { offset } = this.props + const { card } = this.state let _style = {...card.style} - - if (_style.shadow) { - _style.boxShadow = '0 0 4px ' + _style.shadow - } _style = resetStyle(_style) @@ -163,7 +125,9 @@ <Col span={card.setting.width || 6} offset={offset || 0}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.setState({visible: true})} /> + <NormalForm title="鑿滃崟缂栬緫" width={900} update={this.updateSetting} getForms={this.getSettingForms}> + <Icon type="edit" style={{color: '#1890ff'}} title="缂栬緫"/> + </NormalForm> <CopyComponent type="menucell" card={card}/> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ @@ -191,25 +155,6 @@ <div className="menu-name">{card.setting.name}</div> </div> </Popover> - <Modal - wrapClassName="popview-modal" - title={'鑿滃崟璁剧疆'} - visible={visible} - width={800} - maskClosable={false} - okText={dict['model.submit']} - onOk={this.settingSubmit} - onCancel={this.cancel} - destroyOnClose - > - <SettingForm - dict={dict} - cards={cards} - setting={card.setting} - inputSubmit={this.settingSubmit} - wrappedComponentRef={(inst) => this.settingRef = inst} - /> - </Modal> </Col> ) } -- Gitblit v1.8.0