king
2022-09-16 66cc7818cf5e13c44f4372e7d47fb72df7d2f752
src/menu/components/card/cardcellcomponent/index.jsx
@@ -68,19 +68,16 @@
  componentDidMount () {
    MKEmitter.addListener('submitModal', this.handleSave)
    MKEmitter.addListener('cardAddElement', this.cardAddElement)
    MKEmitter.addListener('cardDelElement', this.cardDelElement)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props.cards), fromJS(nextProps.cards)) || !is(fromJS(this.state), fromJS(nextState))
    return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props.cards), fromJS(nextProps.cards))
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    if (this.props.side !== nextProps.side) {
      this.setState({
        elements: fromJS(nextProps.elements).toJS()
      })
    } else if (!is(fromJS(this.props.elements), fromJS(nextProps.elements)) && nextProps.elements.length !== this.state.elements.length) {
      this.setState({
        elements: fromJS(nextProps.elements).toJS()
      })
@@ -96,13 +93,14 @@
    }
    MKEmitter.removeListener('submitModal', this.handleSave)
    MKEmitter.removeListener('cardAddElement', this.cardAddElement)
    MKEmitter.removeListener('cardDelElement', this.cardDelElement)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
  }
  updateComponentStyle = (parentId, keys, style) => {
    const { cardCell } = this.props
    if (!cardCell || cardCell.uuid !== parentId) return
    if (cardCell.uuid !== parentId) return
    const { elements } = this.state
@@ -120,10 +118,18 @@
    })
  }
  cardAddElement = (ids, element) => {
    const { cards, cardCell } = this.props
  cardDelElement = (id, eleId) => {
    const { cardCell } = this.props
    if (!ids || ids.length !== 2 || ids[0] !== cards.uuid || ids[1] !== cardCell.uuid) return
    if (id !== cardCell.uuid) return
    this.setState({elements: this.state.elements.filter(item => item.uuid !== eleId)})
  }
  cardAddElement = (id, element) => {
    const { cardCell } = this.props
    if (id !== cardCell.uuid) return
    if (window.GLOB.$lock) return
    window.GLOB.$lock = true
@@ -194,12 +200,17 @@
  resetCardStyle = (card, style) => {
    let _card = fromJS(card).toJS()
    
    if (['text', 'number', 'formula'].includes(_card.eleType)) {
    if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(_card.eleType)) {
      _card.style = style
      let line = _card.height || null
      if (['currentDate', 'sequence', 'icon'].includes(_card.eleType)) {
        line = 1
      }
      if (line) {
      let fontSize = 14
      let lineHeight = 1.5
      let line = _card.height || null
      if (_card.style.fontSize) {
        fontSize = parseInt(_card.style.fontSize)
@@ -208,20 +219,10 @@
        lineHeight = parseFloat(_card.style.lineHeight)
      }
      if (line) {
        _card.innerHeight = fontSize * lineHeight * line
      } else {
        _card.innerHeight = 'auto'
      }
    } else if (_card.eleType === 'sequence') {
      _card.style = style
      let fontSize = 14
      let lineHeight = 1.5
      if (_card.style.fontSize) {
        fontSize = parseInt(_card.style.fontSize)
      }
      _card.innerHeight = fontSize * lineHeight
    } else if (_card.eleType === 'barcode') {
      _card.style = style
@@ -323,7 +324,7 @@
    this.setState({
      actvisible: true,
      card: card,
      formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules, anchors)
      formlist: getActionForm(card, functip, cards, usefulFields, menulist, modules, anchors)
    })
  }
@@ -364,13 +365,19 @@
      let _elements = elements.map(cell => {
        if (cell.uuid === res.uuid) {
          res.style = cell.style || {}
          if (res.eleType === 'splitline' && cell.eleType !== 'splitline') {
          if (res.eleType === 'splitline' && (cell.eleType !== 'splitline' || cell.focus)) {
            res.style.paddingTop = '5px'
            res.style.paddingBottom = '5px'
          } else if (['text', 'number', 'formula'].includes(res.eleType)) {
          } else if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(res.eleType)) {
            let line = res.height || null
            if (['currentDate', 'sequence', 'icon'].includes(res.eleType)) {
              line = 1
            }
            if (line) {
            let fontSize = 14
            let lineHeight = 1.5
            let line = res.height || null
      
            if (res.style && res.style.fontSize) {
              fontSize = parseInt(res.style.fontSize)
@@ -379,8 +386,9 @@
              lineHeight = parseFloat(res.style.lineHeight)
            }
            if (line) {
              res.innerHeight = fontSize * lineHeight * line
            } else {
              res.innerHeight = 'auto'
            }
            if (res.eleType === 'text' && res.link && !res.style.color) {
@@ -605,9 +613,10 @@
  }
  dropButton = (id) => {
    const { cards } = this.props
    const { cards, cardCell } = this.props
    if (!cards.action) return
    if (cardCell.type === 'custom') return
    let index = cards.action.findIndex(item => item.uuid === id)
@@ -690,7 +699,7 @@
      <div className="model-menu-card-cell-list">
        <DragElement
          list={elements}
          parent={{...cardCell, components: elements}}
          parent={cardCell}
          fields={cards.columns}
          updateMarks={this.updateMarks}
          handleList={this.handleList}