king
2022-11-21 89f85223ff7b1b5ee3931ae01efa3dd17d5524fc
src/menu/components/card/data-card/index.jsx
@@ -140,10 +140,6 @@
    }
  }
  componentDidMount () {
    MKEmitter.addListener('submitModal', this.handleSave)
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
@@ -155,7 +151,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitModal', this.handleSave)
  }
  /**
@@ -281,7 +276,6 @@
   * @description 单个卡片信息更新
   */
  deleteCard = (cell) => {
    const { appType } = this.state
    let card = fromJS(this.state.card).toJS()
    let _this = this
@@ -291,25 +285,6 @@
        card.subcards = card.subcards.filter(item => item.uuid !== cell.uuid)
        _this.updateComponent(card)
        if (appType === 'mob') return
        let uuids = []
        cell.elements && cell.elements.forEach(c => {
          if (c.eleType !== 'button' || (appType === 'pc' && c.OpenType !== 'popview')) return
          uuids.push(c.uuid)
        })
        cell.backElements && cell.backElements.forEach(c => {
          if (c.eleType !== 'button' || (appType === 'pc' && c.OpenType !== 'popview')) return
          uuids.push(c.uuid)
        })
        if (uuids.length === 0) return
        MKEmitter.emit('delButtons', uuids)
      },
      onCancel() {}
    })
@@ -318,7 +293,7 @@
  changeStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', ['background', 'height', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle)
    MKEmitter.emit('changeStyle', ['background', 'height', 'border', 'padding', 'margin', 'shadow', 'clear'], card.style, this.getStyle)
  }
  getStyle = (style) => {
@@ -401,26 +376,6 @@
    } else if (btn.OpenType === 'popview' && appType !== 'mob') {
      MKEmitter.emit('changePopview', card, btn)
    }
  }
  handleSave = (_cards, btn, modal) => {
    let card = fromJS(this.state.card).toJS()
    if (card.uuid !== _cards.uuid) return
    let _index = card.action.findIndex(cell => cell.uuid === btn.uuid)
    if (_index === -1) return
    card.action = card.action.map(cell => {
      if (cell.uuid === btn.uuid) {
        cell.modal = modal
      }
      return cell
    })
    this.updateComponent(card)
  }
  addCard = (copy) => {
@@ -537,7 +492,6 @@
      res.$cardType = 'extendCard'
      res.setting.width = res.setting.width || 6
      let copyBtns = []
      let mobtypes = ['pop', 'prompt', 'exec', 'innerpage', 'funcbutton']
      let elements = []
@@ -552,16 +506,7 @@
        } else if (appType === 'mob' && !mobtypes.includes(cell.OpenType)) {
          return
        } else {
          let _uuid = Utils.getuuid()
          if (cell.OpenType === 'popview') {
            let _cell = fromJS(cell).toJS()
            _cell.$originUuid = _cell.uuid
            _cell.uuid = _uuid
            copyBtns.push(_cell)
          }
          cell.uuid = _uuid
          cell.uuid = Utils.getuuid()
          elements.push(cell)
        }
      })
@@ -582,26 +527,13 @@
          } else if (appType === 'mob' && !mobtypes.includes(cell.OpenType)) {
            return
          } else {
            let _uuid = Utils.getuuid()
            if (cell.OpenType === 'popview') {
              let _cell = fromJS(cell).toJS()
              _cell.$originUuid = _cell.uuid
              _cell.uuid = _uuid
              copyBtns.push(_cell)
            }
            cell.uuid = _uuid
            cell.uuid = Utils.getuuid()
            backElements.push(cell)
          }
        })
      }
      res.backElements = backElements
      if (copyBtns.length > 0) {
        MKEmitter.emit('copyButtons', copyBtns)
      }
      resolve({status: true})
@@ -638,19 +570,9 @@
      if (appType === 'mob' && !['pop', 'prompt', 'exec', 'innerpage'].includes(res.OpenType)) {
        resolve({status: false, message: '移动端不支持此类型的按钮。'})
      } else {
        let _uuid = Utils.getuuid()
        if (res.OpenType === 'popview') {
          let _cell = fromJS(res).toJS()
          _cell.$originUuid = _cell.uuid
          _cell.uuid = _uuid
          MKEmitter.emit('copyButtons', [_cell])
        }
        resolve({status: true})
    
        res.uuid = _uuid
        res.uuid = Utils.getuuid()
        this.addButton(res)
      }
    }