From c78051cc51032d4e29d35ca356d11d77a473eced Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 09 八月 2021 18:20:08 +0800 Subject: [PATCH] 2021-08-09 --- src/mob/components/menubar/normal-menubar/menucomponent/index.jsx | 63 +++++++++++++++++++++++-------- 1 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx b/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx index e5f35e9..aae1331 100644 --- a/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx +++ b/src/mob/components/menubar/normal-menubar/menucomponent/index.jsx @@ -6,11 +6,13 @@ 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 { 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')) class MenuBoxComponent extends Component { @@ -25,14 +27,11 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - card: null, // 鍗$墖淇℃伅锛屽寘鎷鍙嶉潰 - formlist: null, // 璁剧疆琛ㄥ崟淇℃伅 - visible: false, // 妯℃�佹鎺у埗 + card: null, + formlist: null, + visible: false } - /** - * @description 鎼滅储鏉′欢鍒濆鍖� - */ UNSAFE_componentWillMount () { const { card } = this.props @@ -42,7 +41,14 @@ } componentDidMount () { + const { card } = this.props MKEmitter.addListener('submitStyle', this.getStyle) + + if (card.isnew) { + this.setState({ + visible: true + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -91,13 +97,40 @@ const { card } = this.state this.settingRef.handleConfirm().then(res => { - this.setState({ - visible: false, - card: {...card, setting: res} - }) + let _card = {...card, setting: res} - this.props.updateElement({...card, setting: res}) + if (!card.isnew && card.setting.type === 'menu' && _card.setting.type !== 'menu') { + const _this = this + confirm({ + content: '鑿滃崟灏嗚閲嶇疆锛岀‘瀹氫慨鏀瑰悧锛�', + onOk() { + _card.oriuuid = _card.uuid + _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) + } }) + } + + cancel = () => { + const { card } = this.state + + 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 }) + } } changeMenu = () => { @@ -120,10 +153,6 @@ const { card, visible, dict } = this.state let _style = {...card.style} - - if (_style.shadow) { - _style.boxShadow = '0 0 4px ' + _style.shadow - } _style = resetStyle(_style) @@ -163,11 +192,11 @@ wrapClassName="popview-modal" title={'鑿滃崟璁剧疆'} visible={visible} - width={800} + width={900} maskClosable={false} okText={dict['model.submit']} onOk={this.settingSubmit} - onCancel={() => { this.setState({ visible: false }) }} + onCancel={this.cancel} destroyOnClose > <SettingForm -- Gitblit v1.8.0