From 10e2b76a5b403c17da448d8e043c42966b14e657 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 25 七月 2021 23:46:20 +0800
Subject: [PATCH] 2021-07-25

---
 src/mob/components/menubar/normal-menubar/menucomponent/index.jsx |   56 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 12 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..b85cfd5 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,39 @@
     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.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 = () => {
@@ -167,7 +199,7 @@
           maskClosable={false}
           okText={dict['model.submit']}
           onOk={this.settingSubmit}
-          onCancel={() => { this.setState({ visible: false }) }}
+          onCancel={this.cancel}
           destroyOnClose
         >
           <SettingForm

--
Gitblit v1.8.0