From f6a1ab6a58215cf7546976a86eb6face1a7be32f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 30 七月 2021 15:37:17 +0800 Subject: [PATCH] 2021-07-30 --- src/mob/components/menubar/normal-menubar/menucomponent/index.jsx | 62 ++++++++++++++++++++++-------- 1 files changed, 45 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 e900692..9c68e58 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: '鑿滃崟灞炴�х敱鈥滆彍鍗曗�濆垏鎹㈣嚦鍏朵粬绫诲瀷鏃讹紝鑿滃崟灏嗚閲嶇疆锛屽嵆瑙i櫎涔嬪墠鑿滃崟鐨勭粦瀹氬叧绯伙紝纭畾淇敼鍚楋紵', + 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 = () => { @@ -107,7 +140,6 @@ window.open(card.setting.linkurl) } else { MKEmitter.emit('changeEditMenu', { - fixed: card.setting.type === 'menu', MenuID: card.setting.type === 'linkmenu' ? card.setting.linkMenuId : card.uuid, copyMenuId: card.setting.type === 'menu' ? card.setting.copyMenuId : '', MenuNo: card.setting.MenuNo || '', @@ -121,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) @@ -168,7 +196,7 @@ maskClosable={false} okText={dict['model.submit']} onOk={this.settingSubmit} - onCancel={() => { this.setState({ visible: false }) }} + onCancel={this.cancel} destroyOnClose > <SettingForm -- Gitblit v1.8.0