king
2025-03-21 fdce913ce7b9d55c34a2abd7a94ee377a4869b9a
src/menu/components/share/pastecomponent/index.jsx
@@ -6,9 +6,11 @@
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'
const { confirm } = Modal
const PasteForm = asyncComponent(() => import('@/templates/zshare/pasteform'))
class PasteController extends Component {
@@ -28,7 +30,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 +43,10 @@
            cell.datatype = 'static'
          }
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
@@ -48,6 +56,10 @@
            cell.datatype = 'static'
          }
          cell.uuid = Utils.getuuid()
          if (cell.eleType === 'button') {
            MenuUtils.resetBtn(cell, _uuid)
          }
          return cell
        })
      }
@@ -64,12 +76,18 @@
      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
        })
      }
@@ -87,6 +105,9 @@
          } 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
            })
          }
@@ -100,9 +121,44 @@
    return item
  }
  extra = (res) => {
    let config = fromJS(this.props.config).toJS()
    if (res.copyType === 'mk_actions') {
      config.action = res.action
      this.props.updateConfig(config)
      setTimeout(() => {
        MKEmitter.emit('revertBtn', config.uuid)
      }, 30)
    } else if (res.copyType === 'mk_searches') {
      config.search = res.search
      this.props.updateConfig(config)
      setTimeout(() => {
        MKEmitter.emit('revert', config.uuid, 'search')
      }, 30)
    } else if (res.copyType === 'mk_fields') {
      config.columns = res.columns
      this.props.updateConfig(config)
    } else if (res.copyType === 'mk_cols') {
      config.cols = res.cols
      this.props.updateConfig(config)
    } else if (res.copyType === 'mk_setting') {
      config.setting = res.setting
      this.props.updateConfig(config)
    }
    console.log(config)
    this.setState({visible: false})
  }
  pasteSubmit = () => {
    const { options } = this.props
    this.pasteFormRef.handleConfirm().then(res => {
      if (/^mk_/.test(res.copyType)) { // dms-trans
        this.extra(res)
        return
      }
      if (!options.includes(res.copyType)) {
        notification.warning({ top: 92, message: '配置信息格式错误!', duration: 5 })
        return
@@ -112,6 +168,10 @@
        this.props.updateConfig(res)
        this.setState({visible: false})
        return
      }
      if (res.copyType === 'editcols') {
        res.copyType = 'cols'
      }
      let type = res.copyType
@@ -149,17 +209,20 @@
          }
        }
        if (res.field && keys.includes(res.field.toLowerCase())) {
          notification.warning({
            top: 92,
            message: '搜索字段已存在!',
            duration: 5
          })
          return
        }
        MKEmitter.emit('plusSearch', config.uuid, res, 'simple')
        this.setState({visible: false})
        if (res.field && keys.includes(res.field.toLowerCase())) {
          confirm({
            title: '搜索字段已存在!',
            okText: '知道了',
            cancelText: '替换',
            onOk() {},
            onCancel() {
              MKEmitter.emit('plusSearch', config.uuid, res, 'replace')
            }
          })
        } else {
          MKEmitter.emit('plusSearch', config.uuid, res, 'simple')
        }
        return
      } else if (type === 'cardcell') {
        config.subcards.push(res)
@@ -168,24 +231,28 @@
      } else if (type === 'cols') {
        config.cols = config.cols.filter(col => !col.origin)
        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
        if ((config.subtype === 'normaltable' || config.subtype === 'editable') && res.cols.length === 1) {
          config.cols.push(...res.cols)
        } else {
          config.cols.push(...cols)
          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)
          }
        }
      }