king
2022-11-21 f6626b05f1275cc2f8ca77f773d4f6a6af1b0a89
src/menu/components/card/cardcellcomponent/index.jsx
@@ -5,7 +5,7 @@
import asyncComponent from '@/utils/asyncComponent'
import { getCardCellForm } from './formconfig'
import { getActionForm } from '@/menu/components/share/actioncomponent/formconfig'
import { getActionForm, getBaseTableActionForm } from '@/menu/components/share/actioncomponent/formconfig'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
@@ -162,6 +162,8 @@
      options = ['padding', 'margin']
    }
    options.push('clear')
    this.setState({
      card: element
    })
@@ -260,12 +262,10 @@
    if (card.eleType === 'button') {
      this.handleAction(card)
    } else {
      let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || []
      this.setState({
        visible: true,
        card: card,
        formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell, anchors)
        formlist: getCardCellForm(card, cards, cardCell)
      })
    }
  }
@@ -303,29 +303,34 @@
      }
    }
    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid, supId) || []
    let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || []
    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid, supId)
    this.setState({
      actvisible: true,
      card: card,
      formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors)
    })
    if (cards.subtype === 'basetable') {
      this.setState({
        actvisible: true,
        card: card,
        formlist: getBaseTableActionForm(card, functip, cards, usefulFields, modules)
      })
    } else {
      let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || []
      this.setState({
        actvisible: true,
        card: card,
        formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors)
      })
    }
  }
  /**
   * @description 取消保存,如果元素为新添元素,则从序列中删除
   */
  editModalCancel = () => {
    const { card, elements, appType } = this.state
    const { card, elements } = this.state
    let _elements = null
    if (card.focus) {
      _elements = elements.filter(item => item.uuid !== card.uuid)
      if (card.OpenType === 'popview' && appType !== 'mob') { // 弹窗标签按钮,从复制列表中删除
        MKEmitter.emit('delButtons', [card.uuid])
      }
    } else {
      _elements = elements
    }
@@ -408,14 +413,15 @@
   */
  handleActionSubmit = () => {
    const { elements } = this.state
    let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' }
    let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666', default: 'rgba(0, 0, 0, 0.65)' }
    this.actionFormRef.handleConfirm().then(res => {
      let _elements = elements.map(cell => {
        if (cell.uuid === res.uuid) {
          res.eleType = cell.eleType || null
          res.style = cell.style || null
          res.modal = cell.modal || null
          // res.modal = cell.modal || null
          // res.config = cell.config || null
          res.wrapStyle = cell.wrapStyle || null
          // res = {...cell, ...res}
@@ -431,13 +437,14 @@
              res.style = {}
            }
          } else if (res.class !== cell.class || res.show !== cell.show || !res.style) {
            let cl = res.class.replace('border-', '')
            let style = {}
            if (res.show === 'link' || res.show === 'icon') {
              style.color = color[res.class]
              style.color = color[cl]
              style.backgroundColor = 'transparent'
            } else {
              style.color = '#ffffff'
              style.backgroundColor = color[res.class]
              style.backgroundColor = color[cl]
            }
            res.style = {...res.style, ...style}
          }
@@ -460,30 +467,19 @@
   * @description 按钮删除
   */
  deleteElement = (card) => {
    const { cardCell, side } = this.props
    const { elements, appType } = this.state
    const { elements } = this.state
    let _this = this
    confirm({
      content: '确定删除元素吗?',
      onOk() {
        let _elements = elements.filter(item => item.uuid !== card.uuid)
        if (card.OpenType === 'popview' || card.verify || card.modal) {
          card.$parentId = cardCell.uuid
          card.$side = side || ''
        }
        _this.setState({
          elements: _elements
        }, () => {
          _this.props.updateElement(_elements)
        })
        if (card.eleType !== 'button') return
        if (appType === 'mob' || (appType === 'pc' && card.OpenType !== 'popview')) return
        MKEmitter.emit('delButtons', [card.uuid])
      },
      onCancel() {}
    })
@@ -497,7 +493,6 @@
      profVisible: true,
      card: element
    })
    MKEmitter.emit('modalStatus', '验证信息')
  }
  /**
@@ -521,8 +516,6 @@
      }, () => {
        this.props.updateElement(_elements)
      })
      MKEmitter.emit('modalStatus', false)
    })
  }
@@ -555,18 +548,18 @@
    }
  }
  handleSave = (_cards, btn, modal) => {
  handleSave = (componentId, btnId, modal) => {
    const { cards } = this.props
    const { elements } = this.state
    if (cards.uuid !== _cards.uuid) return
    if (cards.uuid !== componentId) return
    
    let _index = elements.findIndex(cell => cell.uuid === btn.uuid)
    let _index = elements.findIndex(cell => cell.uuid === btnId)
    if (_index === -1) return
    let _elements = elements.map(cell => {
      if (cell.uuid === btn.uuid) {
      if (cell.uuid === btnId) {
        cell.modal = modal
      }
@@ -743,11 +736,9 @@
              if (this.verifyRef.handleCancel) {
                this.verifyRef.handleCancel().then(() => {
                  this.setState({ profVisible: false })
                  MKEmitter.emit('modalStatus', false)
                })
              } else {
                this.setState({ profVisible: false })
                MKEmitter.emit('modalStatus', false)
              }
            }}
            destroyOnClose