king
2024-12-30 81a5ae579e84d7cfe0cda268d4156d4b78a27454
src/menu/components/share/pastecomponent/index.jsx
@@ -6,6 +6,7 @@
import Utils from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
// import './index.scss'
@@ -28,7 +29,9 @@
      item.uuid = _uuid
    }
    if (item.copyType === 'cardcell' && config.subtype === 'datacard') {
    if (item.copyType === 'action') {
      MenuUtils.resetBtn(item, _uuid)
    } else if (item.copyType === 'cardcell' && config.subtype === 'datacard') {
      item.setting = item.setting || {}
      item.$cardType = 'extendCard'
      item.setting.width = item.setting.width || 6
@@ -39,6 +42,10 @@
            cell.datatype = 'static'
          }
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
@@ -48,6 +55,10 @@
            cell.datatype = 'static'
          }
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
@@ -56,54 +67,54 @@
      item.setting.width = item.setting.width || 6
      delete item.$cardType
      if (config.type === 'carousel') {
        delete item.setting.linkbtn
        delete item.backElements
      }
      if (item.elements) {
        item.elements = item.elements.map(cell => {
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
      if (item.backElements) {
        item.backElements = item.backElements.map(cell => {
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
    } else if (item.copyType === 'cols') {
      let loopCol = (col) => {
        col.subcols = col.subcols.map(c => {
          c.uuid = Utils.getuuid()
      let loopCol = (cols) => {
        return cols.map(col => {
          col.uuid = Utils.getuuid()
          if (c.type === 'colspan' && c.subcols) {
            c = loopCol(c)
          } else if (c.type === 'custom' && c.elements) {
            c.elements = c.elements.map(cell => {
          if (col.type === 'action') {
            col.type = 'custom'
          }
          if (col.type === 'colspan' && col.subcols) {
            col.subcols = loopCol(col.subcols)
          } else if (col.type === 'custom' && col.elements) {
            col.elements = col.elements.map(cell => {
              cell.uuid = Utils.getuuid()
              if (cell.eleType === 'button') {
                MenuUtils.resetBtn(cell, _uuid)
              }
              return cell
            })
          }
          return c
          return col
        })
        return col
      }
      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 => {
            cell.uuid = Utils.getuuid()
            return cell
          })
        }
        return _item
      })
      item.cols = loopCol(item.cols)
    }
    return item
@@ -123,6 +134,10 @@
        return
      }
      if (res.copyType === 'editcols') {
        res.copyType = 'cols'
      }
      let type = res.copyType
      let config = fromJS(this.props.config).toJS()
@@ -134,6 +149,10 @@
        this.setState({visible: false})
        return
      } else if (type === 'action') {
        if (res.style) {
          delete res.style.width
          delete res.style.float
        }
        if (['line', 'bar', 'scatter'].includes(config.type) && !['excelOut', 'excelIn'].includes(res.OpenType)) {
          notification.warning({ top: 92, message: '图表中不支持此类按钮!', duration: 5 })
          return
@@ -173,13 +192,29 @@
      } 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)
        if ((config.subtype === 'normaltable' || config.subtype === 'editable') && res.cols.length === 1) {
          config.cols.push(...res.cols)
        } else {
          let keys = config.cols.map(col => (col.field || '$empty'))
          let cols = []
          res.cols.forEach(col => {
            if (!col.field || !keys.includes(col.field)) {
              cols.push(col)
            }
          })
          if (cols.length === 0) {
            notification.warning({
              top: 92,
              message: '显示列已存在!',
              duration: 5
            })
            return
          } else {
            config.cols.push(...cols)
          }
        })
        }
      }
      this.props.updateConfig(config, type)