king
2020-02-21 063b983daaf51a7f1e8677bde1e9c0e618866c91
src/tabviews/tableshare/mutilform/index.jsx
@@ -21,6 +21,7 @@
  }
  state = {
    cols: 2,
    datatype: null,
    readtype: null,
    readin: null,
@@ -29,10 +30,24 @@
    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 () {
    const { data, BData } = this.props
    let action = JSON.parse(JSON.stringify(this.props.action))
    let datatype = {}
    let readtype = {}
    let readin = {}
@@ -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>
@@ -570,63 +600,25 @@
          })
          Object.keys(values).forEach(key => {
            let _value = ''
            if (this.state.datatype[key] === 'datetime') {
              let _value = ''
              if (values[key]) {
                _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss')
              }
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: _value
              })
            } else if (this.state.datatype[key] === 'datemonth') {
              let _value = ''
              if (values[key]) {
                _value = moment(values[key]).format('YYYY-MM')
              }
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: _value
              })
            } else if (this.state.datatype[key] === 'date') {
              let _value = ''
              if (values[key]) {
                _value = moment(values[key]).format('YYYY-MM-DD')
              }
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: _value
              })
            } else if (this.state.datatype[key] === 'number') {
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: values[key]
              })
              _value = values[key]
            } else if (this.state.datatype[key] === 'multiselect') {
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: values[key] ? values[key].join(',') : ''
              })
              _value = values[key] ? values[key].join(',') : ''
            } else if (this.state.datatype[key] === 'fileupload') {
              let vals = []
@@ -640,33 +632,23 @@
                })
              }
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: vals.join(',')
              })
              _value = vals.join(',')
            } else if (this.state.datatype[key] === 'text') {
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '')
              })
              _value = values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '')
            } else {
              search.push({
                type: this.state.datatype[key],
                readonly: this.state.readtype[key],
                readin: this.state.readin[key],
                fieldlen: this.state.fieldlen[key],
                key: key,
                value: values[key]
              })
              _value = values[key]
            }
            search.push({
              type: this.state.datatype[key],
              readonly: this.state.readtype[key],
              readin: this.state.readin[key],
              fieldlen: this.state.fieldlen[key],
              key: key,
              value: _value
            })
          })
          resolve(search)