king
2021-01-14 3cbad93c94c39730e45600efeabdfebcd424c2cc
src/menu/components/share/pastecomponent/index.jsx
@@ -4,6 +4,7 @@
import { Icon, Modal, notification } from 'antd'
import Utils from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
@@ -23,8 +24,19 @@
    this.setState({visible: true})
  }
  resetconfig = (item) => {
    item.uuid = Utils.getuuid()
  resetconfig = (item, copyBtns) => {
    let _uuid = Utils.getuuid()
    if (item.OpenType === 'popview') {
      let _cell = fromJS(item).toJS()
      _cell.$originUuid = _cell.uuid
      _cell.uuid = _uuid
      copyBtns.set(_uuid, _cell)
    }
    if (item.uuid) {
      item.uuid = _uuid
    }
    if (item.copyType === 'cardcell') {
      item.setting = item.setting || {}
@@ -42,7 +54,7 @@
          return cell
        })
      }
    } else if (item.copyType === 'table') {
    } else if (item.copyType === 'cols') {
      let loopCol = (col) => {
        col.subcols = col.subcols.map(c => {
          c.uuid = Utils.getuuid()
@@ -54,11 +66,6 @@
              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
            })
          }
          return c
        })
@@ -66,19 +73,30 @@
        return col
      }
      if (item.type === 'colspan' && item.subcols) {
        item = loopCol(item)
      } else if (item.type === 'custom' && item.elements) {
        item.elements = item.elements.map(cell => {
          cell.uuid = Utils.getuuid()
          return cell
        })
      } else if (item.type === 'action' && item.elements) {
        item.elements = item.elements.map(cell => {
          cell.uuid = Utils.getuuid()
          return cell
        })
      }
      item.cols = item.cols.map(_item => {
        _item.uuid = Utils.getuuid()
        if (_item.type === 'colspan' && _item.subcols) {
          _item = loopCol(_item)
        } else if (_item.type === 'custom' && _item.elements) {
          _item.elements = _item.elements.map(cell => {
            cell.uuid = Utils.getuuid()
            return cell
          })
        } else if (_item.type === 'action' && _item.elements) {
          _item.elements = _item.elements.map(cell => {
            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 _item
      })
    }
    return item
@@ -98,15 +116,22 @@
      let type = res.copyType
      let config = fromJS(this.props.config).toJS()
      let copyBtns = new Map()
      res = this.resetconfig(res)
      res = this.resetconfig(res, copyBtns)
      delete res.copyType
      copyBtns = [...copyBtns.values()]
      if (copyBtns.length > 0) {
        MKEmitter.emit('copyButtons', copyBtns)
      }
      if (type === 'action') {
        config.action = config.action || []
        config.action = config.action.filter(item => !item.origin)
        config.action.push(res)
        MKEmitter.emit('addButton', config.uuid, res)
      } else if (type === 'search' || type === 'form') {
        config.search = config.search || []
        config.search = config.search.filter(item => !item.origin)
@@ -137,6 +162,16 @@
        config.search.push(res)
      } else if (type === 'cardcell') {
        config.subcards.push(res)
      } else if (type === 'cols') {
        config.cols = config.cols.filter(col => !col.origin)
        let keys = config.cols.map(col => (col.field || '$empty'))
        res.cols.forEach(col => {
          if (!keys.includes(col.field)) {
            config.cols.push(col)
          }
        })
      }
      this.props.updateConfig(config)