From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 17:04:42 +0800
Subject: [PATCH] Merge branch 'master' into bms

---
 src/menu/pastecontroller/index.jsx |   77 ++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/src/menu/pastecontroller/index.jsx b/src/menu/pastecontroller/index.jsx
index e39a687..f8061f3 100644
--- a/src/menu/pastecontroller/index.jsx
+++ b/src/menu/pastecontroller/index.jsx
@@ -1,8 +1,10 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+import { fromJS } from 'immutable'
 import { Icon, Modal, Button, notification } from 'antd'
 
 import Utils from '@/utils/utils.js'
+import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
@@ -23,7 +25,7 @@
     this.setState({visible: true})
   }
 
-  resetconfig = (item, Tab, isgroup) => {
+  resetconfig = (item, Tab, isgroup, copyBtns) => {
     item.uuid = Utils.getuuid()
     item.floor = Tab ? (Tab.floor + 1) : 1
 
@@ -49,22 +51,47 @@
         }
 
         tab.components = tab.components.map(cell => {
-          cell = this.resetconfig(cell, tab)
+          cell = this.resetconfig(cell, tab, copyBtns)
           return cell
         })
+      })
+    } else if (item.type === 'group') {
+      item.components = item.components.map(cell => {
+        cell = this.resetconfig(cell, item, true, copyBtns)
+        return cell
       })
     } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) {
       item.subcards.forEach(card => {
         card.uuid = Utils.getuuid()
         if (card.elements) {
+          if (sessionStorage.getItem('editMenuType') === 'popview') {
+            card.elements = card.elements.filter(b => b.OpenType !== 'popview' && b.OpenType !== 'funcbutton')
+          }
           card.elements = card.elements.map(cell => {
-            cell.uuid = Utils.getuuid()
+            let _uuid = Utils.getuuid()
+            if (cell.OpenType === 'popview') {
+              let _cell = fromJS(cell).toJS()
+              _cell.$originUuid = _cell.uuid
+              _cell.uuid = _uuid
+              copyBtns.set(_uuid, _cell)
+            }
+            cell.uuid = _uuid
             return cell
           })
         }
         if (card.backElements) {
+          if (sessionStorage.getItem('editMenuType') === 'popview') {
+            card.elements = card.elements.filter(b => b.OpenType !== 'popview' && b.OpenType !== 'funcbutton')
+          }
           card.backElements = card.backElements.map(cell => {
-            cell.uuid = Utils.getuuid()
+            let _uuid = Utils.getuuid()
+            if (cell.OpenType === 'popview') {
+              let _cell = fromJS(cell).toJS()
+              _cell.$originUuid = _cell.uuid
+              _cell.uuid = _uuid
+              copyBtns.set(_uuid, _cell)
+            }
+            cell.uuid = _uuid
             return cell
           })
         }
@@ -77,11 +104,6 @@
           if (c.type === 'colspan' && c.subcols) {
             c = loopCol(c)
           } else if (c.type === 'custom' && c.elements) {
-            c.elements = c.elements.map(cell => {
-              cell.uuid = Utils.getuuid()
-              return cell
-            })
-          } else if (c.type === 'action' && c.elements) {
             c.elements = c.elements.map(cell => {
               cell.uuid = Utils.getuuid()
               return cell
@@ -104,8 +126,18 @@
             return cell
           })
         } else if (col.type === 'action' && col.elements) {
+          if (sessionStorage.getItem('editMenuType') === 'popview') {
+            col.elements = col.elements.filter(c => c.OpenType !== 'popview' && c.OpenType !== 'funcbutton')
+          }
           col.elements = col.elements.map(cell => {
-            cell.uuid = Utils.getuuid()
+            let _uuid = Utils.getuuid()
+            if (cell.OpenType === 'popview') {
+              let _cell = fromJS(cell).toJS()
+              _cell.$originUuid = _cell.uuid
+              _cell.uuid = _uuid
+              copyBtns.set(_uuid, _cell)
+            }
+            cell.uuid = _uuid
             return cell
           })
         }
@@ -118,8 +150,18 @@
     }
 
     if (item.action) {
+      if (sessionStorage.getItem('editMenuType') === 'popview') {
+        item.action = item.action.filter(c => c.OpenType !== 'popview' && c.OpenType !== 'funcbutton')
+      }
       item.action = item.action.map(cell => {
-        cell.uuid = Utils.getuuid()
+        let _uuid = Utils.getuuid()
+        if (cell.OpenType === 'popview') {
+          let _cell = fromJS(cell).toJS()
+          _cell.$originUuid = _cell.uuid
+          _cell.uuid = _uuid
+          copyBtns.set(_uuid, _cell)
+        }
+        cell.uuid = _uuid
         return cell
       })
     }
@@ -168,11 +210,20 @@
         return
       }
 
-      res = this.resetconfig(res, Tab, isgroup)
+      let copyBtns = new Map()
+
+      res = this.resetconfig(res, Tab, isgroup, copyBtns)
 
       delete res.copyType
-
+      
       this.props.insert(res, Tab)
+
+      copyBtns = [...copyBtns.values()]
+
+      if (copyBtns.length > 0) {
+        MKEmitter.emit('copyButtons', copyBtns)
+      }
+
       this.setState({visible: false})
 
       notification.success({

--
Gitblit v1.8.0