king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/menu/components/card/cardcellcomponent/index.jsx
@@ -34,6 +34,7 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    appType: sessionStorage.getItem('appType'),
    card: null,          // 编辑中元素
    formlist: null,      // 表单信息
    elements: null,      // 按钮组
@@ -63,9 +64,9 @@
  }
  componentDidMount () {
    MKEmitter.addListener('cardAddElement', this.cardAddElement)
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('submitModal', this.handleSave)
    MKEmitter.addListener('cardAddElement', this.cardAddElement)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
  }
@@ -92,9 +93,9 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('cardAddElement', this.cardAddElement)
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('submitModal', this.handleSave)
    MKEmitter.removeListener('cardAddElement', this.cardAddElement)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
  }
@@ -160,6 +161,12 @@
    if (comIds.length !== 3 || comIds[0] !== cards.uuid || comIds[1] !== cardCell.uuid || !card) return
    if (card.eleType === 'button') {
      if ((style.paddingLeft || style.paddingRight) && !style.width) {
        style.width = 'auto'
      }
    }
    let _card = this.resetCardStyle(card, style)
    let _elements = elements.map(cell => {
@@ -177,7 +184,7 @@
  resetCardStyle = (card, style) => {
    let _card = fromJS(card).toJS()
    
    if (_card.eleType === 'text' || _card.eleType === 'number') {
    if (['text', 'number', 'formula'].includes(_card.eleType)) {
      _card.style = style
      let fontSize = 14
@@ -260,7 +267,7 @@
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch {
      } catch (e) {
        usefulFields = []
      }
    } else {
@@ -276,7 +283,7 @@
    if (menulist) {
      try {
        menulist = JSON.parse(menulist)
      } catch {
      } catch (e) {
        menulist = []
      }
    } else {
@@ -296,11 +303,15 @@
   * @description 取消保存,如果元素为新添元素,则从序列中删除
   */
  editModalCancel = () => {
    const { card, elements } = this.state
    const { card, elements, appType } = 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
    }
@@ -310,6 +321,8 @@
      elements: _elements,
      visible: false,
      actvisible: false
    }, () => {
      this.props.updateElement(_elements)
    })
  }
@@ -327,7 +340,7 @@
          if (res.eleType === 'splitline' && cell.eleType !== 'splitline') {
            res.style.paddingTop = '5px'
            res.style.paddingBottom = '5px'
          } else if (res.eleType === 'text' || res.eleType === 'number') {
          } else if (['text', 'number', 'formula'].includes(res.eleType)) {
            let fontSize = 14
            let lineHeight = 1.5
            let line = res.height || null
@@ -414,17 +427,14 @@
   */
  deleteElement = (card) => {
    const { cards, cardCell, side } = this.props
    const { dict, elements } = this.state
    const { dict, elements, appType } = this.state
    let _this = this
    confirm({
      content: dict['model.confirm'] + dict['model.delete'] + '元素吗?',
      onOk() {
        let _elements = elements.filter(item => item.uuid !== card.uuid)
        if (card.eleType === 'button') {
          MKEmitter.emit('delButtons', [card.uuid])
        }
        if (card.OpenType === 'popview' || card.verify || card.modal) {
          card.$parentId = cardCell.uuid
          card.$side = side || ''
@@ -437,6 +447,11 @@
        }, () => {
          _this.props.updateElement(_elements)
        })
        if (card.eleType !== 'button') return
        if (appType === 'mob' || (appType === 'pc' && card.OpenType !== 'popview')) return
        MKEmitter.emit('delButtons', [card.uuid])
      },
      onCancel() {}
    })
@@ -501,6 +516,8 @@
        MKEmitter.emit('changeEditMenu', {MenuID: btn.uuid, copyMenuId: btn.copyMenuId})
      } else if (btn.OpenType === 'innerpage' && btn.pageTemplate === 'linkpage') {
        MKEmitter.emit('changeEditMenu', {MenuID: btn.linkmenu})
      } else {
        this.handleElement(item)
      }
    } else {
      if (btn.link === 'page') {
@@ -592,94 +609,96 @@
          handleSubConfig={this.handleSubConfig}
          deleteMenu={this.deleteElement}
        />
        {/* 编辑按钮:复制、编辑 */}
        <Modal
          title={'编辑元素'}
          visible={visible}
          width={800}
          maskClosable={false}
          onCancel={this.editModalCancel}
          onOk={this.handleSubmit}
          destroyOnClose
        >
          <ElementForm
            dict={dict}
            card={card}
            formlist={this.state.formlist}
            inputSubmit={this.handleSubmit}
            config={cards}
            wrappedComponentRef={(inst) => this.elementFormRef = inst}
          />
        </Modal>
        {/* 编辑按钮:复制、编辑 */}
        <Modal
          title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])}
          visible={actvisible}
          width={800}
          maskClosable={false}
          onCancel={this.editModalCancel}
          footer={[
            <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>,
            <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>{dict['model.confirm']}</Button>
          ]}
          destroyOnClose
        >
          <ActionForm
            dict={dict}
            type={cards.type === 'balcony' ? '' : 'card'}
            card={card}
            formlist={this.state.formlist}
            inputSubmit={this.handleActionSubmit}
            setting={cards.setting}
            wrappedComponentRef={(inst) => this.actionFormRef = inst}
          />
        </Modal>
        {/* 按钮使用系统存储过程时,验证信息模态框 */}
        <Modal
          wrapClassName="model-table-action-verify-modal"
          title={'验证信息'}
          visible={profVisible}
          width={'75vw'}
          maskClosable={false}
          okText={dict['model.submit']}
          onOk={this.verifySubmit}
          onCancel={() => { this.setState({ profVisible: false }) }}
          destroyOnClose
        >
          {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ?
            <VerifyCard
              card={card}
        <div onDoubleClick={(e) => e.stopPropagation()}>
          {/* 编辑按钮:复制、编辑 */}
          <Modal
            title={'编辑元素'}
            visible={visible}
            width={800}
            maskClosable={false}
            onCancel={this.editModalCancel}
            onOk={this.handleSubmit}
            destroyOnClose
          >
            <ElementForm
              dict={dict}
              card={card}
              formlist={this.state.formlist}
              inputSubmit={this.handleSubmit}
              config={cards}
              columns={cards.columns}
              wrappedComponentRef={(inst) => this.verifyRef = inst}
            /> : null
          }
          {card && card.execMode ?
            <VerifyPrint
              card={card}
              wrappedComponentRef={(inst) => this.elementFormRef = inst}
            />
          </Modal>
          {/* 编辑按钮:复制、编辑 */}
          <Modal
            title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])}
            visible={actvisible}
            width={800}
            maskClosable={false}
            onCancel={this.editModalCancel}
            footer={[
              <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>,
              <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>{dict['model.confirm']}</Button>
            ]}
            destroyOnClose
          >
            <ActionForm
              dict={dict}
              columns={cards.columns}
              wrappedComponentRef={(inst) => this.verifyRef = inst}
            /> : null
          }
          {card && card.OpenType === 'excelIn' ?
            <VerifyExcelIn
              type={cards.type === 'balcony' ? '' : 'card'}
              card={card}
              dict={dict}
              columns={cards.columns}
              wrappedComponentRef={(inst) => this.verifyRef = inst}
            /> : null
          }
          {card && card.OpenType === 'excelOut' ?
            <VerifyExcelOut
              card={card}
              dict={dict}
              config={cards}
              wrappedComponentRef={(inst) => this.verifyRef = inst}
            /> : null
          }
        </Modal>
              formlist={this.state.formlist}
              inputSubmit={this.handleActionSubmit}
              setting={cards.setting}
              wrappedComponentRef={(inst) => this.actionFormRef = inst}
            />
          </Modal>
          {/* 按钮使用系统存储过程时,验证信息模态框 */}
          <Modal
            wrapClassName="model-table-action-verify-modal"
            title={'验证信息'}
            visible={profVisible}
            width={'75vw'}
            maskClosable={false}
            okText={dict['model.submit']}
            onOk={this.verifySubmit}
            onCancel={() => { this.setState({ profVisible: false }) }}
            destroyOnClose
          >
            {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ?
              <VerifyCard
                card={card}
                dict={dict}
                config={cards}
                columns={cards.columns}
                wrappedComponentRef={(inst) => this.verifyRef = inst}
              /> : null
            }
            {card && card.execMode ?
              <VerifyPrint
                card={card}
                dict={dict}
                columns={cards.columns}
                wrappedComponentRef={(inst) => this.verifyRef = inst}
              /> : null
            }
            {card && card.OpenType === 'excelIn' ?
              <VerifyExcelIn
                card={card}
                dict={dict}
                columns={cards.columns}
                wrappedComponentRef={(inst) => this.verifyRef = inst}
              /> : null
            }
            {card && card.OpenType === 'excelOut' ?
              <VerifyExcelOut
                card={card}
                dict={dict}
                config={cards}
                wrappedComponentRef={(inst) => this.verifyRef = inst}
              /> : null
            }
          </Modal>
        </div>
      </div>
    )
  }