重置密码功能

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)
@ -766,11 +775,11 @@ function getName(arr: any[], type: any): string {
onMounted(() => { onMounted(() => {
getTree(); getTree();
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
}) })
} }
@ -1019,58 +1028,57 @@ function handleClearSelection() {
<el-dialog v-model="fishway" :close-on-click-modal="false" :before-close="fishHandleClose" title="过鱼设施权限维护" <el-dialog v-model="fishway" :close-on-click-modal="false" :before-close="fishHandleClose" title="过鱼设施权限维护"
append-to-body width="1600px" draggable> append-to-body width="1600px" draggable>
<!-- <el-scrollbar height="610px"> --> <!-- <el-scrollbar height="610px"> -->
<!-- <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <!-- <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
<el-tab-pane label="基地" name="1" :disabled="isBaseDisabled"></el-tab-pane> <el-tab-pane label="基地" name="1" :disabled="isBaseDisabled"></el-tab-pane>
<el-tab-pane label="公司" name="2" :disabled="isCompanyDisabled"></el-tab-pane> <el-tab-pane label="公司" name="2" :disabled="isCompanyDisabled"></el-tab-pane>
</el-tabs> --> </el-tabs> -->
<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> </el-input>
</el-input> <div class="button_div">
<div class="button_div"> <el-button type="primary" @click="handleSelectAll">全选</el-button>
<el-button type="primary" @click="handleSelectAll">全选</el-button> <el-button type="primary" @click="handleInvertSelection">反选</el-button>
<el-button type="primary" @click="handleInvertSelection">反选</el-button> <el-button type="primary" @click="handleClearSelection">取消选中</el-button>
<el-button type="primary" @click="handleClearSelection">取消选中</el-button>
</div>
</div> </div>
</div>
<el-scrollbar height="450px" style="margin-top: 10px;"> <el-scrollbar height="450px" style="margin-top: 10px;">
<el-tree ref="fishTreeRef" style="max-width: 300px" :data="fishData" show-checkbox default-expand-all <el-tree ref="fishTreeRef" style="max-width: 300px" :data="fishData" show-checkbox default-expand-all
v-loading="fishTreeDialog" node-key="code" highlight-current :props="fishProps" v-loading="fishTreeDialog" node-key="code" highlight-current :props="fishProps"
@check="handleFishCheckChange" /> @check="handleFishCheckChange" />
</el-scrollbar> </el-scrollbar>
</div>
<div class="fishTable">
<div class="topTable">
<el-button type="danger" :disabled="fishTableSelection.length == 0" @click="delFishTable">移除权限</el-button>
</div>
<el-table :data="fishTableData" style="width: 100%;" row-key="id" border default-expand-all
:v-loading="fishDialog" @selection-change="fishDataHandleSelectionChange" max-height="600"
:header-cell-style="{ background: 'rgb(250 250 250)', color: ' #383838', height: '50px' }">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="type" label="类型" width="200" align="center">
<template #default="scope">
<span>{{ getName(dictData,scope.row.type) }}</span>
</template>
</el-table-column>
<el-table-column prop="id" label="权限" align="center" width="200">
<template #default="scope">
<el-radio-group v-model="scope.row.permissionType">
<el-radio value="READ" size="large"></el-radio>
<el-radio value="WRITE" size="large"></el-radio>
</el-radio-group>
</template>
</el-table-column>
</el-table>
</div>
</div> </div>
<div class="fishTable">
<div class="topTable">
<el-button type="danger" :disabled="fishTableSelection.length == 0" @click="delFishTable">移除权限</el-button>
</div>
<el-table :data="fishTableData" style="width: 100%;" row-key="id" border default-expand-all
:v-loading="fishDialog" @selection-change="fishDataHandleSelectionChange" max-height="600"
:header-cell-style="{ background: 'rgb(250 250 250)', color: ' #383838', height: '50px' }">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="type" label="类型" width="200" align="center">
<template #default="scope">
<span>{{ getName(dictData, scope.row.type) }}</span>
</template>
</el-table-column>
<el-table-column prop="id" label="权限" align="center" width="200">
<template #default="scope">
<el-radio-group v-model="scope.row.permissionType">
<el-radio value="READ" size="large"></el-radio>
<el-radio value="WRITE" size="large"></el-radio>
</el-radio-group>
</template>
</el-table-column>
</el-table>
</div>
</div>
<!-- </el-scrollbar> --> <!-- </el-scrollbar> -->
<span class="dialog-footer" <span class="dialog-footer"
style="display: flex;display: -webkit-flex; justify-content: flex-end;-webkit-justify-content: flex-end;margin-top: 20px;"> style="display: flex;display: -webkit-flex; justify-content: flex-end;-webkit-justify-content: flex-end;margin-top: 20px;">
@ -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>