king
2019-12-18 1a14ff6035932eadfb6ef7970e3adb24b4e158a6
src/tabviews/commontable/mutilform/index.jsx
@@ -9,10 +9,11 @@
class MainSearch extends Component {
  static propTpyes = {
    action: PropTypes.object, // 搜索条件列表
    dict: PropTypes.object, // 字典项
    data: PropTypes.any, // 表格数据
    configMap: PropTypes.object
    action: PropTypes.object,    // 按钮信息、表单列表
    dict: PropTypes.object,      // 字典项
    data: PropTypes.any,         // 表格数据
    configMap: PropTypes.object, // 按钮及下拉表单配置信息集
    inputSubmit: PropTypes.func  // input回车提交
  }
  state = {
@@ -22,6 +23,7 @@
  }
  componentDidMount () {
    const { data } = this.props
    let action = JSON.parse(JSON.stringify(this.props.action))
    let datatype = {}
@@ -83,12 +85,18 @@
    formlist = formlist.map(item => {
      if (item.type === 'link') {
        let supItem = formlist.filter(form => form.field === item.linkField)[0]
        if (!supItem && data && data.hasOwnProperty(item.linkField)) {
          supItem = {initval: data[item.linkField]}
        }
        if (!supItem) {
          error = true
        } else {
          item.options = item.oriOptions.filter(option => option.parentId === supItem.initval)
        }
      }
      return item
    })
@@ -104,6 +112,13 @@
      readtype: readtype,
      datatype: datatype,
      formlist: formlist
    }, () => {
      if (action.setting && action.setting.focus) {
        let _item = document.getElementById(action.setting.focus)
        if (_item) {
          _item.select()
        }
      }
    })
  }
@@ -187,14 +202,14 @@
          <Col span={24 / cols} key={index}>
            <Form.Item label={item.label}>
              {getFieldDecorator(item.field, {
                initialValue: item.initval,
                initialValue: item.initval || 'text',
                rules: [
                  {
                    required: item.required === 'true',
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)}
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)}
            </Form.Item>
          </Col>
        )
@@ -217,8 +232,8 @@
                ]
              })(
                precision === null ?
                <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} /> :
                <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} />
                <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> :
                <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />
                )}
            </Form.Item>
          </Col>
@@ -394,9 +409,9 @@
    })
  }
  handleReset = () => {
    // 重置
    this.props.form.resetFields()
  handleSubmit = (e) => {
    e.preventDefault()
    this.props.inputSubmit()
  }
  render() {