From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 17:04:42 +0800
Subject: [PATCH] Merge branch 'master' into bms

---
 src/components/header/resetpwd/index.jsx |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/components/header/resetpwd/index.jsx b/src/components/header/resetpwd/index.jsx
index ac9eaed..2f3b63a 100644
--- a/src/components/header/resetpwd/index.jsx
+++ b/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 = () => {
@@ -68,7 +90,7 @@
     }
 
     return (
-      <Form {...formItemLayout} onKeyDown={this.onEnterSubmit}>
+      <Form {...formItemLayout} onKeyDown={this.onEnterSubmit} id="reset-password-form">
         <Form.Item label={this.props.dict['main.password.origin']}>
           {getFieldDecorator('originpwd', {
             rules: [
@@ -77,7 +99,7 @@
                 message: this.props.dict['main.password.origin.required']
               }
             ]
-          })(<Input.Password />)}
+          })(<Input.Password autoFocus/>)}
         </Form.Item>
         <Form.Item label={this.props.dict['main.password.new']} hasFeedback>
           {getFieldDecorator('password', {

--
Gitblit v1.8.0