king
2021-03-31 682a74e858e5a6cd24d36183931d3afafd6443d7
src/templates/zshare/modalform/index.jsx
@@ -32,7 +32,7 @@
  hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth'],
  split: ['label', 'type'],
  brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption'],
  funcvar: [],
  funcvar: ['span', 'labelwidth'],
  linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra']
}
@@ -40,6 +40,7 @@
  static propTpyes = {
    dict: PropTypes.object,    // 字典项
    formlist: PropTypes.any,
    standardform: PropTypes.any,
    card: PropTypes.object,
    inputSubmit: PropTypes.any
  }
@@ -57,7 +58,6 @@
  UNSAFE_componentWillMount () {
    let formlist = fromJS(this.props.formlist).toJS()
    let type = ''
    let resourceType = ''
    let supField = ''
@@ -364,6 +364,50 @@
    })
  }
  changeVal = (val, type) => {
    if (type !== 'span' || ![24, 12, 8, 6].includes(val)) return
    const { standardform } = this.props
    if (!standardform || ![24, 12, 8, 6].includes(standardform.span) || !standardform.labelwidth) return
    let labelwidth = null
    if (standardform.span === val) {
      labelwidth = standardform.labelwidth
    } else if (standardform.span > val) {
      labelwidth = 33.3
    } else {
      switch(standardform.span) {
        case 12:
          labelwidth = 16.2
          break;
        case 8:
          if (val === 12) {
            labelwidth = 21.6
          } else {
            labelwidth = 10.5
          }
          break;
        case 6:
          if (val === 8) {
            labelwidth = 24.3
          } else if (val === 12) {
            labelwidth = 15.8
          } else {
            labelwidth = 7.7
          }
          break;
        default:
      }
    }
    if (labelwidth) {
      this.props.form.setFieldsValue({labelwidth})
    }
  }
  handleSubmit = (e) => {
    e.preventDefault()
@@ -437,7 +481,7 @@
                      message: this.props.dict['form.required.input'] + item.label + '!'
                    }
                  ]
                })(<InputNumber min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>)}
                })(<InputNumber onChange={(value) => this.changeVal(value, item.key)} min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>)}
              </Form.Item>
            </Col>
          )