From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/components/header/resetpwd/index.jsx | 47 +++++++++++++++++++++++++++++++---------------- 1 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/components/header/resetpwd/index.jsx b/src/components/header/resetpwd/index.jsx index 2f3b63a..5db93ce 100644 --- a/src/components/header/resetpwd/index.jsx +++ b/src/components/header/resetpwd/index.jsx @@ -1,15 +1,11 @@ import React, {Component} from 'react' -import PropTypes from 'prop-types' import { Form, Input } from 'antd' class Resetpwd extends Component { - static propTpyes = { - dict: PropTypes.object - } - state = { confirmDirty: false, - autoCompleteResult: [] + autoCompleteResult: [], + level: localStorage.getItem(window.location.href.split('#')[0] + 'pwdlevel') || '' } onEnterSubmit = (e) => { @@ -61,7 +57,7 @@ compareToFirstPassword = (rule, value, callback) => { const { form } = this.props if (value && value !== form.getFieldValue('password')) { - callback(this.props.dict['main.password.diff']) + callback('涓ゆ杈撳叆瀵嗙爜涓嶄竴鑷达紒') } else { callback() } @@ -69,14 +65,24 @@ validateToNextPassword = (rule, value, callback) => { const { form } = this.props + const { level } = this.state + if (value && this.state.confirmDirty) { form.validateFields(['confirm'], { force: true }) } - callback() + + if (level === 'letter_num' && value && /^[0-9a-zA-Z!@#$%^&*()_]*$/.test(value) && /^([^0-9]*|[^a-zA-Z]*)$/.test(value)) { + callback('瀵嗙爜涓繀椤诲惈鏈夋暟瀛楀拰瀛楁瘝銆�') + } else if ((level === 'char_num' || level === 'char_num_90') && value && /^[0-9a-zA-Z!@#$%^&*()_]*$/.test(value) && /^([^0-9]*|[^a-zA-Z]*|[^!@#$%^&*()_]*)$/.test(value)) { + callback('瀵嗙爜涓繀椤诲惈鏈夋暟瀛椼�佸瓧姣嶅拰鐗规畩瀛楃銆�') + } else { + callback() + } } render() { const { getFieldDecorator } = this.props.form + const { level } = this.state const formItemLayout = { labelCol: { @@ -85,36 +91,45 @@ }, wrapperCol: { xs: { span: 24 }, - sm: { span: 16 } + sm: { span: 14 } } + } + + let rules = [] + if (level) { + rules.push({ + min: 8, + message: '瀵嗙爜闀垮害涓嶅彲灏忎簬8浣嶏紒' + }) } return ( <Form {...formItemLayout} onKeyDown={this.onEnterSubmit} id="reset-password-form"> - <Form.Item label={this.props.dict['main.password.origin']}> + <Form.Item label="鍘熷瘑鐮�"> {getFieldDecorator('originpwd', { rules: [ { required: true, - message: this.props.dict['main.password.origin.required'] + message: '璇疯緭鍏ュ師瀵嗙爜锛�' } ] })(<Input.Password autoFocus/>)} </Form.Item> - <Form.Item label={this.props.dict['main.password.new']} hasFeedback> + <Form.Item label="鏂板瘑鐮�" hasFeedback> {getFieldDecorator('password', { rules: [ { required: true, - message: this.props.dict['main.password.new.required'] + message: '璇疯緭鍏ユ柊瀵嗙爜锛�' }, { pattern: /^[0-9a-zA-Z!@#$%^&*()_]*$/ig, message: '瀵嗙爜鍙厑璁稿寘鍚暟瀛椼�佸瓧姣嶄互鍙�!@#$%&*()_銆�' }, + ...rules, { max: 50, - message: this.props.dict['main.password.maxlen'] + message: '鏈�澶у瘑鐮侀暱搴︿负50浣嶏紒' }, { validator: this.validateToNextPassword @@ -122,12 +137,12 @@ ] })(<Input.Password />)} </Form.Item> - <Form.Item label={this.props.dict['main.password.confirm']} hasFeedback> + <Form.Item label="纭瀵嗙爜" hasFeedback> {getFieldDecorator('confirm', { rules: [ { required: true, - message: this.props.dict['main.password.confirm.required'] + message: '璇风‘璁ゅ瘑鐮侊紒' }, { validator: this.compareToFirstPassword -- Gitblit v1.8.0