Files
hzdyjs/web/src/views/xg-xx/studentInfo/batchManagement.vue
T
wuzhen 8697b21b4d feat: 学生信息管理系统开发完成
- 完成学生信息管理核心功能开发
- 新增学生信息采集批次管理功能
- 完成班干部管理模块开发
- 修复物业报修模块附件上传逻辑
- 完善数据库表结构和权限配置
- 更新API文档和变更记录
- 优化前端页面交互体验

详细变更记录见:
- docs/变更管理/code-adjust-record-2025-01-13-wuzhen.md
- docs/变更管理/code-adjust-record-2025-07-11-wuzilong.md
- docs/变更管理/code-adjust-record-2025-07-12-wuzhen.md
2025-07-14 07:53:31 +08:00

774 lines
24 KiB
Vue

<template>
<div class="p-2 page-container">
<!-- 批次选择区域 -->
<el-card shadow="hover" class="mb-4">
<template #header>
<div class="card-header">
<span>批次管理</span>
<div class="header-actions">
<el-select v-model="selectedBatchId" placeholder="请选择批次" @change="handleBatchChange" style="width: 200px; margin-right: 10px;">
<el-option v-for="batch in batchOptions" :key="batch.id" :label="batch.batchName" :value="batch.id" />
</el-select>
<el-button type="primary" icon="Refresh" @click="refreshBatchInfo">刷新</el-button>
</div>
</div>
</template>
<!-- 批次信息展示 -->
<div v-if="currentBatch" class="batch-info">
<el-row :gutter="20">
<el-col :span="6">
<el-statistic title="批次名称" :value="currentBatch.batchName" />
</el-col>
<el-col :span="6">
<el-statistic title="批次状态" :value="getBatchStatusText(currentBatch.status)" />
</el-col>
<el-col :span="6">
<el-statistic title="总学生数" :value="batchStatistics.totalCount" />
</el-col>
<el-col :span="6">
<el-statistic title="已提交数" :value="batchStatistics.submittedCount" />
</el-col>
</el-row>
<el-row :gutter="20" class="mt-4">
<el-col :span="6">
<el-statistic title="已通过数" :value="batchStatistics.approvedCount" />
</el-col>
<el-col :span="6">
<el-statistic title="已拒绝数" :value="batchStatistics.rejectedCount" />
</el-col>
<el-col :span="6">
<el-statistic title="完成率" :value="batchStatistics.completionRate" suffix="%" />
</el-col>
<el-col :span="6">
<div class="progress-info">
<el-progress :percentage="batchStatistics.completionRate" :stroke-width="8" />
</div>
</el-col>
</el-row>
</div>
</el-card>
<!-- 搜索区域 -->
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" label-width="100px">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="学生姓名" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入学生姓名" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="学号" prop="studentNo">
<el-input v-model="queryParams.studentNo" placeholder="请输入学号" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="班级" prop="className">
<el-input v-model="queryParams.className" placeholder="请输入班级名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="提交状态" prop="submissionStatus">
<el-select v-model="queryParams.submissionStatus" placeholder="请选择提交状态" clearable style="width: 100%">
<el-option label="草稿" value="DRAFT" />
<el-option label="已提交" value="SUBMITTED" />
<el-option label="已通过" value="APPROVED" />
<el-option label="已拒绝" value="REJECTED" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="学院" prop="collegeName">
<el-input v-model="queryParams.collegeName" placeholder="请输入学院名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="18">
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
</div>
</transition>
<!-- 主要内容区域 -->
<el-card shadow="hover">
<!-- 操作按钮区域 -->
<div class="toolbar-wrapper">
<div class="toolbar-left">
<el-button type="primary" icon="Plus" @click="handleAssociate" :disabled="!selectedBatchId">
关联学生到批次
</el-button>
<el-button type="success" icon="Select" :disabled="!multiple || ids.length === 0" @click="handleBatchAssociate">
批量关联
</el-button>
<el-button type="warning" icon="Upload" :disabled="!multiple || ids.length === 0" @click="handleBatchSubmit">
批量提交
</el-button>
<el-button type="info" icon="Download" :disabled="!multiple || ids.length === 0" @click="handleBatchWithdraw">
批量撤回
</el-button>
</div>
<div class="toolbar-right">
<el-button type="danger" icon="Download" @click="handleExport">
导出
</el-button>
<el-button type="info" icon="Refresh" @click="handleRefresh">
刷新
</el-button>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</div>
</div>
<!-- 表格区域 -->
<div class="table-wrapper">
<el-table
v-loading="loading"
:data="studentList"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
row-key="id"
border
stripe
size="small"
>
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" type="index" width="60" align="center" />
<el-table-column label="学生姓名" prop="name" width="100" align="center" show-overflow-tooltip />
<el-table-column label="学号" prop="studentNo" width="120" align="center" show-overflow-tooltip />
<el-table-column label="班级" prop="className" width="120" align="center" show-overflow-tooltip />
<el-table-column label="学院" prop="collegeName" width="120" align="center" show-overflow-tooltip />
<el-table-column label="专业" prop="majorName" width="120" align="center" show-overflow-tooltip />
<el-table-column label="联系电话" prop="phone" width="120" align="center" show-overflow-tooltip />
<el-table-column label="提交状态" prop="submissionStatus" width="100" align="center">
<template #default="scope">
<el-tag :type="getSubmissionStatusTagType(scope.row.submissionStatus)" size="small">
{{ getSubmissionStatusText(scope.row.submissionStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="提交时间" prop="submissionTime" width="160" align="center" sortable="custom">
<template #default="scope">
<span>{{ scope.row.submissionTime ? proxy.parseTime(scope.row.submissionTime, '{y}-{m}-{d} {h}:{i}') : '-' }}</span>
</template>
</el-table-column>
<el-table-column label="审核状态" prop="approvalStatus" width="100" align="center">
<template #default="scope">
<el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)" size="small">
{{ getApprovalStatusText(scope.row.approvalStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="200" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<div class="action-buttons">
<el-tooltip content="查看详情" placement="top">
<el-button link type="info" icon="View" size="small" @click="handleView(scope.row)" />
</el-tooltip>
<el-tooltip content="编辑" placement="top">
<el-button link type="primary" icon="Edit" size="small" @click="handleEdit(scope.row)" />
</el-tooltip>
<el-tooltip content="查看进度" placement="top">
<el-button link type="warning" icon="DataAnalysis" size="small" @click="handleProgress(scope.row)" />
</el-tooltip>
<template v-if="scope.row.submissionStatus === 'DRAFT'">
<el-tooltip content="提交" placement="top">
<el-button link type="success" icon="Upload" size="small" @click="handleSubmit(scope.row)" />
</el-tooltip>
</template>
<template v-else-if="scope.row.submissionStatus === 'SUBMITTED'">
<el-tooltip content="撤回" placement="top">
<el-button link type="danger" icon="Download" size="small" @click="handleWithdraw(scope.row)" />
</el-tooltip>
</template>
</div>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<pagination v-show="total > 0" :total="total" :page="queryParams.pageNum" :limit="queryParams.pageSize" @pagination="getList" />
</div>
</div>
</el-card>
<!-- 关联学生到批次对话框 -->
<el-dialog title="关联学生到批次" v-model="associateDialog.visible" width="600px" append-to-body>
<el-form ref="associateFormRef" :model="associateForm" :rules="associateRules" label-width="100px">
<el-form-item label="选择批次" prop="batchId">
<el-select v-model="associateForm.batchId" placeholder="请选择批次" style="width: 100%">
<el-option v-for="batch in batchOptions" :key="batch.id" :label="batch.batchName" :value="batch.id" />
</el-select>
</el-form-item>
<el-form-item label="选择学生" prop="studentIds">
<el-select v-model="associateForm.studentIds" multiple placeholder="请选择学生" style="width: 100%">
<el-option v-for="student in allStudents" :key="student.id" :label="`${student.name}(${student.studentNo})`" :value="student.id" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="associateDialog.visible = false">取消</el-button>
<el-button type="primary" @click="submitAssociate">确定</el-button>
</div>
</template>
</el-dialog>
<!-- 学生进度对话框 -->
<el-dialog title="学生批次进度" v-model="progressDialog.visible" width="800px" append-to-body>
<div v-if="progressInfo" class="progress-content">
<el-descriptions :column="2" border>
<el-descriptions-item label="学生姓名">{{ progressInfo.studentName }}</el-descriptions-item>
<el-descriptions-item label="学号">{{ progressInfo.studentNo }}</el-descriptions-item>
<el-descriptions-item label="批次名称">{{ progressInfo.batchName }}</el-descriptions-item>
<el-descriptions-item label="提交状态">
<el-tag :type="getSubmissionStatusTagType(progressInfo.submissionStatus)">
{{ getSubmissionStatusText(progressInfo.submissionStatus) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="审核状态">
<el-tag :type="getApprovalStatusTagType(progressInfo.approvalStatus)">
{{ getApprovalStatusText(progressInfo.approvalStatus) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="提交时间">
{{ progressInfo.submissionTime ? proxy.parseTime(progressInfo.submissionTime, '{y}-{m}-{d} {h}:{i}:{s}') : '-' }}
</el-descriptions-item>
<el-descriptions-item label="审核时间">
{{ progressInfo.approvalTime ? proxy.parseTime(progressInfo.approvalTime, '{y}-{m}-{d} {h}:{i}:{s}') : '-' }}
</el-descriptions-item>
<el-descriptions-item label="审核意见" :span="2">
{{ progressInfo.approvalComments || '-' }}
</el-descriptions-item>
</el-descriptions>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { listAllCollectionBatch } from '@/api/xg-xx/collectionBatch';
import {
getStudentsByBatch,
associateStudentToBatch,
batchAssociateStudentsToBatch,
submitStudentInfo,
withdrawStudentInfo,
getStudentBatchProgress,
batchAuditStudentInfo,
checkEditPermission,
getStudentBatchStatistics,
batchSubmitStudentInfo,
batchWithdrawStudentInfo,
getAllStudentOptions
} from '@/api/xg-xx/studentInfo';
const { proxy } = getCurrentInstance() as any;
// 响应式数据
const loading = ref(false);
const showSearch = ref(true);
const ids = ref<number[]>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const studentList = ref<any[]>([]);
const batchOptions = ref<any[]>([]);
const allStudents = ref<any[]>([]);
const selectedBatchId = ref<number>();
const currentBatch = ref<any>();
// 批次统计信息
const batchStatistics = reactive({
totalCount: 0,
submittedCount: 0,
approvedCount: 0,
rejectedCount: 0,
completionRate: 0
});
// 查询参数
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
batchId: undefined as number | undefined,
name: undefined,
studentNo: undefined,
className: undefined,
submissionStatus: undefined,
collegeName: undefined
});
// 关联对话框
const associateDialog = reactive({
visible: false
});
const associateForm = reactive({
batchId: undefined as number | undefined,
studentIds: [] as number[]
});
const associateRules = {
batchId: [{ required: true, message: '请选择批次', trigger: 'change' }],
studentIds: [{ required: true, message: '请选择学生', trigger: 'change' }]
};
// 进度对话框
const progressDialog = reactive({
visible: false
});
const progressInfo = ref<any>();
// 获取列表数据
const getList = async () => {
if (!selectedBatchId.value) {
studentList.value = [];
total.value = 0;
return;
}
loading.value = true;
try {
const response = await getStudentsByBatch(selectedBatchId.value, queryParams);
studentList.value = response.rows;
total.value = response.total;
} catch (error) {
console.error('获取列表失败:', error);
ElMessage.error('获取学生列表失败');
} finally {
loading.value = false;
}
};
// 获取批次选项
const getBatchOptions = async () => {
try {
const response = await listAllCollectionBatch({});
batchOptions.value = response.data;
} catch (error) {
console.error('获取批次选项失败:', error);
ElMessage.error('获取批次选项失败');
}
};
// 获取所有学生选项
const getAllStudentsList = async () => {
try {
const response = await getAllStudentOptions();
allStudents.value = response.data;
} catch (error) {
console.error('获取学生选项失败:', error);
ElMessage.error('获取学生选项失败');
}
};
// 批次改变处理
const handleBatchChange = (batchId: number) => {
selectedBatchId.value = batchId;
queryParams.batchId = batchId;
currentBatch.value = batchOptions.value.find(batch => batch.id === batchId);
// 获取批次统计信息
getBatchStatistics();
// 刷新列表
getList();
};
// 获取批次统计信息
const getBatchStatistics = async () => {
if (!selectedBatchId.value) return;
try {
const response = await getStudentBatchStatistics(selectedBatchId.value);
Object.assign(batchStatistics, response.data);
} catch (error) {
console.error('获取批次统计失败:', error);
ElMessage.error('获取批次统计失败');
}
};
// 刷新批次信息
const refreshBatchInfo = () => {
getBatchStatistics();
getList();
};
// 搜索
const handleQuery = () => {
queryParams.pageNum = 1;
getList();
};
// 重置搜索
const resetQuery = () => {
proxy.resetForm('queryFormRef');
handleQuery();
};
// 多选框选中数据
const handleSelectionChange = (selection: any[]) => {
ids.value = selection.map(item => item.id);
single.value = selection.length !== 1;
multiple.value = !selection.length;
};
// 排序变化
const handleSortChange = (column: any) => {
getList();
};
// 关联学生到批次
const handleAssociate = () => {
associateDialog.visible = true;
associateForm.batchId = selectedBatchId.value;
associateForm.studentIds = [];
// 获取所有学生选项
getAllStudentsList();
};
// 批量关联
const handleBatchAssociate = () => {
if (ids.value.length === 0) {
ElMessage.warning('请选择要关联的学生');
return;
}
associateDialog.visible = true;
associateForm.batchId = selectedBatchId.value;
associateForm.studentIds = ids.value;
// 获取所有学生选项
getAllStudentsList();
};
// 提交关联
const submitAssociate = async () => {
if (!associateForm.batchId || associateForm.studentIds.length === 0) {
ElMessage.warning('请选择批次和学生');
return;
}
try {
await batchAssociateStudentsToBatch(associateForm.studentIds, associateForm.batchId);
ElMessage.success('关联成功');
associateDialog.visible = false;
// 刷新统计信息和列表
getBatchStatistics();
getList();
} catch (error) {
console.error('关联失败:', error);
ElMessage.error('关联失败');
}
};
// 批量提交
const handleBatchSubmit = async () => {
if (ids.value.length === 0) {
ElMessage.warning('请选择要提交的学生');
return;
}
if (!selectedBatchId.value) {
ElMessage.warning('请先选择批次');
return;
}
try {
await ElMessageBox.confirm('确定要批量提交选中的学生信息吗?', '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
await batchSubmitStudentInfo(ids.value, selectedBatchId.value);
ElMessage.success('批量提交成功');
// 刷新统计信息和列表
getBatchStatistics();
getList();
} catch (error) {
if (error !== 'cancel') {
console.error('批量提交失败:', error);
ElMessage.error('批量提交失败');
}
}
};
// 批量撤回
const handleBatchWithdraw = async () => {
if (ids.value.length === 0) {
ElMessage.warning('请选择要撤回的学生');
return;
}
if (!selectedBatchId.value) {
ElMessage.warning('请先选择批次');
return;
}
try {
await ElMessageBox.confirm('确定要批量撤回选中的学生信息吗?', '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
await batchWithdrawStudentInfo(ids.value, selectedBatchId.value);
ElMessage.success('批量撤回成功');
// 刷新统计信息和列表
getBatchStatistics();
getList();
} catch (error) {
if (error !== 'cancel') {
console.error('批量撤回失败:', error);
ElMessage.error('批量撤回失败');
}
}
};
// 查看详情
const handleView = (row: any) => {
proxy.$router.push(`/xg-xx/studentInfo/detail/${row.id}`);
};
// 编辑
const handleEdit = (row: any) => {
proxy.$router.push(`/xg-xx/studentInfo/edit/${row.id}`);
};
// 提交
const handleSubmit = async (row: any) => {
if (!selectedBatchId.value) {
ElMessage.warning('请先选择批次');
return;
}
try {
await ElMessageBox.confirm('确定要提交该学生信息吗?', '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
await submitStudentInfo(row.id, selectedBatchId.value);
ElMessage.success('提交成功');
// 刷新统计信息和列表
getBatchStatistics();
getList();
} catch (error) {
if (error !== 'cancel') {
console.error('提交失败:', error);
ElMessage.error('提交失败');
}
}
};
// 撤回
const handleWithdraw = async (row: any) => {
if (!selectedBatchId.value) {
ElMessage.warning('请先选择批次');
return;
}
try {
await ElMessageBox.confirm('确定要撤回该学生信息吗?', '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
await withdrawStudentInfo(row.id, selectedBatchId.value);
ElMessage.success('撤回成功');
// 刷新统计信息和列表
getBatchStatistics();
getList();
} catch (error) {
if (error !== 'cancel') {
console.error('撤回失败:', error);
ElMessage.error('撤回失败');
}
}
};
// 查看进度
const handleProgress = async (row: any) => {
if (!selectedBatchId.value) {
ElMessage.warning('请先选择批次');
return;
}
try {
const response = await getStudentBatchProgress(row.id, selectedBatchId.value);
progressInfo.value = response.data;
progressDialog.visible = true;
} catch (error) {
console.error('获取进度失败:', error);
ElMessage.error('获取进度失败');
}
};
// 导出
const handleExport = () => {
proxy?.download(
'xg/studentInfo/export',
queryParams,
`学生信息_${proxy.parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`
);
};
// 刷新
const handleRefresh = () => {
getList();
};
// 获取批次状态文本
const getBatchStatusText = (status: string) => {
const statusMap: Record<string, string> = {
'DRAFT': '草稿',
'ACTIVE': '进行中',
'COMPLETED': '已完成',
'CANCELLED': '已取消'
};
return statusMap[status] || '未知';
};
// 获取提交状态标签类型
const getSubmissionStatusTagType = (status: string): 'success' | 'warning' | 'info' | 'primary' | 'danger' => {
const statusMap: Record<string, 'success' | 'warning' | 'info' | 'primary' | 'danger'> = {
'DRAFT': 'info',
'SUBMITTED': 'warning',
'APPROVED': 'success',
'REJECTED': 'danger'
};
return statusMap[status] || 'info';
};
// 获取提交状态文本
const getSubmissionStatusText = (status: string) => {
const statusMap: Record<string, string> = {
'DRAFT': '草稿',
'SUBMITTED': '已提交',
'APPROVED': '已通过',
'REJECTED': '已拒绝'
};
return statusMap[status] || '未知';
};
// 获取审核状态标签类型
const getApprovalStatusTagType = (status: string): 'success' | 'warning' | 'info' | 'primary' | 'danger' => {
const statusMap: Record<string, 'success' | 'warning' | 'info' | 'primary' | 'danger'> = {
'PENDING': 'warning',
'APPROVED': 'success',
'REJECTED': 'danger'
};
return statusMap[status] || 'info';
};
// 获取审核状态文本
const getApprovalStatusText = (status: string) => {
const statusMap: Record<string, string> = {
'PENDING': '待审核',
'APPROVED': '已通过',
'REJECTED': '已拒绝'
};
return statusMap[status] || '未知';
};
// 初始化
onMounted(() => {
getBatchOptions();
});
</script>
<style scoped>
.page-container {
background-color: #f5f5f5;
min-height: 100vh;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.header-actions {
display: flex;
align-items: center;
}
.batch-info {
padding: 16px 0;
}
.toolbar-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.toolbar-left {
display: flex;
align-items: center;
gap: 8px;
}
.toolbar-right {
display: flex;
align-items: center;
gap: 8px;
}
.table-wrapper {
margin-top: 16px;
}
.action-buttons {
display: flex;
gap: 4px;
justify-content: center;
}
.pagination-container {
display: flex;
justify-content: center;
margin-top: 16px;
}
.progress-info {
padding: 8px 0;
}
.progress-content {
padding: 16px 0;
}
.mt-4 {
margin-top: 16px;
}
</style>