king
2021-06-02 e543372cc70a19ff2630c79d8421c2c593e54e5f
src/components/header/resetpwd/index.jsx
@@ -15,7 +15,29 @@
  onEnterSubmit = (e) => {
    // 表单回车提交
    if (e.key !== 'Enter') return
    this.props.resetPwdSubmit()
    if (!this.props.form.getFieldValue('originpwd')) {
      this.focusInput('originpwd')
    } else if (!this.props.form.getFieldValue('password')) {
      this.focusInput('password')
    } else if (!this.props.form.getFieldValue('confirm')) {
      this.focusInput('confirm')
    } else {
      this.props.resetPwdSubmit()
    }
  }
  focusInput = (selectId) => {
    let _form = document.getElementById('reset-password-form')
    let _inputs = _form.getElementsByTagName('input')
    _inputs = [..._inputs]
    _inputs.forEach(input => {
      if (!input || input.id !== selectId) return
      if (input.focus) {
        input.focus()
      }
    })
  }
  handleConfirm = () => {
@@ -39,7 +61,7 @@
  compareToFirstPassword = (rule, value, callback) => {
    const { form } = this.props
    if (value && value !== form.getFieldValue('password')) {
      callback(this.props.dict['header.password.diff'])
      callback(this.props.dict['main.password.diff'])
    } else {
      callback()
    }
@@ -68,31 +90,31 @@
    }
    return (
      <Form {...formItemLayout} onKeyDown={this.onEnterSubmit}>
        <Form.Item label={this.props.dict['header.password.origin']}>
      <Form {...formItemLayout} onKeyDown={this.onEnterSubmit} id="reset-password-form">
        <Form.Item label={this.props.dict['main.password.origin']}>
          {getFieldDecorator('originpwd', {
            rules: [
              {
                required: true,
                message: this.props.dict['header.password.origin.required']
                message: this.props.dict['main.password.origin.required']
              }
            ]
          })(<Input.Password />)}
          })(<Input.Password autoFocus/>)}
        </Form.Item>
        <Form.Item label={this.props.dict['header.password.new']} hasFeedback>
        <Form.Item label={this.props.dict['main.password.new']} hasFeedback>
          {getFieldDecorator('password', {
            rules: [
              {
                required: true,
                message: this.props.dict['header.password.new.required']
                message: this.props.dict['main.password.new.required']
              },
              {
                min: 6,
                message: this.props.dict['header.password.minlen']
                pattern: /^[0-9a-zA-Z!@#$%^&*()_]*$/ig,
                message: '密码只允许包含数字、字母以及!@#$%&*()_。'
              },
              {
                max: 12,
                message: this.props.dict['header.password.maxlen']
                max: 50,
                message: this.props.dict['main.password.maxlen']
              },
              {
                validator: this.validateToNextPassword
@@ -100,12 +122,12 @@
            ]
          })(<Input.Password />)}
        </Form.Item>
        <Form.Item label={this.props.dict['header.password.confirm']} hasFeedback>
        <Form.Item label={this.props.dict['main.password.confirm']} hasFeedback>
          {getFieldDecorator('confirm', {
            rules: [
              {
                required: true,
                message: this.props.dict['header.password.confirm.required']
                message: this.props.dict['main.password.confirm.required']
              },
              {
                validator: this.compareToFirstPassword