Files
hzdyjs/web/src/views/stgl/stclass/index.vue
T
2025-09-07 18:17:50 +08:00

450 lines
17 KiB
Vue

<template>
<div class="p-2 page-container">
<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="classId">
<el-select v-model="queryParams.classId" placeholder="请选择班级" clearable style="width: 100%" @change="handleClassChange">
<el-option v-for="item in classList" :key="item.id" :label="item.className" :value="item.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="学生姓名" prop="studentName">
<el-input v-model="queryParams.studentName" 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-row>
<el-row>
<el-col :span="24" class="search-btn-container">
<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="never" class="button-card table-card">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="View" @click="() => handleView()" v-hasPermi="['stgl:stclass:query']">查看</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Download" @click="handleExport" v-hasPermi="['stgl:stclass:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="studentList" row-key="id" @selection-change="handleSelectionChange" @row-dblclick="handleView">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" type="index" width="60" align="center" />
<el-table-column label="学生姓名" align="center" prop="studentName" min-width="40" />
<el-table-column label="学号" align="center" prop="studentNo" min-width="45" />
<el-table-column label="性别" align="center" prop="gender" width="70">
<template #default="scope">
<dict-tag :options="sys_user_sex" :value="scope.row.gender" />
</template>
</el-table-column>
<el-table-column label="联系电话" align="center" prop="phone" min-width="55" />
<el-table-column label="加入社团" align="center" width="160">
<template #default="scope">
<el-button
v-if="scope.row.clubCount > 0"
type="primary"
link
@click="handleViewClubs(scope.row)"
style="font-size: 14px; font-weight: bold; color: #409eff"
>
{{ scope.row.clubCount }}
</el-button>
<span v-else class="no-data">0</span>
</template>
</el-table-column>
<el-table-column label="加入志愿者队伍" align="center" width="170">
<template #default="scope">
<el-button
v-if="scope.row.volunteerTeamCount > 0"
type="success"
link
@click="handleViewVolunteerTeams(scope.row)"
style="font-size: 14px; font-weight: bold; color: #67c23a"
>
{{ scope.row.volunteerTeamCount }}
</el-button>
<span v-else class="no-data">0</span>
</template>
</el-table-column>
<el-table-column label="参与活动" align="center" width="160">
<template #default="scope">
<el-button
v-if="scope.row.activityCount > 0"
type="warning"
link
@click="handleViewActivities(scope.row)"
style="font-size: 14px; font-weight: bold; color: #e6a23c"
>
{{ scope.row.activityCount }}
</el-button>
<span v-else class="no-data">0</span>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</div>
</el-card>
<!-- 社团详情弹窗 -->
<el-dialog v-model="clubDialog.visible" :title="clubDialog.title" width="800px" append-to-body>
<div v-if="clubDetails.length > 0">
<div v-for="(club, index) in clubDetails" :key="club.id" class="club-item">
<el-divider v-if="index > 0" />
<el-descriptions :column="2" border>
<el-descriptions-item label="社团名称">{{ club.clubName }}</el-descriptions-item>
<el-descriptions-item label="社团类型">
<dict-tag :options="stgl_club_type" :value="club.clubType" />
</el-descriptions-item>
<el-descriptions-item label="成立日期">{{ club.establishDate }}</el-descriptions-item>
<el-descriptions-item label="成员规模">{{ club.memberLimit }}</el-descriptions-item>
<el-descriptions-item label="社长姓名">{{ club.presidentName }}</el-descriptions-item>
<el-descriptions-item label="社长联系方式">{{ club.presidentPhone }}</el-descriptions-item>
<el-descriptions-item label="社长院系">{{ club.presidentDept }}</el-descriptions-item>
<el-descriptions-item label="社长专业">{{ club.presidentMajor }}</el-descriptions-item>
<el-descriptions-item label="社长班级">{{ club.presidentClass }}</el-descriptions-item>
<el-descriptions-item label="指导老师姓名">{{ club.advisorName }}</el-descriptions-item>
<el-descriptions-item label="指导老师部门">{{ club.advisorDept }}</el-descriptions-item>
<el-descriptions-item label="指导老师电话">{{ club.advisorPhone }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div v-else class="no-data-container">
<span class="no-data-text">暂无社团信息</span>
</div>
</el-dialog>
<!-- 志愿者队伍详情弹窗 -->
<el-dialog v-model="volunteerTeamDialog.visible" :title="volunteerTeamDialog.title" width="800px" append-to-body>
<div v-if="volunteerTeamDetails.length > 0">
<div v-for="(team, index) in volunteerTeamDetails" :key="team.id" class="team-item">
<el-divider v-if="index > 0" />
<el-descriptions :column="2" border>
<el-descriptions-item label="队伍名称">{{ team.teamName }}</el-descriptions-item>
<el-descriptions-item label="成立日期">{{ team.establishDate }}</el-descriptions-item>
<el-descriptions-item label="队长姓名">{{ team.leaderName }}</el-descriptions-item>
<el-descriptions-item label="队长联系方式">{{ team.leaderPhone }}</el-descriptions-item>
<el-descriptions-item label="队长院系">{{ team.leaderDept }}</el-descriptions-item>
<el-descriptions-item label="队长专业">{{ team.leaderMajor }}</el-descriptions-item>
<el-descriptions-item label="队长班级">{{ team.leaderClass }}</el-descriptions-item>
<el-descriptions-item label="指导老师姓名">{{ team.advisorName }}</el-descriptions-item>
<el-descriptions-item label="指导老师部门">{{ team.advisorDept }}</el-descriptions-item>
<el-descriptions-item label="指导老师电话">{{ team.advisorPhone }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div v-else class="no-data-container">
<span class="no-data-text">暂无志愿者队伍信息</span>
</div>
</el-dialog>
<!-- 活动详情弹窗 -->
<el-dialog v-model="activityDialog.visible" :title="activityDialog.title" width="800px" append-to-body>
<div v-if="activityDetails.length > 0">
<div v-for="(activity, index) in activityDetails" :key="activity.id" class="activity-item">
<el-divider v-if="index > 0" />
<el-descriptions :column="2" border>
<el-descriptions-item label="活动名称">{{ activity.activityName }}</el-descriptions-item>
<el-descriptions-item label="活动类型">
<dict-tag :options="stgl_activity_type" :value="activity.activityType" />
</el-descriptions-item>
<el-descriptions-item label="活动主题">{{ activity.activityTheme }}</el-descriptions-item>
<el-descriptions-item label="活动地点">{{ activity.location }}</el-descriptions-item>
<el-descriptions-item label="活动时间">{{ activity.activityTime }}</el-descriptions-item>
<el-descriptions-item label="关联社团/队伍">{{ activity.relatedOrganization }}</el-descriptions-item>
<el-descriptions-item label="指导老师姓名">{{ activity.advisorName }}</el-descriptions-item>
<el-descriptions-item label="指导老师电话">{{ activity.advisorPhone }}</el-descriptions-item>
<el-descriptions-item label="报名类型">{{ activity.registrationType }}</el-descriptions-item>
<el-descriptions-item label="取得成绩">{{ activity.score }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div v-else class="no-data-container">
<span class="no-data-text">暂无活动信息</span>
</div>
</el-dialog>
</div>
</template>
<script setup name="StglClass" lang="ts">
import {
getTeacherClasses,
listStglClass,
getStudentClubs,
getStudentVolunteerTeams,
getStudentActivities,
exportStglClass
} from '@/api/stgl/stclass';
import { StglClassQuery, StglClassVO, StglClassDetailVO, ClubDetailVO, VolunteerTeamDetailVO, ActivityDetailVO } from '@/api/stgl/stclass/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_user_sex, stgl_club_type, stgl_activity_type } = toRefs<any>(proxy?.useDict('sys_user_sex', 'stgl_club_type', 'stgl_activity_type'));
const loading = ref(false);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const studentList = ref<StglClassVO[]>([]);
const classList = ref<StglClassDetailVO[]>([]);
const queryFormRef = ref<ElFormInstance>();
const queryParams = ref<StglClassQuery>({
pageNum: 1,
pageSize: 10,
classId: undefined,
studentName: undefined,
studentNo: undefined
});
// 社团详情弹窗
const clubDialog = reactive<DialogOption>({
visible: false,
title: ''
});
const clubDetails = ref<ClubDetailVO[]>([]);
// 志愿者队伍详情弹窗
const volunteerTeamDialog = reactive<DialogOption>({
visible: false,
title: ''
});
const volunteerTeamDetails = ref<VolunteerTeamDetailVO[]>([]);
// 活动详情弹窗
const activityDialog = reactive<DialogOption>({
visible: false,
title: ''
});
const activityDetails = ref<ActivityDetailVO[]>([]);
/** 查询班主任的班级列表 */
const getTeacherClassList = async () => {
try {
const res = await getTeacherClasses();
if ((res.code === 200 || res.code === 0) && res.data) {
classList.value = res.data;
// 默认选择第一个班级
if (classList.value.length > 0) {
queryParams.value.classId = classList.value[0].id;
await getList();
}
}
} catch (error) {
console.error('获取班级列表失败:', error);
proxy?.$modal.msgError('获取班级列表失败');
}
};
/** 查询学生列表 */
const getList = async () => {
loading.value = true;
try {
const res = await listStglClass(queryParams.value);
if (res.code === 200 || res.code === 0) {
studentList.value = res.rows;
total.value = res.total;
}
} catch (error) {
console.error('查询学生列表失败:', error);
proxy?.$modal.msgError('查询学生列表失败');
} finally {
loading.value = false;
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: StglClassVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 班级切换处理 */
const handleClassChange = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 查看按钮操作 */
const handleView = (row?: StglClassVO) => {
const _row = row || studentList.value.find((item) => item.id === ids.value[0]);
if (!_row) {
proxy?.$modal.msgError('请选择要查看的学生');
return;
}
// 这里可以跳转到学生详情页面或显示学生详细信息
proxy?.$modal.msg(`查看学生:${_row.studentName}`);
};
/** 查看社团详情 */
const handleViewClubs = async (row: StglClassVO) => {
try {
const res = await getStudentClubs(row.id);
if (res.code === 200 || res.code === 0) {
clubDetails.value = res.data || [];
clubDialog.title = `${row.studentName} - 社团信息`;
clubDialog.visible = true;
}
} catch (error) {
console.error('获取社团详情失败:', error);
proxy?.$modal.msgError('获取社团详情失败');
}
};
/** 查看志愿者队伍详情 */
const handleViewVolunteerTeams = async (row: StglClassVO) => {
try {
const res = await getStudentVolunteerTeams(row.id);
if (res.code === 200 || res.code === 0) {
volunteerTeamDetails.value = res.data || [];
volunteerTeamDialog.title = `${row.studentName} - 志愿者队伍信息`;
volunteerTeamDialog.visible = true;
}
} catch (error) {
console.error('获取志愿者队伍详情失败:', error);
proxy?.$modal.msgError('获取志愿者队伍详情失败');
}
};
/** 查看活动详情 */
const handleViewActivities = async (row: StglClassVO) => {
try {
const res = await getStudentActivities(row.id);
if (res.code === 200 || res.code === 0) {
activityDetails.value = res.data || [];
activityDialog.title = `${row.studentName} - 活动信息`;
activityDialog.visible = true;
}
} catch (error) {
console.error('获取活动详情失败:', error);
proxy?.$modal.msgError('获取活动详情失败');
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('stgl/stclass/export', queryParams.value, `班级学生参与情况_${new Date().getTime()}.xlsx`);
};
onMounted(() => {
getTeacherClassList();
});
</script>
<style scoped>
/* 页面容器样式 */
.page-container {
padding: 8px;
background-color: #f5f5f5;
}
/* 表格卡片布局 */
.table-card {
margin-top: 0;
border-radius: 12px;
border: 1px solid #e4e7ed;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.table-card :deep(.el-card__body) {
padding: 0px 20px 20px 20px !important;
}
/* 移除按钮栏底部边框 */
.button-card :deep(.el-card__header) {
border-bottom: none !important;
background: linear-gradient(135deg, #fafbff 0%, #f8fafc 100%);
padding: 16px 20px;
}
/* 搜索按钮容器样式 */
.search-btn-container {
display: flex;
justify-content: flex-end;
margin-top: 10px;
.el-form-item {
margin-bottom: 0 !important;
}
}
/* 分页容器样式 */
.pagination-container {
display: flex;
justify-content: flex-end;
padding: 16px 20px 0 0 !important;
background-color: #fff;
margin-top: 0px !important;
}
/* 无数据样式 */
.no-data {
color: #909399;
font-size: 14px;
}
.no-data-container {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
}
.no-data-text {
color: #909399;
font-size: 16px;
}
/* 详情弹窗样式 */
.club-item,
.team-item,
.activity-item {
margin-bottom: 20px;
}
.club-item:last-child,
.team-item:last-child,
.activity-item:last-child {
margin-bottom: 0;
}
</style>