Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
maintain_service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘帅
maintain_service
Commits
34fb2562
Commit
34fb2562
authored
Sep 22, 2025
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.新用户创建以及管理员密码重置增加规则校验
parent
9c5cdb29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
8 deletions
+66
-8
index.vue
maintain-ui/src/views/system/user/index.vue
+66
-8
No files found.
maintain-ui/src/views/system/user/index.vue
View file @
34fb2562
...
@@ -260,7 +260,7 @@
...
@@ -260,7 +260,7 @@
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
<el-form-item
v-if=
"form.userId == undefined"
label=
"用户密码"
prop=
"password"
>
<el-form-item
v-if=
"form.userId == undefined"
label=
"用户密码"
prop=
"password"
>
<el-input
v-model=
"form.password"
placeholder=
"请输入用户密码"
type=
"password"
maxlength=
"20"
show-password
/>
<el-input
v-model=
"form.password"
placeholder=
"请输入用户密码"
type=
"password"
maxlength=
"20"
show-password
@
input=
"checkPasswordStrength"
/>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
...
@@ -385,7 +385,30 @@ export default {
...
@@ -385,7 +385,30 @@ export default {
dicts
:
[
'
sys_normal_disable
'
,
'
sys_user_sex
'
],
dicts
:
[
'
sys_normal_disable
'
,
'
sys_user_sex
'
],
components
:
{
Treeselect
},
components
:
{
Treeselect
},
data
()
{
data
()
{
// 验证密码复杂度
const
validatePasswordComplexity
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
value
)
{
callback
(
new
Error
(
"
新密码不能为空
"
));
return
;
}
// 检查密码复杂度
const
hasLowerCase
=
/
[
a-z
]
/
.
test
(
value
);
const
hasUpperCase
=
/
[
A-Z
]
/
.
test
(
value
);
const
hasNumber
=
/
[
0-9
]
/
.
test
(
value
);
const
hasSpecialChar
=
/
[
!@#$%^&*()_+
\-
=
\[\]
{};':"
\\
|,.<>
\/
?
]
/
.
test
(
value
);
if
(
!
hasLowerCase
||
!
hasUpperCase
||
!
hasNumber
||
!
hasSpecialChar
)
{
callback
(
new
Error
(
"
密码必须包含大小写字母、数字和特殊字符
"
));
return
;
}
callback
();
};
return
{
return
{
strengthClass
:
'
weak
'
,
strengthText
:
'
弱
'
,
isPasswordStrong
:
false
,
// 遮罩层
// 遮罩层
loading
:
true
,
loading
:
true
,
// 选中数组
// 选中数组
...
@@ -468,7 +491,8 @@ export default {
...
@@ -468,7 +491,8 @@ export default {
],
],
password
:
[
password
:
[
{
required
:
true
,
message
:
"
用户密码不能为空
"
,
trigger
:
"
blur
"
},
{
required
:
true
,
message
:
"
用户密码不能为空
"
,
trigger
:
"
blur
"
},
{
min
:
5
,
max
:
20
,
message
:
'
用户密码长度必须介于 5 和 20 之间
'
,
trigger
:
'
blur
'
}
{
min
:
8
,
message
:
"
密码至少为8个字符,须包含大写字母、小写字母、数字和特殊字符
"
,
trigger
:
"
blur
"
},
{
validator
:
validatePasswordComplexity
,
trigger
:
"
blur
"
}
],
],
email
:
[
email
:
[
{
{
...
@@ -501,6 +525,40 @@ export default {
...
@@ -501,6 +525,40 @@ export default {
});
});
},
},
methods
:
{
methods
:
{
// 检查密码强度
checkPasswordStrength
()
{
if
(
!
this
.
form
.
password
)
{
this
.
strengthClass
=
'
weak
'
;
this
.
strengthText
=
'
弱
'
;
this
.
isPasswordStrong
=
false
;
return
;
}
let
strength
=
0
;
// 长度检查
if
(
this
.
form
.
password
.
length
>=
8
)
strength
++
;
// 包含小写字母
if
(
/
[
a-z
]
/
.
test
(
this
.
form
.
password
))
strength
++
;
// 包含大写字母
if
(
/
[
A-Z
]
/
.
test
(
this
.
form
.
password
))
strength
++
;
// 包含数字
if
(
/
[
0-9
]
/
.
test
(
this
.
form
.
password
))
strength
++
;
// 包含特殊字符
if
(
/
[
!@#$%^&*()_+
\-
=
\[\]
{};':"
\\
|,.<>
\/
?
]
/
.
test
(
this
.
form
.
password
))
strength
++
;
// 设置强度等级
if
(
strength
<=
2
)
{
this
.
strengthClass
=
'
weak
'
;
this
.
strengthText
=
'
弱
'
;
this
.
isPasswordStrong
=
false
;
}
else
if
(
strength
<=
4
)
{
this
.
strengthClass
=
'
medium
'
;
this
.
strengthText
=
'
中
'
;
this
.
isPasswordStrong
=
false
;
}
else
{
this
.
strengthClass
=
'
strong
'
;
this
.
strengthText
=
'
强
'
;
this
.
isPasswordStrong
=
true
;
}
},
/** 查询用户列表 */
/** 查询用户列表 */
getList
()
{
getList
()
{
this
.
loading
=
true
;
this
.
loading
=
true
;
...
@@ -625,13 +683,13 @@ export default {
...
@@ -625,13 +683,13 @@ export default {
confirmButtonText
:
"
确定
"
,
confirmButtonText
:
"
确定
"
,
cancelButtonText
:
"
取消
"
,
cancelButtonText
:
"
取消
"
,
closeOnClickModal
:
false
,
closeOnClickModal
:
false
,
inputPattern
:
/^
.
{5
,20}
$/
,
inputPattern
:
/^
(?=
.*
[
a-z
])(?=
.*
[
A-Z
])(?=
.*
\d)(?=
.*
[
@$!%*?&
])[
A-Za-z
\d
@$!%*?&
]{8
,20}
$/
,
inputErrorMessage
:
"
用户密码长度必须介于 5 和 20 之间
"
inputErrorMessage
:
"
密码必须为8-20个字符,且包含大写字母、小写字母、数字和特殊字符(@$!%*?&)
"
}).
then
(({
value
})
=>
{
}).
then
(({
value
})
=>
{
resetUserPwd
(
row
.
userId
,
value
).
then
(
response
=>
{
resetUserPwd
(
row
.
userId
,
value
).
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
"
修改成功,新密码是:
"
+
value
);
this
.
$modal
.
msgSuccess
(
"
修改成功,新密码是:
"
+
value
);
});
});
}).
catch
(()
=>
{});
}).
catch
(()
=>
{});
},
},
/** 分配角色操作 */
/** 分配角色操作 */
handleAuthRole
:
function
(
row
)
{
handleAuthRole
:
function
(
row
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment