From e543372cc70a19ff2630c79d8421c2c593e54e5f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 02 六月 2021 17:15:21 +0800
Subject: [PATCH] 2021-06-02

---
 src/components/header/resetpwd/index.jsx |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/components/header/resetpwd/index.jsx b/src/components/header/resetpwd/index.jsx
index 448aea7..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 = () => {
@@ -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

--
Gitblit v1.8.0