king
2022-02-08 f393af9623c26ae177a3f69b8676afc4e23bff8d
src/menu/pastecontroller/index.jsx
@@ -1,11 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Modal, Button, notification } from 'antd'
import { SnippetsOutlined } from '@ant-design/icons'
import MenuUtils from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
// import './index.scss'
const PasteForm = asyncComponent(() => import('@/templates/zshare/pasteform'))
@@ -18,20 +19,18 @@
    visible: false
  }
  handleMenuClick = () => {
    this.setState({visible: true})
  }
  resetconfig = (item, copyBtns) => {
  resetconfig = (item, copyBtns, uuids = {}) => {
    let appType = sessionStorage.getItem('appType')
    
    if (item.type === 'tabs') {
      item.uuid = MenuUtils.getuuid()
      uuids[item.uuid] = MenuUtils.getuuid()
      item.uuid = uuids[item.uuid]
      item.setting.name = item.setting.name + MenuUtils.getdataName().toUpperCase().substr(-4)
      item.name = item.setting.name
      item.subtabs.forEach(tab => {
        tab.uuid = MenuUtils.getuuid()
        uuids[tab.uuid] = MenuUtils.getuuid()
        tab.uuid = uuids[tab.uuid]
        tab.parentId = item.uuid
        if (appType !== 'mob') {
@@ -39,36 +38,35 @@
        }
        tab.components = tab.components.map(cell => {
          cell.floor = tab.floor + 1
          cell.tabId = tab.uuid
          cell.parentId = tab.parentId
          cell = this.resetconfig(cell, copyBtns)
          cell = this.resetconfig(cell, copyBtns, uuids)
          return cell
        })
      })
    } else if (item.type === 'group') {
      item.uuid = MenuUtils.getuuid()
      uuids[item.uuid] = MenuUtils.getuuid()
      item.uuid = uuids[item.uuid]
      item.setting.name = item.setting.name + MenuUtils.getdataName().toUpperCase().substr(-4)
      item.name = item.setting.name
      item.components = item.components.map(cell => {
        cell.floor = item.floor
        cell.tabId = item.tabId || ''
        cell.parentId = item.parentId || ''
        cell = MenuUtils.resetComponentConfig(cell, copyBtns)
        cell = MenuUtils.resetComponentConfig(cell, copyBtns, uuids)
        return cell
      })
    } else {
      item = MenuUtils.resetComponentConfig(item, copyBtns)
      item = MenuUtils.resetComponentConfig(item, copyBtns, uuids)
    }
    return item
  }
  pasteSubmit = () => {
    let options = ['tabs', 'menubar', 'topbar', 'datacard', 'propcard', 'mainsearch', 'stepform', 'tabform', 'balcony', 'group', 'normaltable', 'tablecard', 'line', 'bar', 'pie', 'dashboard', 'scatter']
    let options = ['tabs', 'menubar', 'topbar', 'timeline', 'datacard', 'propcard', 'mainsearch', 'stepform', 'tabform', 'balcony', 'group', 'normaltable', 'tablecard', 'line', 'bar', 'pie', 'dashboard', 'scatter']
    this.pasteFormRef.handleConfirm().then(res => {
      if ((res.copyType === 'menubar' || res.copyType === 'topbar') && sessionStorage.getItem('appType') !== 'mob') {
@@ -109,8 +107,8 @@
    const { visible } = this.state
    return (
      <div style={{display: 'inline-block'}}>
        <Button className="menu-config-paste" icon="snippets" onClick={() => {this.setState({visible: true})}}>粘贴</Button>
      <div className="mk-view-paste" style={{display: 'inline-block'}}>
        <Button style={{borderColor: '#40a9ff', color: '#40a9ff'}} onClick={() => {this.setState({visible: true})}}><SnippetsOutlined />粘贴</Button>
        <Modal
          title="粘贴"
          visible={visible}