From 58aebf343084d71f0db27287c645c14400f8cb6d Mon Sep 17 00:00:00 2001
From: wl <173@qq.com>
Date: 星期二, 20 十二月 2022 17:44:04 +0800
Subject: [PATCH] fix:密码校验
---
src/views/layout/components/Header/updatePassword/index.vue | 67 ++++++++++-----------
src/views/systemSetting/baseSetting/user/components/password/index.vue | 37 +++++------
src/views/systemSetting/baseSetting/user/components/createUser/index.vue | 16 ++---
src/views/systemSetting/platform/cockpitManage/index.vue | 4
4 files changed, 57 insertions(+), 67 deletions(-)
diff --git a/src/views/layout/components/Header/updatePassword/index.vue b/src/views/layout/components/Header/updatePassword/index.vue
index 5e5c04c..b75e94e 100644
--- a/src/views/layout/components/Header/updatePassword/index.vue
+++ b/src/views/layout/components/Header/updatePassword/index.vue
@@ -2,16 +2,16 @@
<div class="createUser">
<main>
<div class="mainContent">
- <el-form ref="password" label-width="140px" :rules="passwordRules" autoComplete="on" :model="password"
- label-position="right">
- <el-form-item class="optionItem" label="褰撳墠瀵嗙爜:" prop="oldPassword">
- <el-input type="password" v-model="password.oldPassword" placeholder="璇峰~鍐欏綋鍓嶅瘑鐮�"></el-input>
+ <el-form ref="password" label-width="120px" :rules="passwordRules" autoComplete="on" :model="password"
+ label-position="right">
+ <el-form-item class="optionItem" label="褰撳墠瀵嗙爜:" prop="oldPassword" show-password>
+ <el-input type="password" v-model="password.oldPassword" placeholder="璇峰~鍐欏綋鍓嶅瘑鐮�" show-password> </el-input>
</el-form-item>
- <el-form-item class="optionItems" label="鏂板瘑鐮�:" prop="newPassword">
- <el-input type="password" v-model="password.newPassword" placeholder="璇峰~鍐欐柊瀵嗙爜"></el-input>
+ <el-form-item class="optionItems" label="鏂板瘑鐮�:" prop="newPassword" show-password>
+ <el-input type="password" v-model="password.newPassword" placeholder="璇峰~鍐欐柊瀵嗙爜" show-password></el-input>
</el-form-item>
- <el-form-item class="optionItems" label="纭畾鏂板瘑鐮�:" prop="confirmPassword">
- <el-input type="password" v-model="password.confirmPassword" placeholder="璇峰啀娆″~鍐欐柊瀵嗙爜"></el-input>
+ <el-form-item class="optionItems" label="纭畾鏂板瘑鐮�:" prop="confirmPassword" >
+ <el-input type="password" v-model="password.confirmPassword" placeholder="璇峰啀娆″~鍐欐柊瀵嗙爜" show-password></el-input>
</el-form-item>
<el-form-item class="optionItems">
<el-button type="primary" @click="onSubmit">鎻愪氦</el-button>
@@ -27,20 +27,12 @@
export default {
data() {
const validatePass = (rule, value, callback) => {
- if (!value) {
- callback(new Error("鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖"));
- } else {
- if (value.length < 6 || value.length > 16) {
- callback(new Error("鐢ㄦ埛瀵嗙爜闀垮害涓嶅悎娉�"));
- } else {
- const rep = /^\w+$/;
- if (!rep.test(value)) {
- callback(new Error("瀵嗙爜鍙兘鏄互鏁板瓧銆�26涓嫳鏂囧瓧姣嶆垨鑰呬笅鍒掔嚎缁勬垚鐨勫瓧绗︿覆"));
+ var rep =/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$/;
+ if (!rep.test(value) ) {
+ callback(new Error("瀵嗙爜闀垮害8鍒�16浣嶄笖瀵嗙爜涓殑瀛楃蹇呴』鍖呭惈瀛楁瘝澶у啓鍜屽瓧姣嶅皬鍐欏拰蹇呴』鍖呭惈鏁板瓧锛屼笉鑳藉寘鍚┖鏍�"));
} else {
callback();
}
- }
- }
};
return {
updatePasswordParam: {
@@ -55,16 +47,16 @@
},
passwordRules: {
newPassword: [
- {required: true, trigger: 'blur', message: '瀵嗙爜涓嶈兘涓虹┖'},
- {validator: validatePass, trigger: 'blur'}
+ { required: true, trigger: 'blur', message: '鏂板瘑鐮佷笉鑳戒负绌�' },
+ { validator: validatePass, trigger: 'blur' }
],
oldPassword: [
- {required: true, trigger: 'blur', message: '鏂板瘑鐮佷笉鑳戒负绌�'},
- {validator: validatePass, trigger: 'blur'}
+ { required: true, trigger: 'blur', message: '褰撳墠瀵嗙爜涓嶈兘涓虹┖' },
+ // { validator: validatePass, trigger: 'blur' }
],
confirmPassword: [
- {required: true, trigger: 'blur', message: '鏂板瘑鐮佷笉鑳戒负绌�'},
- {validator: validatePass, trigger: 'blur'}
+ { required: true, trigger: 'blur', message: '鏂板瘑鐮佷笉鑳戒负绌�' },
+ { validator: validatePass, trigger: 'blur' }
],
}
}
@@ -79,22 +71,22 @@
this.updatePasswordParam.username = sessionStorage.getItem('name');
this.updatePasswordParam.newPassword = this.password.newPassword;
users.updatePassword(this.updatePasswordParam)
- .then(() => {
- this.$message.success('淇敼瀵嗙爜鎴愬姛, 鍗冲皢閲嶆柊鐧诲綍');
- this.logout();
- location.reload();
- })
- .catch(err => this.$message.error(err))
+ .then(() => {
+ this.$message.success('淇敼瀵嗙爜鎴愬姛, 鍗冲皢閲嶆柊鐧诲綍');
+ this.logout();
+ location.reload();
+ })
+ .catch(err => this.$message.error(err))
}
})
}
,
logout() {
users.logout()
- .then(() => {
- sessionStorage.clear();
- })
- .catch(err => this.$message.error(err))
+ .then(() => {
+ sessionStorage.clear();
+ })
+ .catch(err => this.$message.error(err))
}
},
}
@@ -161,5 +153,10 @@
background-color: #09152f;
border: 1px solid #17324c;
}
+
+ ::v-deep .el-form-item__error {
+ position:unset;
+}
+
}
</style>
diff --git a/src/views/systemSetting/baseSetting/user/components/createUser/index.vue b/src/views/systemSetting/baseSetting/user/components/createUser/index.vue
index 7d1cbe8..d20faaf 100644
--- a/src/views/systemSetting/baseSetting/user/components/createUser/index.vue
+++ b/src/views/systemSetting/baseSetting/user/components/createUser/index.vue
@@ -189,16 +189,12 @@
};
const validatePass = (rule, value, callback) => {
//蹇呴』鍖呭惈瀛楁瘝銆佹暟瀛椼�侀暱搴﹀啀6-16浣嶄箣闂�
- var regex = new RegExp("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$");
- if (value === "") {
- callback(new Error("鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖"));
- } else if (value.length < 6 || value.length > 16) {
- callback(new Error("璇疯緭饧�6~16浣嶅瘑鐮�"));
- } else if (!regex.test(value)) {
- callback(new Error("瀵嗙爜鍙兘鏄互鏁板瓧銆�26涓嫳鏂囧瓧姣嶇粍鎴愮殑瀛楃涓�"));
- } else {
- callback();
- }
+ var rep =/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$/;
+ if (!rep.test(value) ) {
+ callback(new Error("瀵嗙爜闀垮害8鍒�16浣嶄笖瀵嗙爜涓殑瀛楃蹇呴』鍖呭惈瀛楁瘝澶у啓鍜屽瓧姣嶅皬鍐欏拰蹇呴』鍖呭惈鏁板瓧锛屼笉鑳藉寘鍚┖鏍�"));
+ } else {
+ callback();
+ }
// if (!value) {
// callback(new Error("鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖"));
diff --git a/src/views/systemSetting/baseSetting/user/components/password/index.vue b/src/views/systemSetting/baseSetting/user/components/password/index.vue
index 2a7eb82..69322c5 100644
--- a/src/views/systemSetting/baseSetting/user/components/password/index.vue
+++ b/src/views/systemSetting/baseSetting/user/components/password/index.vue
@@ -3,15 +3,15 @@
<el-form ref="pwd" label-width="140px" autoComplete="on" :model="user" :rules="passrules">
<!-- 鍒濆瀵嗙爜 -->
<el-form-item class="optionItem" label="鍒濆瀵嗙爜:" prop="password">
- <el-input v-model="user.password" type="password" placeholder="璇峰~鍐欏垵濮嬪瘑鐮�"></el-input>
+ <el-input v-model="user.password" type="password" placeholder="璇峰~鍐欏垵濮嬪瘑鐮�" show-password></el-input>
</el-form-item>
<!-- 鏂板瘑鐮� -->
<el-form-item class="optionItem" label="鏂板瘑鐮�:" prop="newPwd">
- <el-input v-model="user.newPwd" type="password" placeholder="璇峰~鍐欐柊瀵嗙爜"></el-input>
+ <el-input v-model="user.newPwd" type="password" placeholder="璇峰~鍐欐柊瀵嗙爜" show-password></el-input>
</el-form-item>
<!-- 鏂板瘑鐮� -->
<el-form-item class="optionItem" label="纭鏂板瘑鐮�:" prop="secondPwd">
- <el-input v-model="user.secondPwd" type="password" placeholder="纭鎮ㄧ殑鏂板瘑鐮�"></el-input>
+ <el-input v-model="user.secondPwd" type="password" placeholder="纭鎮ㄧ殑鏂板瘑鐮�" show-password></el-input>
</el-form-item>
</el-form>
@@ -32,24 +32,21 @@
}
}
const checkNewPwd = (rule, value, callback) => {
- if (!value) {
- callback(new Error('鏂板瘑鐮佷笉鑳戒负绌�'))
- } else if (value === this.user.password) {
- callback(new Error('鏂板瘑鐮佷笉鑳藉拰鏃у瘑鐮佷竴鏍�'))
- } else {
- callback();
- }
- }
+ var rep =/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$/;
+ if (!rep.test(value) ) {
+ callback(new Error("瀵嗙爜闀垮害8鍒�16浣嶄笖瀵嗙爜涓殑瀛楃蹇呴』鍖呭惈瀛楁瘝澶у啓鍜屽瓧姣嶅皬鍐欏拰蹇呴』鍖呭惈鏁板瓧锛屼笉鑳藉寘鍚┖鏍�"));
+ } else {
+ callback();
+ }
+ };
+
const checkSame = (rule, value, callback) => {
- if (!value) {
- callback(new Error('纭瀵嗙爜涓嶈兘涓虹┖'))
- } else if (value !== this.user.newPwd) {
- console.log(111);
- callback(new Error('鎮ㄨ緭鍏ョ殑涓ゆ瀵嗙爜缁撴灉涓嶅悓'));
- } else {
-
- callback();
- }
+ var rep =/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$/;
+ if (!rep.test(value) ) {
+ callback(new Error("瀵嗙爜闀垮害8鍒�16浣嶄笖瀵嗙爜涓殑瀛楃蹇呴』鍖呭惈瀛楁瘝澶у啓鍜屽瓧姣嶅皬鍐欏拰蹇呴』鍖呭惈鏁板瓧锛屼笉鑳藉寘鍚┖鏍�"));
+ } else {
+ callback();
+ }
}
return {
user: {
diff --git a/src/views/systemSetting/platform/cockpitManage/index.vue b/src/views/systemSetting/platform/cockpitManage/index.vue
index 9b9234e..a879dd4 100644
--- a/src/views/systemSetting/platform/cockpitManage/index.vue
+++ b/src/views/systemSetting/platform/cockpitManage/index.vue
@@ -110,7 +110,7 @@
</el-dialog>
<div class="tools">
- <div class="funs">
+ <!-- <div class="funs">
<div class="funsItem funs-sp">
<el-checkbox v-model="all" @change="selectAll()">鍏ㄩ��</el-checkbox>
</div>
@@ -124,7 +124,7 @@
</el-option>
</el-select>
</div>
- </div>
+ </div> -->
<div class="pagination">
<el-pagination background :current-page="currentPage" layout="prev, pager, next"
:total="totalNum" :page-size="pageSize" @current-change="changeCurrentPage">
--
Gitblit v1.8.0