From 72419e2f826031a158173f46d723a672064e37cd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 31 八月 2021 22:42:51 +0800
Subject: [PATCH] 2021-08-31

---
 src/menu/pastecontroller/index.jsx |  135 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 112 insertions(+), 23 deletions(-)

diff --git a/src/menu/pastecontroller/index.jsx b/src/menu/pastecontroller/index.jsx
index f7dc92b..2a7aebe 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
 
@@ -33,6 +35,10 @@
     } else if (Tab) {
       item.floor = Tab.floor || 1
       item.parentId = Tab.parentId
+    }
+
+    if (item.dataName) {
+      item.dataName = Utils.getdataName()
     }
 
     if (item.type === 'tabs') {
@@ -45,22 +51,57 @@
         }
 
         tab.components = tab.components.map(cell => {
-          cell = this.resetconfig(cell, tab)
+          cell = this.resetconfig(cell, tab, false, 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 === 'menubar') {
+      item.subMenus = item.subMenus.map(cell => {
+        cell.uuid = Utils.getuuid()
+        return cell
+      })
+    } else if (item.type === 'balcony') {
+      item.elements = item.elements.map(cell => {
+        cell.uuid = Utils.getuuid()
+        return cell
+      })
     } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) {
-      item.subcards.forEach(card => {
+      item.subcards && 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
           })
         }
@@ -73,11 +114,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
@@ -100,12 +136,33 @@
             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
           })
         }
         return col
+      })
+    } else if (item.type === 'form') {
+      item.subcards = item.subcards.map(cell => {
+        cell.uuid = Utils.getuuid()
+
+        cell.fields = cell.fields.map(m => {
+          m.uuid = Utils.getuuid()
+  
+          return m
+        })
+        return cell
       })
     }
 
@@ -113,9 +170,23 @@
       item.btnlog = []
     }
 
+    let oriUids = {}
     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()
+
+        oriUids[cell.uuid] = _uuid
+
+        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
       })
     }
@@ -131,6 +202,13 @@
         return cell
       })
     }
+    if (item.setting && item.setting.supModule) {
+      item.setting.supModule = ''
+    }
+    
+    if (item.wrap && item.wrap.doubleClick) {
+      item.wrap.doubleClick = oriUids[item.wrap.doubleClick] || ''
+    }
 
     return item
   }
@@ -139,16 +217,18 @@
     const { Tab } = this.props
 
     let isgroup = Tab && Tab.type === 'group' ? true : false
+    let options = ['tabs', 'datacard', 'propcard', 'mainsearch', 'balcony', 'group', 'normaltable', 'tablecard', 'line', 'bar', 'pie', 'dashboard', 'scatter']
+
+    if (sessionStorage.getItem('appType') === 'mob') {
+      options.push('menubar')
+    }
+
+    if (isgroup) {
+      options = options.filter(item => !['tabs', 'mainsearch', 'group'].includes(item))
+    }
 
     this.pasteFormRef.handleConfirm().then(res => {
-      if (!isgroup && !['tabs', 'datacard', 'propcard', 'mainsearch', 'group', 'normaltable', 'tablecard', 'line', 'bar', 'pie'].includes(res.copyType)) {
-        notification.warning({
-          top: 92,
-          message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�',
-          duration: 5
-        })
-        return
-      } else if (isgroup && !['datacard', 'propcard', 'normaltable', 'tablecard', 'line', 'bar', 'pie'].includes(res.copyType)) {
+      if (!options.includes(res.copyType)) {
         notification.warning({
           top: 92,
           message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�',
@@ -164,11 +244,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({
@@ -186,7 +275,7 @@
     return (
       <div style={{display: 'inline-block'}}>
         {type !== 'menu' ? <Icon type="snippets" style={{color: 'purple'}} onClick={() => {this.setState({visible: true})}} /> : null}
-        {type === 'menu' ? <Button type="link" style={{padding: '5px'}} icon="snippets" onClick={() => {this.setState({visible: true})}}>绮樿创</Button> : null}
+        {type === 'menu' ? <Button className="menu-config-paste" icon="snippets" onClick={() => {this.setState({visible: true})}}>绮樿创</Button> : null}
         <Modal
           title="绮樿创"
           visible={visible}

--
Gitblit v1.8.0