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
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 重置学生密码 API
|
||||
*/
|
||||
import { request } from '@/common/request.js';
|
||||
|
||||
/**
|
||||
* 按学号查询学生基本信息(重置密码页)
|
||||
* @param {string} studentNo 学号
|
||||
*/
|
||||
export const queryStudentForPwdReset = (studentNo) => {
|
||||
return request({
|
||||
url: `/studentMsg/studentMsg/queryByStudentNo/${encodeURIComponent(studentNo)}`,
|
||||
method: 'GET'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 按学号重置学生登录密码为固定默认值
|
||||
* @param {string} studentNo 学号
|
||||
*/
|
||||
export const resetStudentPassword = (studentNo) => {
|
||||
return request({
|
||||
url: `/studentMsg/studentMsg/resetStudentPassword/${encodeURIComponent(studentNo)}`,
|
||||
method: 'PUT'
|
||||
});
|
||||
};
|
||||
@@ -65,6 +65,14 @@
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/xg/xsjcxx/studentPwdReset/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "重置学生密码",
|
||||
"navigationBarBackgroundColor": "#0051d9",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/xg/xsjcxx/xsws/index",
|
||||
"style": {
|
||||
|
||||
@@ -86,6 +86,15 @@
|
||||
/>
|
||||
</template>
|
||||
</ServiceItem>
|
||||
<ServiceItem
|
||||
v-if="hasPermi(['student:pwdreset:listapp'])"
|
||||
title="重置学生密码"
|
||||
@click="gotoStudentPwdReset"
|
||||
>
|
||||
<template #icon>
|
||||
<u-icon name="lock-open" size="24" color="#1890ff" />
|
||||
</template>
|
||||
</ServiceItem>
|
||||
<!-- 卡片结束 -->
|
||||
<!-- <ServiceItem
|
||||
v-if="hasPermi(['student:dorm:list'])"
|
||||
@@ -776,6 +785,7 @@ export default {
|
||||
hasStudentServices() {
|
||||
return (
|
||||
this.hasPermi(['student:info:listapp']) ||
|
||||
this.hasPermi(['student:pwdreset:listapp']) ||
|
||||
this.hasPermi(['student:dorm:list']) ||
|
||||
this.hasPermi(['student:leave:listapp']) ||
|
||||
this.hasPermi(['student:psychology:list']) ||
|
||||
@@ -1203,6 +1213,13 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转到重置学生密码页面
|
||||
gotoStudentPwdReset() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/xg/xsjcxx/studentPwdReset/index',
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转到假期留宿申请(学生)
|
||||
gotoHolidayStayApply() {
|
||||
uni.navigateTo({
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
<template>
|
||||
<view class="pwd-reset-page">
|
||||
<view class="search-card">
|
||||
<view class="form-row">
|
||||
<text class="label">学号</text>
|
||||
<u-input
|
||||
v-model="studentNo"
|
||||
placeholder="请输入学生学号"
|
||||
clearable
|
||||
maxlength="32"
|
||||
border="surround"
|
||||
:custom-style="{ background: '#fff' }"
|
||||
@confirm="handleQuery"
|
||||
/>
|
||||
</view>
|
||||
<u-button
|
||||
type="primary"
|
||||
text="查询"
|
||||
:loading="queryLoading"
|
||||
:custom-style="{ marginTop: '24rpx' }"
|
||||
@click="handleQuery"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view v-if="student" class="info-card">
|
||||
<view class="card-title">学生信息</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">姓名</text>
|
||||
<text class="info-value">{{ student.name || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">学号</text>
|
||||
<text class="info-value">{{ student.studentNo || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">班级</text>
|
||||
<text class="info-value">{{ student.className || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">班主任</text>
|
||||
<text class="info-value">{{ student.classTeacherName || '-' }}</text>
|
||||
</view>
|
||||
<u-button
|
||||
type="error"
|
||||
text="重置密码"
|
||||
:loading="resetLoading"
|
||||
:custom-style="{ marginTop: '32rpx' }"
|
||||
@click="handleReset"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view v-else-if="queried && !queryLoading" class="empty-tip">
|
||||
<u-empty mode="search" text="请输入学号后查询" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryStudentForPwdReset,
|
||||
resetStudentPassword
|
||||
} from '@/api/studentPwdReset.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
studentNo: '',
|
||||
student: null,
|
||||
queried: false,
|
||||
queryLoading: false,
|
||||
resetLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async handleQuery() {
|
||||
const no = (this.studentNo || '').trim();
|
||||
if (!no) {
|
||||
uni.showToast({ title: '请输入学号', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.queryLoading = true;
|
||||
this.queried = true;
|
||||
this.student = null;
|
||||
try {
|
||||
const res = await queryStudentForPwdReset(no);
|
||||
const payload =
|
||||
res && res.data && typeof res.data === 'object' && !Array.isArray(res.data)
|
||||
? res.data
|
||||
: res;
|
||||
if (!payload || (!payload.studentNo && !payload.name && payload.id == null)) {
|
||||
uni.showToast({
|
||||
title: (res && res.msg) || '未查询到学生信息',
|
||||
icon: 'none'
|
||||
});
|
||||
this.student = null;
|
||||
return;
|
||||
}
|
||||
this.student = payload;
|
||||
this.studentNo = no;
|
||||
} catch (e) {
|
||||
this.student = null;
|
||||
} finally {
|
||||
this.queryLoading = false;
|
||||
}
|
||||
},
|
||||
handleReset() {
|
||||
if (!this.student || !this.student.studentNo) {
|
||||
uni.showToast({ title: '请先查询学生', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const name = this.student.name || '';
|
||||
const no = this.student.studentNo;
|
||||
uni.showModal({
|
||||
title: '重置密码确认',
|
||||
content: `确认将学号「${no}」(${name})的登录密码重置为系统默认密码?`,
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: async (modalRes) => {
|
||||
if (!modalRes.confirm) {
|
||||
return;
|
||||
}
|
||||
this.resetLoading = true;
|
||||
try {
|
||||
await resetStudentPassword(no);
|
||||
uni.showToast({ title: '密码已重置为默认密码', icon: 'success' });
|
||||
} catch (e) {
|
||||
// 错误提示由 request 拦截器处理
|
||||
} finally {
|
||||
this.resetLoading = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pwd-reset-page {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding: 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-card,
|
||||
.info-card {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 28rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.form-row .label {
|
||||
width: 80rpx;
|
||||
flex-shrink: 0;
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.info-item:last-of-type {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
flex-shrink: 0;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding-top: 80rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -7,6 +7,7 @@
|
||||
const SERVICE_ROUTES = {
|
||||
// 学工管理
|
||||
'student:info': '/pages/xg/xsjcxx/xsjcxx/index',
|
||||
'student:pwdreset': '/pages/xg/xsjcxx/studentPwdReset/index',
|
||||
'student:dorm': '/pages/student/dorm/index',
|
||||
'student:leave': '/pages/xg/xsjcxx/xsqj/leave/index',
|
||||
'student:psychology': '/pages/student/psychology/index',
|
||||
@@ -48,6 +49,7 @@ const SERVICE_ROUTES = {
|
||||
// 服务名称映射
|
||||
const SERVICE_NAMES = {
|
||||
学生信息: 'student:info',
|
||||
重置学生密码: 'student:pwdreset',
|
||||
宿舍管理: 'student:dorm',
|
||||
学生请假: 'student:leave',
|
||||
心理健康: 'student:psychology',
|
||||
|
||||
Reference in new issue
Block a user