重置密码功能

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>
<!-- 密码 --> <!-- 密码 -->
<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" <a-input-password v-model:value="registerData.password"
placeholder="请设置密码6-20个字符" /> placeholder="请设置密码6-20个字符" />
</a-form-item> </a-form-item>
@ -297,11 +297,18 @@ const registerRules = {
} }
// 4. // 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(); const passwordLower = value.toLowerCase();
// 4.1 // 4.1
if (passwordLower.includes(username)) { if (passwordLower.includes(usernameLower)) {
return Promise.reject("密码不能包含用户名"); return Promise.reject("密码不能包含用户名");
} }
@ -309,14 +316,14 @@ const registerRules = {
const passwordLetters = passwordLower.replace(/[^a-z]/g, ''); const passwordLetters = passwordLower.replace(/[^a-z]/g, '');
// 4.3 >= 3 // 4.3 >= 3
if (passwordLetters.length >= 3 && username.includes(passwordLetters)) { if (passwordLetters.length >= 3 && usernameLower.includes(passwordLetters)) {
return Promise.reject("密码的字母部分不能是用户名的子串"); return Promise.reject("密码的字母部分不能是用户名的子串");
} }
// 4.4 3 // 4.4 3
for (let i = 0; i <= passwordLetters.length - 3; i++) { for (let i = 0; i <= passwordLetters.length - 3; i++) {
const substring = passwordLetters.substring(i, i + 3); const substring = passwordLetters.substring(i, i + 3);
if (username.includes(substring)) { if (usernameLower.includes(substring)) {
return Promise.reject("密码不能与用户名存在明显关联"); return Promise.reject("密码不能与用户名存在明显关联");
} }
} }
@ -801,7 +808,7 @@ const filterOption = (inputValue: string, option: any) => {
} }
:deep(.ant-form-item) { :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 userid.value = row.id
} }
function closeResult(){
resultPawss.value = false
}
// //
const fishway = ref(false) const fishway = ref(false)
const userId = ref('') const userId = ref('')
@ -1083,7 +1085,7 @@ function handleClearSelection() {
</el-dialog> </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"> append-to-body :before-close="handleAuditClose">
<el-form ref="auditFormRef" :model="auditForm" :rules="auditRules" label-width="80px"> <el-form ref="auditFormRef" :model="auditForm" :rules="auditRules" label-width="80px">
<el-form-item label="审批意见" prop="commentInfo"> <el-form-item label="审批意见" prop="commentInfo">
@ -1099,8 +1101,14 @@ function handleClearSelection() {
</template> </template>
</el-dialog> </el-dialog>
<!-- 重置密码后的回显 --> <!-- 重置密码后的回显 -->
<el-dialog v-model="resultPawss" width="500px" append-to-body :before-close="handleAuditClose"> <el-dialog v-model="resultPawss" :close-on-click-modal="false" title="重置成功" width="500px" append-to-body :before-close="closeResult">
已将密码重置为{{ msgText }} 已将密码重置为<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> </el-dialog>
</div> </div>
</template> </template>

View File

@ -251,9 +251,11 @@ function handleClose() {
// //
const userid = ref(""); const userid = ref("");
const resultPawss = ref(false)
const msgText = ref('')
function setpassword(row: any) { function setpassword(row: any) {
ElMessageBox.confirm( ElMessageBox.confirm(
'确定将该账号密码重置为123456吗?', '确定要重置此账号密码吗?',
'重置密码', '重置密码',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -265,16 +267,23 @@ function setpassword(row: any) {
const params = { const params = {
id: userid.value id: userid.value
} }
setpass(params).then(() => { setpass(params).then((res: any) => {
ElMessage({ if (res.code == 0) {
type: 'success', resultPawss.value = true
message: '密码重置成功', msgText.value = res.data
}) }
// ElMessage({
// type: 'success',
// message: '',
// })
}) })
}) })
userid.value = row.id userid.value = row.id
} }
function closeResult() {
resultPawss.value = false
}
// //
const fishway = ref(false) const fishway = ref(false)
@ -769,8 +778,8 @@ onMounted(() => {
getdictdata() getdictdata()
}); });
const dictData = ref([]) const dictData = ref([])
function getdictdata(){ function getdictdata() {
getDictItemsByCode({dictCode:'resourceType'}).then(res=>{ getDictItemsByCode({ dictCode: 'resourceType' }).then(res => {
dictData.value = res.data dictData.value = res.data
}) })
} }
@ -1026,8 +1035,7 @@ function handleClearSelection() {
<div class="fishBody"> <div class="fishBody">
<div class="fishTree"> <div class="fishTree">
<div style="width: 100%;padding: 0px 10px; box-sizing: border-box;"> <div style="width: 100%;padding: 0px 10px; box-sizing: border-box;">
<el-input v-model="treeInput" style="width: 100%" placeholder="请输入电站名称" clearable <el-input v-model="treeInput" style="width: 100%" placeholder="请输入电站名称" clearable class="input-with-select">
class="input-with-select">
<template #append> <template #append>
<el-button :icon="Search" @click="getFishTree()" /> <el-button :icon="Search" @click="getFishTree()" />
</template> </template>
@ -1057,7 +1065,7 @@ function handleClearSelection() {
<el-table-column prop="name" label="名称"></el-table-column> <el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="type" label="类型" width="200" align="center"> <el-table-column prop="type" label="类型" width="200" align="center">
<template #default="scope"> <template #default="scope">
<span>{{ getName(dictData,scope.row.type) }}</span> <span>{{ getName(dictData, scope.row.type) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="id" label="权限" align="center" width="200"> <el-table-column prop="id" label="权限" align="center" width="200">
@ -1078,6 +1086,16 @@ function handleClearSelection() {
<el-button type="primary" @click="fishSure">保存</el-button> <el-button type="primary" @click="fishSure">保存</el-button>
</span> </span>
</el-dialog> </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> </div>
</template> </template>