重置密码功能

This commit is contained in:
王兴凯 2026-04-29 11:28:47 +08:00
parent 2181329316
commit 0f0199fd41
3 changed files with 106 additions and 74 deletions

View File

@ -25,7 +25,7 @@
</a-form-item>
<!-- 密码 -->
<a-form-item name="password" label="密&nbsp;&nbsp;码">
<a-form-item name="password" label="密&nbsp;&nbsp;码" :dependencies="['username']">
<a-input-password v-model:value="registerData.password"
placeholder="请设置密码6-20个字符" />
</a-form-item>
@ -297,11 +297,18 @@ const registerRules = {
}
// 4.
const username = registerData.username.toLowerCase();
// 4.0
const username = registerData.username;
if (!username || username.trim() === '') {
//
return Promise.resolve();
}
const usernameLower = username.toLowerCase();
const passwordLower = value.toLowerCase();
// 4.1
if (passwordLower.includes(username)) {
if (passwordLower.includes(usernameLower)) {
return Promise.reject("密码不能包含用户名");
}
@ -309,14 +316,14 @@ const registerRules = {
const passwordLetters = passwordLower.replace(/[^a-z]/g, '');
// 4.3 >= 3
if (passwordLetters.length >= 3 && username.includes(passwordLetters)) {
if (passwordLetters.length >= 3 && usernameLower.includes(passwordLetters)) {
return Promise.reject("密码的字母部分不能是用户名的子串");
}
// 4.4 3
for (let i = 0; i <= passwordLetters.length - 3; i++) {
const substring = passwordLetters.substring(i, i + 3);
if (username.includes(substring)) {
if (usernameLower.includes(substring)) {
return Promise.reject("密码不能与用户名存在明显关联");
}
}
@ -801,7 +808,7 @@ const filterOption = (inputValue: string, option: any) => {
}
:deep(.ant-form-item) {
margin-bottom: clamp(8px, 1vh, 14px);
margin-bottom: 8px;
}
}
}
@ -829,5 +836,4 @@ const filterOption = (inputValue: string, option: any) => {
}
}
}
}
</style>
}</style>

View File

@ -204,7 +204,9 @@ function setpassword(row: any) {
userid.value = row.id
}
function closeResult(){
resultPawss.value = false
}
//
const fishway = ref(false)
const userId = ref('')
@ -1083,7 +1085,7 @@ function handleClearSelection() {
</el-dialog>
<!-- 审批意见对话框 -->
<el-dialog v-model="auditDialogVisible" :title="auditType === 'APPROVED' ? '审批通过' : '审批驳回'" width="500px"
<el-dialog v-model="auditDialogVisible" :close-on-click-modal="false" :title="auditType === 'APPROVED' ? '审批通过' : '审批驳回'" width="500px"
append-to-body :before-close="handleAuditClose">
<el-form ref="auditFormRef" :model="auditForm" :rules="auditRules" label-width="80px">
<el-form-item label="审批意见" prop="commentInfo">
@ -1099,8 +1101,14 @@ function handleClearSelection() {
</template>
</el-dialog>
<!-- 重置密码后的回显 -->
<el-dialog v-model="resultPawss" width="500px" append-to-body :before-close="handleAuditClose">
已将密码重置为{{ msgText }}
<el-dialog v-model="resultPawss" :close-on-click-modal="false" title="重置成功" width="500px" append-to-body :before-close="closeResult">
已将密码重置为<span style="color: #409eff;font-size: 16px;">{{ msgText }}</span>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeResult">取消</el-button>
<el-button type="primary" @click="closeResult">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>

View File

@ -251,9 +251,11 @@ function handleClose() {
//
const userid = ref("");
const resultPawss = ref(false)
const msgText = ref('')
function setpassword(row: any) {
ElMessageBox.confirm(
'确定将该账号密码重置为123456吗?',
'确定要重置此账号密码吗?',
'重置密码',
{
confirmButtonText: '确定',
@ -265,16 +267,23 @@ function setpassword(row: any) {
const params = {
id: userid.value
}
setpass(params).then(() => {
ElMessage({
type: 'success',
message: '密码重置成功',
})
setpass(params).then((res: any) => {
if (res.code == 0) {
resultPawss.value = true
msgText.value = res.data
}
// ElMessage({
// type: 'success',
// message: '',
// })
})
})
userid.value = row.id
}
function closeResult() {
resultPawss.value = false
}
//
const fishway = ref(false)
@ -1026,8 +1035,7 @@ function handleClearSelection() {
<div class="fishBody">
<div class="fishTree">
<div style="width: 100%;padding: 0px 10px; box-sizing: border-box;">
<el-input v-model="treeInput" style="width: 100%" placeholder="请输入电站名称" clearable
class="input-with-select">
<el-input v-model="treeInput" style="width: 100%" placeholder="请输入电站名称" clearable class="input-with-select">
<template #append>
<el-button :icon="Search" @click="getFishTree()" />
</template>
@ -1078,6 +1086,16 @@ function handleClearSelection() {
<el-button type="primary" @click="fishSure">保存</el-button>
</span>
</el-dialog>
<el-dialog v-model="resultPawss" :close-on-click-modal="false" title="重置成功" width="500px" append-to-body
:before-close="closeResult">
已将密码重置为<span style="color: #409eff;font-size: 16px;">{{ msgText }}</span>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeResult">取消</el-button>
<el-button type="primary" @click="closeResult">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>