king
2020-02-21 063b983daaf51a7f1e8677bde1e9c0e618866c91
src/tabviews/tableshare/mutilform/index.jsx
@@ -21,12 +21,27 @@
  }
  state = {
    cols: 2,
    datatype: null,
    readtype: null,
    readin: null,
    fieldlen: null,
    formlist: [],
    record: {}
  }
  UNSAFE_componentWillMount () {
    let cols = 2
    if (this.props.action.setting && this.props.action.setting.cols) {
      cols = parseInt(this.props.action.setting.cols)
      if (cols > 3 || cols < 1) {
        cols = 2
      }
    }
    this.setState({
      cols: cols
    })
  }
  componentDidMount () {
@@ -129,7 +144,7 @@
    if (error) {
      notification.warning({
        top: 92,
        message: '关联菜单设置错误!',
        message: this.props.dict['main.form.link.error'],
        duration: 10
      })
    }
@@ -151,7 +166,7 @@
            input.select()
          })
        } catch {
          console.warn('表单获取失败!')
          console.warn('focus error!')
        }
      }
    })
@@ -243,15 +258,9 @@
  getFields() {
    const { getFieldDecorator } = this.props.form
    const { cols } = this.state
    const fields = []
    let cols = 2
    if (this.props.action.setting && this.props.action.setting.cols) {
      cols = parseInt(this.props.action.setting.cols)
      if (cols > 3 || cols < 1) {
        cols = 2
      }
    }
    this.state.formlist.forEach((item, index) => {
      if ((!item.field && item.type !== 'title') || item.hidden === 'true') return
@@ -263,6 +272,26 @@
          </Col>
        )
      } else if (item.type === 'text') {
        let _max = item.fieldlength || 50
        let _rules = []
        if (item.regular) {
          if (item.regular === 'number') {
            _rules = [{
              pattern: /^[0-9]*$/ig,
              message: formRule.input.numbermsg
            }]
          } else if (item.regular === 'letter') {
            _rules = [{
              pattern: /^[a-zA-Z]*$/ig,
              message: formRule.input.lettermsg
            }]
          } else if (item.regular === 'letter&number') {
            _rules = [{
              pattern: /^[a-zA-Z0-9]*$/ig,
              message: formRule.input.letternummsg
            }]
          }
        }
        fields.push(
          <Col span={24 / cols} key={index}>
            <Form.Item label={item.label}>
@@ -274,9 +303,10 @@
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  },
                  {
                    max: formRule.input.max,
                    message: formRule.input.message
                  }
                    max: _max,
                    message: formRule.input.formMessage.replace('@max', _max)
                  },
                  ..._rules
                ]
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)}
            </Form.Item>