feat(xg): 新增按学号重置学生密码(Web/移动端)
学工老师可按学号查询并重置学生登录密码为固定默认值,独立权限不复用系统用户重置。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
0765f00458
commit
df4c21bd0d
14 files changed
+781
No files matched your search
@@ -117,3 +117,31 @@ export const getCollegeLeaders = (studentId: string | number): AxiosPromise<{ da
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
export interface StudentPwdResetVO {
|
||||
id?: string | number;
|
||||
studentNo?: string;
|
||||
name?: string;
|
||||
className?: string;
|
||||
classTeacherName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按学号查询学生(重置密码页)
|
||||
*/
|
||||
export const queryStudentForPwdReset = (studentNo: string): AxiosPromise<StudentPwdResetVO> => {
|
||||
return request({
|
||||
url: `/studentMsg/studentMsg/queryByStudentNo/${encodeURIComponent(studentNo)}`,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 按学号重置学生密码为固定默认值
|
||||
*/
|
||||
export const resetStudentPassword = (studentNo: string) => {
|
||||
return request({
|
||||
url: `/studentMsg/studentMsg/resetStudentPassword/${encodeURIComponent(studentNo)}`,
|
||||
method: 'put'
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<el-card shadow="hover" class="mb-3">
|
||||
<el-form :inline="true" @submit.prevent>
|
||||
<el-form-item label="学号">
|
||||
<el-input
|
||||
v-model="studentNo"
|
||||
placeholder="请输入学生学号"
|
||||
clearable
|
||||
maxlength="32"
|
||||
style="width: 260px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
v-hasPermi="['studentMsg:studentPwdReset:query']"
|
||||
type="primary"
|
||||
icon="Search"
|
||||
:loading="queryLoading"
|
||||
@click="handleQuery"
|
||||
>
|
||||
查询
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-if="student" shadow="never" v-loading="queryLoading">
|
||||
<template #header>
|
||||
<span>学生信息</span>
|
||||
</template>
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="姓名">{{ student.name || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="学号">{{ student.studentNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班级">{{ student.className || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班主任">{{ student.classTeacherName || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="mt-4">
|
||||
<el-button
|
||||
v-hasPermi="['studentMsg:studentPwdReset:reset']"
|
||||
type="danger"
|
||||
icon="Key"
|
||||
:loading="resetLoading"
|
||||
@click="handleReset"
|
||||
>
|
||||
重置密码
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-empty v-else-if="queried && !queryLoading" description="请输入学号后查询" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StudentPwdReset">
|
||||
import { ref } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
queryStudentForPwdReset,
|
||||
resetStudentPassword,
|
||||
type StudentPwdResetVO
|
||||
} from '@/api/xg/xsjcxx/studentMsg/studentMsg';
|
||||
|
||||
const studentNo = ref('');
|
||||
const student = ref<StudentPwdResetVO | null>(null);
|
||||
const queried = ref(false);
|
||||
const queryLoading = ref(false);
|
||||
const resetLoading = ref(false);
|
||||
|
||||
const handleQuery = async () => {
|
||||
const no = studentNo.value?.trim();
|
||||
if (!no) {
|
||||
ElMessage.warning('请输入学号');
|
||||
return;
|
||||
}
|
||||
queryLoading.value = true;
|
||||
queried.value = true;
|
||||
student.value = null;
|
||||
try {
|
||||
const res: any = await queryStudentForPwdReset(no);
|
||||
// 拦截器返回 { code, msg, data },需取 data;兼容偶发直接返回业务对象
|
||||
const payload =
|
||||
res?.data && typeof res.data === 'object' && !Array.isArray(res.data) ? res.data : res;
|
||||
if (!payload?.studentNo && !payload?.name && payload?.id == null) {
|
||||
ElMessage.warning(res?.msg || '未查询到学生信息,请确认后端已部署最新接口');
|
||||
student.value = null;
|
||||
return;
|
||||
}
|
||||
student.value = payload as StudentPwdResetVO;
|
||||
studentNo.value = no;
|
||||
} catch (e) {
|
||||
student.value = null;
|
||||
} finally {
|
||||
queryLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = async () => {
|
||||
if (!student.value?.studentNo) {
|
||||
ElMessage.warning('请先查询学生');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认将学号「${student.value.studentNo}」(${student.value.name || ''})的登录密码重置为系统默认密码?`,
|
||||
'重置密码确认',
|
||||
{ type: 'warning', confirmButtonText: '确定', cancelButtonText: '取消' }
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
resetLoading.value = true;
|
||||
try {
|
||||
await resetStudentPassword(student.value.studentNo);
|
||||
ElMessage.success('密码已重置为默认密码');
|
||||
} finally {
|
||||
resetLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mt-4 {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.mb-3 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user