学年考核学期考核

This commit is contained in:
yaojian
2026-03-11 17:51:17 +08:00
parent cb2280406e
commit d4f140e488
2 changed files with 290 additions and 288 deletions

View File

@@ -1,9 +1,17 @@
<template> <template>
<div class="layout-padding"> <div class="modern-page-container">
<div class="layout-padding-auto layout-padding-view"> <div class="page-wrapper">
<!-- 搜索表单 --> <!-- 搜索表单卡片 -->
<el-row v-show="showSearch"> <el-card v-show="showSearch" class="search-card" shadow="never">
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList"> <template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Search /></el-icon>
筛选条件
</span>
</div>
</template>
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList" class="search-form">
<el-form-item label="学年" prop="schoolYear"> <el-form-item label="学年" prop="schoolYear">
<el-select <el-select
v-model="queryForm.schoolYear" v-model="queryForm.schoolYear"
@@ -54,15 +62,25 @@
<el-button type="warning" icon="Bell" @click="handleSendWarning" :loading="warningLoading">发送预警</el-button> <el-button type="warning" icon="Bell" @click="handleSendWarning" :loading="warningLoading">发送预警</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-row> </el-card>
<!-- 内容卡片 -->
<el-card class="content-card" shadow="never">
<template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Document /></el-icon>
学期操行考核统计
</span>
</div>
</template>
<!-- 统计表格 --> <!-- 统计表格 -->
<el-row style="margin-bottom: 20px">
<el-table <el-table
:data="statisticsData" :data="statisticsData"
v-loading="loading" v-loading="loading"
border stripe
style="width: 100%" style="width: 100%; margin-bottom: 20px"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :header-cell-style="tableStyle.headerCellStyle"
> >
@@ -73,50 +91,52 @@
<el-table-column prop="pass" label="及格" min-width="100" align="center" /> <el-table-column prop="pass" label="及格" min-width="100" align="center" />
<el-table-column prop="fail" label="不及格" min-width="100" align="center" /> <el-table-column prop="fail" label="不及格" min-width="100" align="center" />
</el-table> </el-table>
</el-row>
<!-- 学生列表表格 --> <!-- 学生列表表格 -->
<el-row>
<el-table <el-table
:data="studentList" :data="studentList"
v-loading="loading" v-loading="loading"
border stripe
:max-height="600" style="width: 100%"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :header-cell-style="tableStyle.headerCellStyle"
> >
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" /> <el-table-column prop="stuNo" label="学号" min-width="120" show-overflow-tooltip align="center" />
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" /> <el-table-column prop="realName" label="姓名" min-width="100" show-overflow-tooltip align="center" />
<el-table-column prop="score" label="学期总评" show-overflow-tooltip align="center"> <!-- 各月份分数 -->
<el-table-column v-for="(month, index) in monthColumns" :key="index" :label="month.label" min-width="70" align="center">
<template #default="scope"> <template #default="scope">
<span>{{ scope.row.score !== null && scope.row.score !== undefined ? scope.row.score.toFixed(2) : '-' }}</span> <span>{{ formatScore(scope.row[month.prop]) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="150" align="center" fixed="right"> <!-- 学期总评 -->
<el-table-column prop="scoreOneTerm" label="学期总评" min-width="100" align="center">
<template #default="scope"> <template #default="scope">
<el-button icon="View" text type="primary" @click="handleView(scope.row)"> 查看 </el-button> <el-tag :type="getScoreType(scope.row.scoreOneTerm)" size="small" effect="plain">
{{ formatScore(scope.row.scoreOneTerm) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="center" fixed="right">
<template #default="scope">
<el-button icon="View" link type="primary" @click="handleView(scope.row)">查看</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-row> </el-card>
</div> </div>
<!-- 查看详情弹窗接口queryDataByStuNo 通过学年学号查看详情按当前学期筛选 --> <!-- 查看详情弹窗 -->
<el-dialog <el-dialog v-model="viewDialogVisible" title="学期操行考核详情" width="900px" destroy-on-close @close="viewDetailList = []">
v-model="viewDialogVisible"
title="学期操行考核详情"
width="800px"
destroy-on-close
@close="viewDetailList = []">
<div v-if="viewRow" class="view-summary"> <div v-if="viewRow" class="view-summary">
<el-descriptions :column="2" border size="small"> <el-descriptions :column="3" border size="small">
<el-descriptions-item label="学号">{{ viewRow.stuNo }}</el-descriptions-item> <el-descriptions-item label="学号">{{ viewRow.stuNo }}</el-descriptions-item>
<el-descriptions-item label="姓名">{{ viewRow.realName }}</el-descriptions-item> <el-descriptions-item label="姓名">{{ viewRow.realName }}</el-descriptions-item>
<el-descriptions-item label="学">{{ queryForm.schoolYear }}</el-descriptions-item> <el-descriptions-item label="学期总评">
<el-descriptions-item label="学期">{{ formatSchoolTerm(queryForm.schoolTerm) }}</el-descriptions-item> <el-tag :type="getScoreType(viewRow.scoreOneTerm)" size="small">
<el-descriptions-item label="学期总评" :span="2"> {{ formatScore(viewRow.scoreOneTerm) }}
{{ viewRow.score != null && viewRow.score !== undefined ? Number(viewRow.score).toFixed(2) : '-' }} </el-tag>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</div> </div>
@@ -124,14 +144,13 @@
<el-table <el-table
:data="viewDetailList" :data="viewDetailList"
v-loading="viewLoading" v-loading="viewLoading"
border stripe
size="small" size="small"
max-height="400" max-height="400"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"> :header-cell-style="tableStyle.headerCellStyle">
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="schoolTerm" label="期" width="80" align="center" show-overflow-tooltip /> <el-table-column prop="recordDate" label="考核日期" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="recordDate" label="考核日期" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="conductType" label="类型" width="80" align="center"> <el-table-column prop="conductType" label="类型" width="80" align="center">
<template #default="scope"> <template #default="scope">
<el-tag :type="scope.row.conductType === '1' ? 'success' : 'danger'" size="small"> <el-tag :type="scope.row.conductType === '1' ? 'success' : 'danger'" size="small">
@@ -144,8 +163,8 @@
{{ scope.row.score != null && scope.row.score !== undefined ? Number(scope.row.score) : '-' }} {{ scope.row.score != null && scope.row.score !== undefined ? Number(scope.row.score) : '-' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="description" label="情况记录" min-width="140" show-overflow-tooltip /> <el-table-column prop="description" label="情况记录" min-width="150" show-overflow-tooltip />
<el-table-column prop="remarks" label="备注" min-width="100" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" min-width="120" show-overflow-tooltip />
</el-table> </el-table>
<template v-if="viewDetailList.length === 0 && !viewLoading"> <template v-if="viewDetailList.length === 0 && !viewLoading">
<el-empty description="暂无考核记录" :image-size="80" /> <el-empty description="暂无考核记录" :image-size="80" />
@@ -156,16 +175,17 @@
<script setup lang="ts" name="StuConductTerm"> <script setup lang="ts" name="StuConductTerm">
import { reactive, ref, onMounted, computed } from 'vue' import { reactive, ref, onMounted, computed } from 'vue'
import { getStuConductTerm, queryDataByStuNo, sendConductWarning } from "/@/api/stuwork/stuconduct"; import { getStuConductTerm, sendConductWarning, queryDataByStuNo } from "/@/api/stuwork/stuconduct";
import { getClassListByRole } from "/@/api/basic/basicclass"; import { getClassListByRole } from "/@/api/basic/basicclass";
import { queryAllSchoolYear } from "/@/api/basic/basicyear"; import { queryAllSchoolYear } from "/@/api/basic/basicyear";
import { getDicts } from "/@/api/admin/dict"; import { getDicts } from "/@/api/admin/dict";
import { useMessage, useMessageBox } from "/@/hooks/message"; import { useMessage, useMessageBox } from "/@/hooks/message";
import { Search, Document } from '@element-plus/icons-vue';
// 表格样式 - 在组件内部定义,不从外部导入 // 表格样式
const tableStyle = { const tableStyle = {
cellStyle: { padding: '8px 0' }, cellStyle: { padding: '8px 0', textAlign: 'center' },
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }, headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold', textAlign: 'center' },
}; };
// 定义变量内容 // 定义变量内容
@@ -189,28 +209,73 @@ const queryForm = reactive({
classCode: '', classCode: '',
}); });
// 根据学期动态生成月份列
const monthColumns = computed(() => {
// 第一学期9月、10月、11月、12月、1月
// 第二学期2月、3月、4月、5月、6月
if (queryForm.schoolTerm === '1') {
return [
{ label: '9月', prop: 'scoreOneMonth' },
{ label: '10月', prop: 'scoreTwoMonth' },
{ label: '11月', prop: 'scoreThreeMonth' },
{ label: '12月', prop: 'scoreFourMonth' },
{ label: '1月', prop: 'scoreFiveMonth' },
];
} else if (queryForm.schoolTerm === '2') {
return [
{ label: '2月', prop: 'scoreSixMonth' },
{ label: '3月', prop: 'scoreSevenMonth' },
{ label: '4月', prop: 'scoreEightMonth' },
{ label: '5月', prop: 'scoreNineMonth' },
{ label: '6月', prop: 'scoreTenMonth' },
];
}
// 默认返回第一学期
return [
{ label: '9月', prop: 'scoreOneMonth' },
{ label: '10月', prop: 'scoreTwoMonth' },
{ label: '11月', prop: 'scoreThreeMonth' },
{ label: '12月', prop: 'scoreFourMonth' },
{ label: '1月', prop: 'scoreFiveMonth' },
];
});
// 格式化分数
const formatScore = (score: any) => {
if (score === null || score === undefined || score === '') return '-';
return Number(score).toFixed(2);
};
// 根据分数获取标签类型
const getScoreType = (score: any) => {
if (score === null || score === undefined) return 'info';
const num = Number(score);
if (num >= 90) return 'success';
if (num >= 80) return 'primary';
if (num >= 60) return 'warning';
return 'danger';
};
// 统计表格数据 // 统计表格数据
const statisticsData = computed(() => { const statisticsData = computed(() => {
if (studentList.value.length === 0) { if (studentList.value.length === 0) {
return []; return [];
} }
// 计算各等级人数 let excellent = 0;
// 优秀:>=90良好80-89及格60-79不及格<60 let good = 0;
let excellent = 0; // 优秀 let pass = 0;
let good = 0; // 良好 let fail = 0;
let pass = 0; // 及格
let fail = 0; // 不及格
const total = studentList.value.length; const total = studentList.value.length;
studentList.value.forEach((student: any) => { studentList.value.forEach((student: any) => {
const score = student.score; const score = student.scoreOneTerm;
if (score !== null && score !== undefined) { if (score !== null && score !== undefined) {
if (score >= 90) { if (Number(score) >= 90) {
excellent++; excellent++;
} else if (score >= 80) { } else if (Number(score) >= 80) {
good++; good++;
} else if (score >= 60) { } else if (Number(score) >= 60) {
pass++; pass++;
} else { } else {
fail++; fail++;
@@ -218,52 +283,19 @@ const statisticsData = computed(() => {
} }
}); });
// 计算比率
const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%'; const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%';
const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%'; const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%';
const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%'; const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%';
const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%'; const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%';
const excellentGoodRate = total > 0 ? (((excellent + good) / total) * 100).toFixed(2) + '%' : '0%';
// 优良率 = (优秀 + 良好) / 总人数
const excellentGoodCount = excellent + good;
const excellentGoodRate = total > 0 ? ((excellentGoodCount / total) * 100).toFixed(2) + '%' : '0%';
// 获取班级名称
const classNo = studentList.value.length > 0 ? studentList.value[0].classNo || '-' : '-'; const classNo = studentList.value.length > 0 ? studentList.value[0].classNo || '-' : '-';
return [ return [
{ { label: '人数', classNo, excellent, good, pass, fail },
label: '人数', { label: '比率', classNo, excellent: excellentRate, good: goodRate, pass: passRate, fail: failRate },
classNo: classNo, { label: '优良率', classNo, excellent: excellentGoodRate, good: '-', pass: '-', fail: '-' },
excellent: excellent, { label: '备注', classNo, excellent: '-', good: '-', pass: '-', fail: '-' },
good: good,
pass: pass,
fail: fail,
},
{
label: '比率',
classNo: classNo,
excellent: excellentRate,
good: goodRate,
pass: passRate,
fail: failRate,
},
{
label: '优良率',
classNo: classNo,
excellent: excellentGoodRate,
good: '-',
pass: '-',
fail: '-',
},
{
label: '备注',
classNo: classNo,
excellent: '-',
good: '-',
pass: '-',
fail: '-',
},
]; ];
}); });
@@ -283,34 +315,19 @@ const getDataList = async () => {
}); });
if (res.data && Array.isArray(res.data)) { if (res.data && Array.isArray(res.data)) {
// 处理返回数据提取学生列表 // 返回数据提取学生列表
// 根据API文档返回的是StuConductTermVO数组
const tempList: any[] = []; const tempList: any[] = [];
res.data.forEach((item: any) => { res.data.forEach((item: any) => {
// 如果返回的数据结构中有basicStudentVOList需要展开 if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList)) {
if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList) && item.basicStudentVOList.length > 0) {
item.basicStudentVOList.forEach((student: any) => { item.basicStudentVOList.forEach((student: any) => {
tempList.push({ tempList.push({
stuNo: student.stuNo || item.stuNo, ...student,
realName: student.realName || item.realName,
score: item.score, // 学期总评分数
classNo: item.classNo, classNo: item.classNo,
classCode: item.classCode, classCode: item.classCode,
}); });
}); });
} else {
// 直接使用item作为学生信息
tempList.push({
stuNo: item.stuNo,
realName: item.realName,
score: item.score,
classNo: item.classNo,
classCode: item.classCode,
});
} }
}); });
studentList.value = tempList; studentList.value = tempList;
} else { } else {
studentList.value = []; studentList.value = [];
@@ -338,7 +355,7 @@ const handleReset = () => {
studentList.value = []; studentList.value = [];
}; };
// 查看详情接口GET /stuwork/stuconduct/queryDataByStuNo按当前学年+学号拉取后筛本学期记录) // 查看详情
const handleView = async (row: any) => { const handleView = async (row: any) => {
if (!queryForm.schoolYear || !row.stuNo) { if (!queryForm.schoolYear || !row.stuNo) {
useMessage().warning('缺少学年或学号'); useMessage().warning('缺少学年或学号');
@@ -354,6 +371,7 @@ const handleView = async (row: any) => {
stuNo: row.stuNo, stuNo: row.stuNo,
}); });
const list = Array.isArray(res.data) ? res.data : []; const list = Array.isArray(res.data) ? res.data : [];
// 筛选当前学期的记录
const term = queryForm.schoolTerm; const term = queryForm.schoolTerm;
viewDetailList.value = term ? list.filter((r: any) => String(r.schoolTerm) === String(term)) : list; viewDetailList.value = term ? list.filter((r: any) => String(r.schoolTerm) === String(term)) : list;
} catch (_err) { } catch (_err) {
@@ -373,9 +391,7 @@ const handleSendWarning = async () => {
const { confirm } = useMessageBox(); const { confirm } = useMessageBox();
try { try {
await confirm( await confirm(
`确定要发送${queryForm.schoolYear}学年第${ `确定要发送${queryForm.schoolYear}学年第${queryForm.schoolTerm === '1' ? '一' : '二'}学期操行考核预警吗将向班主任推送不及格学生低于60分的预警通知。`
queryForm.schoolTerm === '1' ? '一' : '二'
}学期操行考核预警吗将向班主任推送不及格学生低于60分的预警通知。`
); );
warningLoading.value = true; warningLoading.value = true;
@@ -394,11 +410,7 @@ const handleSendWarning = async () => {
const getSchoolYearList = async () => { const getSchoolYearList = async () => {
try { try {
const res = await queryAllSchoolYear(); const res = await queryAllSchoolYear();
if (res.data && Array.isArray(res.data)) { schoolYearList.value = res.data && Array.isArray(res.data) ? res.data : [];
schoolYearList.value = res.data;
} else {
schoolYearList.value = [];
}
} catch (err) { } catch (err) {
schoolYearList.value = []; schoolYearList.value = [];
} }
@@ -425,11 +437,7 @@ const getSchoolTermDict = async () => {
const getClassListData = async () => { const getClassListData = async () => {
try { try {
const res = await getClassListByRole(); const res = await getClassListByRole();
if (res.data && Array.isArray(res.data)) { classList.value = res.data && Array.isArray(res.data) ? res.data : [];
classList.value = res.data;
} else {
classList.value = [];
}
} catch (err) { } catch (err) {
classList.value = []; classList.value = [];
} }
@@ -444,15 +452,7 @@ onMounted(() => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout-padding { @import '/@/assets/styles/modern-page.scss';
.layout-padding-auto {
.layout-padding-view {
.el-row {
margin-bottom: 20px;
}
}
}
}
.view-summary { .view-summary {
margin-bottom: 16px; margin-bottom: 16px;
@@ -462,19 +462,4 @@ onMounted(() => {
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
} }
// 确保页面可以滚动
.layout-padding {
height: 100%;
overflow-y: auto;
.layout-padding-auto {
height: 100%;
.layout-padding-view {
height: 100%;
overflow-y: auto;
}
}
}
</style> </style>

View File

@@ -1,9 +1,17 @@
<template> <template>
<div class="layout-padding"> <div class="modern-page-container">
<div class="layout-padding-auto layout-padding-view"> <div class="page-wrapper">
<!-- 搜索表单 --> <!-- 搜索表单卡片 -->
<el-row v-show="showSearch"> <el-card v-show="showSearch" class="search-card" shadow="never">
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList"> <template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Search /></el-icon>
筛选条件
</span>
</div>
</template>
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList" class="search-form">
<el-form-item label="学年" prop="schoolYear"> <el-form-item label="学年" prop="schoolYear">
<el-select v-model="queryForm.schoolYear" placeholder="请选择学年" clearable filterable style="width: 200px"> <el-select v-model="queryForm.schoolYear" placeholder="请选择学年" clearable filterable style="width: 200px">
<el-option v-for="item in schoolYearList" :key="item.year" :label="item.year" :value="item.year"> </el-option> <el-option v-for="item in schoolYearList" :key="item.year" :label="item.year" :value="item.year"> </el-option>
@@ -19,15 +27,25 @@
<el-button icon="Refresh" @click="handleReset">重置</el-button> <el-button icon="Refresh" @click="handleReset">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-row> </el-card>
<!-- 内容卡片 -->
<el-card class="content-card" shadow="never">
<template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Document /></el-icon>
学年操行考核统计
</span>
</div>
</template>
<!-- 统计表格 --> <!-- 统计表格 -->
<el-row style="margin-bottom: 20px">
<el-table <el-table
:data="statisticsData" :data="statisticsData"
v-loading="loading" v-loading="loading"
border stripe
style="width: 100%" style="width: 100%; margin-bottom: 20px"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :header-cell-style="tableStyle.headerCellStyle"
> >
@@ -38,60 +56,106 @@
<el-table-column prop="pass" label="及格" min-width="100" align="center" /> <el-table-column prop="pass" label="及格" min-width="100" align="center" />
<el-table-column prop="fail" label="不及格" min-width="100" align="center" /> <el-table-column prop="fail" label="不及格" min-width="100" align="center" />
</el-table> </el-table>
</el-row>
<!-- 学生列表表格 --> <!-- 学生列表表格 -->
<el-row>
<el-table <el-table
:data="studentList" :data="studentList"
v-loading="loading" v-loading="loading"
border stripe
:max-height="600" style="width: 100%"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :header-cell-style="tableStyle.headerCellStyle"
> >
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="70" align="center" fixed="left" />
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" /> <el-table-column prop="stuNo" label="学号" min-width="120" show-overflow-tooltip align="center" fixed="left" />
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" /> <el-table-column prop="realName" label="姓名" min-width="80" show-overflow-tooltip align="center" fixed="left" />
<el-table-column prop="score" label="学年总评" show-overflow-tooltip align="center"> <!-- 第一学期月份 -->
<el-table-column label="第一学期" align="center">
<el-table-column v-for="(month, index) in firstTermMonths" :key="'first-' + index" :label="month.label" min-width="60" align="center">
<template #default="scope"> <template #default="scope">
<span>{{ scope.row.score !== null && scope.row.score !== undefined ? scope.row.score.toFixed(2) : '-' }}</span> <span>{{ formatScore(scope.row[month.prop]) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="150" align="center" fixed="right"> <el-table-column label="学期评" min-width="70" align="center">
<template #default="scope"> <template #default="scope">
<el-button icon="View" text type="primary" @click="handleView(scope.row)"> 查看 </el-button> <el-tag :type="getScoreType(scope.row.scoreOneTerm)" size="small" effect="plain">
{{ formatScore(scope.row.scoreOneTerm) }}
</el-tag>
</template>
</el-table-column>
</el-table-column>
<!-- 第二学期月份 -->
<el-table-column label="第二学期" align="center">
<el-table-column v-for="(month, index) in secondTermMonths" :key="'second-' + index" :label="month.label" min-width="60" align="center">
<template #default="scope">
<span>{{ formatScore(scope.row[month.prop]) }}</span>
</template>
</el-table-column>
<el-table-column label="学期评" min-width="70" align="center">
<template #default="scope">
<el-tag :type="getScoreType(scope.row.scoreTwoTerm)" size="small" effect="plain">
{{ formatScore(scope.row.scoreTwoTerm) }}
</el-tag>
</template>
</el-table-column>
</el-table-column>
<!-- 学年总评 -->
<el-table-column prop="scoreYear" label="学年总评" min-width="100" align="center" fixed="right">
<template #default="scope">
<el-tag :type="getScoreType(scope.row.scoreYear)" size="small" effect="dark">
{{ formatScore(scope.row.scoreYear) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="center" fixed="right">
<template #default="scope">
<el-button icon="View" link type="primary" @click="handleView(scope.row)">查看</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-row> </el-card>
</div> </div>
<!-- 查看详情弹窗接口queryDataByStuNo 通过学年学号查看详情 --> <!-- 查看详情弹窗 -->
<el-dialog v-model="viewDialogVisible" title="学年操行考核详情" width="800px" destroy-on-close @close="viewDetailList = []"> <el-dialog v-model="viewDialogVisible" title="学年操行考核详情" width="900px" destroy-on-close @close="viewDetailList = []">
<div v-if="viewRow" class="view-summary"> <div v-if="viewRow" class="view-summary">
<el-descriptions :column="2" border size="small"> <el-descriptions :column="3" border size="small">
<el-descriptions-item label="学号">{{ viewRow.stuNo }}</el-descriptions-item> <el-descriptions-item label="学号">{{ viewRow.stuNo }}</el-descriptions-item>
<el-descriptions-item label="姓名">{{ viewRow.realName }}</el-descriptions-item> <el-descriptions-item label="姓名">{{ viewRow.realName }}</el-descriptions-item>
<el-descriptions-item label="学年">{{ queryForm.schoolYear }}</el-descriptions-item>
<el-descriptions-item label="学年总评"> <el-descriptions-item label="学年总评">
{{ viewRow.score != null && viewRow.score !== undefined ? Number(viewRow.score).toFixed(2) : '-' }} <el-tag :type="getScoreType(viewRow.scoreYear)" size="small">
{{ formatScore(viewRow.scoreYear) }}
</el-tag>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="第一学期">
<el-tag :type="getScoreType(viewRow.scoreOneTerm)" size="small" effect="plain">
{{ formatScore(viewRow.scoreOneTerm) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="第二学期">
<el-tag :type="getScoreType(viewRow.scoreTwoTerm)" size="small" effect="plain">
{{ formatScore(viewRow.scoreTwoTerm) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="学年">{{ queryForm.schoolYear }}</el-descriptions-item>
</el-descriptions> </el-descriptions>
</div> </div>
<div class="view-detail-title">考核记录</div> <div class="view-detail-title">考核记录</div>
<el-table <el-table
:data="viewDetailList" :data="viewDetailList"
v-loading="viewLoading" v-loading="viewLoading"
border stripe
size="small" size="small"
max-height="400" max-height="400"
:cell-style="tableStyle.cellStyle" :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :header-cell-style="tableStyle.headerCellStyle">
>
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="schoolTerm" label="学期" width="80" align="center" show-overflow-tooltip /> <el-table-column prop="schoolTerm" label="学期" width="80" align="center">
<el-table-column prop="recordDate" label="考核日期" width="110" align="center" show-overflow-tooltip /> <template #default="scope">
<el-tag size="small" effect="plain">{{ scope.row.schoolTerm === '1' ? '第一学期' : '第二学期' }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="recordDate" label="考核日期" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="conductType" label="类型" width="80" align="center"> <el-table-column prop="conductType" label="类型" width="80" align="center">
<template #default="scope"> <template #default="scope">
<el-tag :type="scope.row.conductType === '1' ? 'success' : 'danger'" size="small"> <el-tag :type="scope.row.conductType === '1' ? 'success' : 'danger'" size="small">
@@ -104,8 +168,8 @@
{{ scope.row.score != null && scope.row.score !== undefined ? Number(scope.row.score) : '-' }} {{ scope.row.score != null && scope.row.score !== undefined ? Number(scope.row.score) : '-' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="description" label="情况记录" min-width="140" show-overflow-tooltip /> <el-table-column prop="description" label="情况记录" min-width="150" show-overflow-tooltip />
<el-table-column prop="remarks" label="备注" min-width="100" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" min-width="120" show-overflow-tooltip />
</el-table> </el-table>
<template v-if="viewDetailList.length === 0 && !viewLoading"> <template v-if="viewDetailList.length === 0 && !viewLoading">
<el-empty description="暂无考核记录" :image-size="80" /> <el-empty description="暂无考核记录" :image-size="80" />
@@ -120,11 +184,12 @@ import { getStuConductYear, queryDataByStuNo } from '/@/api/stuwork/stuconduct';
import { getClassListByRole } from '/@/api/basic/basicclass'; import { getClassListByRole } from '/@/api/basic/basicclass';
import { queryAllSchoolYear } from '/@/api/basic/basicyear'; import { queryAllSchoolYear } from '/@/api/basic/basicyear';
import { useMessage } from '/@/hooks/message'; import { useMessage } from '/@/hooks/message';
import { Search, Document } from '@element-plus/icons-vue';
// 表格样式 - 在组件内部定义,不从外部导入 // 表格样式
const tableStyle = { const tableStyle = {
cellStyle: { padding: '8px 0' }, cellStyle: { padding: '8px 0', textAlign: 'center' },
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }, headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold', textAlign: 'center' },
}; };
// 定义变量内容 // 定义变量内容
@@ -145,28 +210,60 @@ const queryForm = reactive({
classCode: '', classCode: '',
}); });
// 第一学期月份列9月-1月
const firstTermMonths = [
{ label: '9月', prop: 'scoreOneMonth' },
{ label: '10月', prop: 'scoreTwoMonth' },
{ label: '11月', prop: 'scoreThreeMonth' },
{ label: '12月', prop: 'scoreFourMonth' },
{ label: '1月', prop: 'scoreFiveMonth' },
];
// 第二学期月份列2月-6月
const secondTermMonths = [
{ label: '2月', prop: 'scoreSixMonth' },
{ label: '3月', prop: 'scoreSevenMonth' },
{ label: '4月', prop: 'scoreEightMonth' },
{ label: '5月', prop: 'scoreNineMonth' },
{ label: '6月', prop: 'scoreTenMonth' },
];
// 格式化分数
const formatScore = (score: any) => {
if (score === null || score === undefined || score === '') return '-';
return Number(score).toFixed(2);
};
// 根据分数获取标签类型
const getScoreType = (score: any) => {
if (score === null || score === undefined) return 'info';
const num = Number(score);
if (num >= 90) return 'success';
if (num >= 80) return 'primary';
if (num >= 60) return 'warning';
return 'danger';
};
// 统计表格数据 // 统计表格数据
const statisticsData = computed(() => { const statisticsData = computed(() => {
if (studentList.value.length === 0) { if (studentList.value.length === 0) {
return []; return [];
} }
// 计算各等级人数 let excellent = 0;
// 优秀:>=90良好80-89及格60-79不及格<60 let good = 0;
let excellent = 0; // 优秀 let pass = 0;
let good = 0; // 良好 let fail = 0;
let pass = 0; // 及格
let fail = 0; // 不及格
const total = studentList.value.length; const total = studentList.value.length;
studentList.value.forEach((student: any) => { studentList.value.forEach((student: any) => {
const score = student.score; const score = student.scoreYear;
if (score !== null && score !== undefined) { if (score !== null && score !== undefined) {
if (score >= 90) { if (Number(score) >= 90) {
excellent++; excellent++;
} else if (score >= 80) { } else if (Number(score) >= 80) {
good++; good++;
} else if (score >= 60) { } else if (Number(score) >= 60) {
pass++; pass++;
} else { } else {
fail++; fail++;
@@ -174,52 +271,19 @@ const statisticsData = computed(() => {
} }
}); });
// 计算比率
const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%'; const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%';
const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%'; const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%';
const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%'; const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%';
const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%'; const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%';
const excellentGoodRate = total > 0 ? (((excellent + good) / total) * 100).toFixed(2) + '%' : '0%';
// 优良率 = (优秀 + 良好) / 总人数
const excellentGoodCount = excellent + good;
const excellentGoodRate = total > 0 ? ((excellentGoodCount / total) * 100).toFixed(2) + '%' : '0%';
// 获取班级名称
const classNo = studentList.value.length > 0 ? studentList.value[0].classNo || '-' : '-'; const classNo = studentList.value.length > 0 ? studentList.value[0].classNo || '-' : '-';
return [ return [
{ { label: '人数', classNo, excellent, good, pass, fail },
label: '人数', { label: '比率', classNo, excellent: excellentRate, good: goodRate, pass: passRate, fail: failRate },
classNo: classNo, { label: '优良率', classNo, excellent: excellentGoodRate, good: '-', pass: '-', fail: '-' },
excellent: excellent, { label: '备注', classNo, excellent: '-', good: '-', pass: '-', fail: '-' },
good: good,
pass: pass,
fail: fail,
},
{
label: '比率',
classNo: classNo,
excellent: excellentRate,
good: goodRate,
pass: passRate,
fail: failRate,
},
{
label: '优良率',
classNo: classNo,
excellent: excellentGoodRate,
good: '-',
pass: '-',
fail: '-',
},
{
label: '备注',
classNo: classNo,
excellent: '-',
good: '-',
pass: '-',
fail: '-',
},
]; ];
}); });
@@ -238,34 +302,18 @@ const getDataList = async () => {
}); });
if (res.data && Array.isArray(res.data)) { if (res.data && Array.isArray(res.data)) {
// 处理返回的数据,提取学生列表
// 根据API文档返回的是StuConductYearVO数组
const tempList: any[] = []; const tempList: any[] = [];
res.data.forEach((item: any) => { res.data.forEach((item: any) => {
// 如果返回的数据结构中有basicStudentVOList需要展开 if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList)) {
if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList) && item.basicStudentVOList.length > 0) {
item.basicStudentVOList.forEach((student: any) => { item.basicStudentVOList.forEach((student: any) => {
tempList.push({ tempList.push({
stuNo: student.stuNo || item.stuNo, ...student,
realName: student.realName || item.realName,
score: item.score, // 学年总评分数
classNo: item.classNo, classNo: item.classNo,
classCode: item.classCode, classCode: item.classCode,
}); });
}); });
} else {
// 直接使用item作为学生信息
tempList.push({
stuNo: item.stuNo,
realName: item.realName,
score: item.score,
classNo: item.classNo,
classCode: item.classCode,
});
} }
}); });
studentList.value = tempList; studentList.value = tempList;
} else { } else {
studentList.value = []; studentList.value = [];
@@ -285,7 +333,7 @@ const handleReset = () => {
studentList.value = []; studentList.value = [];
}; };
// 查看详情接口GET /stuwork/stuconduct/queryDataByStuNo通过学年学号查看详情 // 查看详情
const handleView = async (row: any) => { const handleView = async (row: any) => {
if (!queryForm.schoolYear || !row.stuNo) { if (!queryForm.schoolYear || !row.stuNo) {
useMessage().warning('缺少学年或学号'); useMessage().warning('缺少学年或学号');
@@ -312,11 +360,7 @@ const handleView = async (row: any) => {
const getSchoolYearList = async () => { const getSchoolYearList = async () => {
try { try {
const res = await queryAllSchoolYear(); const res = await queryAllSchoolYear();
if (res.data && Array.isArray(res.data)) { schoolYearList.value = res.data && Array.isArray(res.data) ? res.data : [];
schoolYearList.value = res.data;
} else {
schoolYearList.value = [];
}
} catch (err) { } catch (err) {
schoolYearList.value = []; schoolYearList.value = [];
} }
@@ -326,11 +370,7 @@ const getSchoolYearList = async () => {
const getClassListData = async () => { const getClassListData = async () => {
try { try {
const res = await getClassListByRole(); const res = await getClassListByRole();
if (res.data && Array.isArray(res.data)) { classList.value = res.data && Array.isArray(res.data) ? res.data : [];
classList.value = res.data;
} else {
classList.value = [];
}
} catch (err) { } catch (err) {
classList.value = []; classList.value = [];
} }
@@ -344,15 +384,7 @@ onMounted(() => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout-padding { @import '/@/assets/styles/modern-page.scss';
.layout-padding-auto {
.layout-padding-view {
.el-row {
margin-bottom: 20px;
}
}
}
}
.view-summary { .view-summary {
margin-bottom: 16px; margin-bottom: 16px;
@@ -362,19 +394,4 @@ onMounted(() => {
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
} }
// 确保页面可以滚动
.layout-padding {
height: 100%;
overflow-y: auto;
.layout-padding-auto {
height: 100%;
.layout-padding-view {
height: 100%;
overflow-y: auto;
}
}
}
</style> </style>