king
2020-01-19 b35e3f0bacdbadf5823e06fe8dc6e047089aae38
src/components/header/loginform.jsx
@@ -27,10 +27,20 @@
    })
  }
  handleSubmit = e => {
    // 登录参数检验
  handleSubmit = (e, key) => {
    e.preventDefault()
    this.props.handleSubmit()
    if (e.target.value) {
      if (!this.props.form.getFieldValue(key)) {
        const input = document.getElementById(key)
        if (input) {
          input.focus()
        }
        return
      }
      this.props.handleSubmit()
    } else {
      this.handleConfirm()
    }
  }
  componentDidMount () {
@@ -54,7 +64,7 @@
              prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
              placeholder={this.state.dict['login.username']}
              autoComplete="off"
              onPressEnter={this.handleSubmit}
              onPressEnter={(e) => {this.handleSubmit(e, 'password')}}
            />
          )}
        </Form.Item>
@@ -67,7 +77,7 @@
                message: this.state.dict['login.password.empty'],
              }
            ]
          })(<Input.Password onPressEnter={this.handleSubmit} placeholder={this.state.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
          })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder={this.state.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
        </Form.Item>
      </Form>
    )