|
|
@@ -157,7 +157,14 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item>
|
|
|
- <el-button type="info" plain @click="handleViewStudentViolations">学生违规处分信息查看</el-button>
|
|
|
+ <el-button
|
|
|
+ :type="studentRecordsData ? 'success' : 'info'"
|
|
|
+ :plain="!studentRecordsData"
|
|
|
+ @click="handleViewStudentViolations"
|
|
|
+ >
|
|
|
+ <i :class="studentRecordsData ? 'el-icon-check' : 'el-icon-view'" style="margin-right: 4px;"></i>
|
|
|
+ {{ studentRecordsData ? '查看已加载的违规处分信息' : '学生违规处分信息查看' }}
|
|
|
+ </el-button>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -340,6 +347,28 @@
|
|
|
<el-tabs v-model="studentRecordsActiveTab" type="border-card" style="margin-top: 16px">
|
|
|
<!-- 违纪记录Tab -->
|
|
|
<el-tab-pane label="违纪记录" name="discipline">
|
|
|
+ <!-- 扣分汇总信息 -->
|
|
|
+ <el-row :gutter="20" style="margin-bottom: 16px;">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-alert
|
|
|
+ :title="`违纪记录扣分汇总: ${calculateTotalDeduction()} 分 (生效记录: ${getEffectiveDisciplineRecords().length} 条)`"
|
|
|
+ type="warning"
|
|
|
+ :closable="false"
|
|
|
+ show-icon
|
|
|
+ />
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8" style="text-align: right;">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="Refresh"
|
|
|
+ @click="applyDeductionToClassScore"
|
|
|
+ :disabled="calculateTotalDeduction() === 0"
|
|
|
+ >
|
|
|
+ 重新同步到班级扣分
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
<el-table :data="studentRecordsData?.disciplineRecords || []" border style="width: 100%" max-height="400" empty-text="暂无违纪记录">
|
|
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
|
|
<el-table-column prop="studentNo" label="学号" min-width="120" align="center" />
|
|
|
@@ -354,7 +383,12 @@
|
|
|
<el-table-column prop="disciplineContent" label="处分内容" min-width="200" :show-overflow-tooltip="true" />
|
|
|
<el-table-column prop="scoreDeduction" label="扣分" min-width="80" align="center">
|
|
|
<template #default="scope">
|
|
|
- <el-tag type="danger" size="small">{{ scope.row.scoreDeduction || 0 }}</el-tag>
|
|
|
+ <el-tag
|
|
|
+ :type="scope.row.status === '1' ? 'danger' : 'info'"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ {{ scope.row.scoreDeduction || 0 }}
|
|
|
+ </el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="status" label="状态" min-width="80" align="center">
|
|
|
@@ -406,6 +440,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="SubmitDialog" lang="ts">
|
|
|
+import { watch, nextTick } from 'vue';
|
|
|
import { getAssessmentSubmitDetail, submitAssessmentScore, submitAssessment, getClassStudentRecords } from '@/api/bzrkh/teacherAssessment';
|
|
|
import {
|
|
|
AssessmentDetailVO,
|
|
|
@@ -652,6 +687,9 @@ const loadAssessmentDetail = async () => {
|
|
|
overallComment: monthlyScoreForm.overallComment
|
|
|
});
|
|
|
console.log('==================');
|
|
|
+
|
|
|
+ // 自动加载学生违规处分信息数据
|
|
|
+ await autoLoadStudentRecords();
|
|
|
} catch (error) {
|
|
|
console.error('加载考核详情失败:', error);
|
|
|
proxy?.$modal.msgError('加载考核详情失败,请检查网络连接或刷新页面重试');
|
|
|
@@ -663,7 +701,28 @@ const loadAssessmentDetail = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-/** 查看学生违规处分信息 */
|
|
|
+/** 自动加载学生违规处分信息数据(后台加载,不显示弹窗) */
|
|
|
+const autoLoadStudentRecords = async () => {
|
|
|
+ if (!props.classId || !props.planId) {
|
|
|
+ console.warn('缺少必要参数(班级ID或计划ID),跳过自动加载学生违规处分数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('🔄 开始自动加载学生违规处分数据...');
|
|
|
+ try {
|
|
|
+ const res = await getClassStudentRecords(props.classId, props.planId);
|
|
|
+ studentRecordsData.value = res.data;
|
|
|
+
|
|
|
+ // 自动同步违纪记录扣分到班级扣分字段(不显示提示消息)
|
|
|
+ autoSyncDeductionToClassScore(false);
|
|
|
+ console.log('✅ 学生违规处分数据自动加载完成');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('❌ 自动加载学生违规处分数据失败:', error);
|
|
|
+ // 静默失败,不显示错误提示(避免影响主要功能)
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 查看学生违规处分信息(点击按钮时调用) */
|
|
|
const handleViewStudentViolations = async () => {
|
|
|
if (!props.classId || !props.planId) {
|
|
|
proxy?.$modal.msgError('缺少必要参数(班级ID或计划ID)');
|
|
|
@@ -675,9 +734,19 @@ const handleViewStudentViolations = async () => {
|
|
|
|
|
|
studentRecordsLoading.value = true;
|
|
|
try {
|
|
|
- const res = await getClassStudentRecords(props.classId, props.planId);
|
|
|
- studentRecordsData.value = res.data;
|
|
|
- studentRecordsVisible.value = true;
|
|
|
+ // 如果数据已经加载过,直接显示弹窗
|
|
|
+ if (studentRecordsData.value?.disciplineRecords || studentRecordsData.value?.rewardRecords) {
|
|
|
+ studentRecordsVisible.value = true;
|
|
|
+ console.log('📋 使用已加载的学生违规处分数据显示弹窗');
|
|
|
+ } else {
|
|
|
+ // 否则重新加载数据
|
|
|
+ const res = await getClassStudentRecords(props.classId, props.planId);
|
|
|
+ studentRecordsData.value = res.data;
|
|
|
+ studentRecordsVisible.value = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 手动查看时也重新同步一次扣分(显示提示消息)
|
|
|
+ autoSyncDeductionToClassScore(true);
|
|
|
} catch (error) {
|
|
|
console.error('查询学生违纪记录和奖励记录失败:', error);
|
|
|
proxy?.$modal.msgError('查询学生违纪记录和奖励记录失败');
|
|
|
@@ -686,6 +755,73 @@ const handleViewStudentViolations = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+/** 获取生效的违纪记录 */
|
|
|
+const getEffectiveDisciplineRecords = () => {
|
|
|
+ if (!studentRecordsData.value?.disciplineRecords) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ // 只统计状态为'1'(生效)的违纪记录
|
|
|
+ return studentRecordsData.value.disciplineRecords.filter(record => record.status === '1');
|
|
|
+};
|
|
|
+
|
|
|
+/** 计算违纪记录总扣分 */
|
|
|
+const calculateTotalDeduction = () => {
|
|
|
+ const effectiveRecords = getEffectiveDisciplineRecords();
|
|
|
+ return effectiveRecords.reduce((total, record) => {
|
|
|
+ const deduction = Number(record.scoreDeduction) || 0;
|
|
|
+ return total + deduction;
|
|
|
+ }, 0);
|
|
|
+};
|
|
|
+
|
|
|
+/** 自动同步违纪记录扣分到班级扣分字段 */
|
|
|
+const autoSyncDeductionToClassScore = (showMessage = true) => {
|
|
|
+ const totalDeduction = calculateTotalDeduction();
|
|
|
+
|
|
|
+ // 自动将汇总的扣分设置到班级扣分字段
|
|
|
+ managementEffectivenessForm.classDeduction = totalDeduction;
|
|
|
+ // 自动计算50%计
|
|
|
+ calculateDeductionHalf();
|
|
|
+
|
|
|
+ if (totalDeduction > 0 && showMessage) {
|
|
|
+ proxy?.$modal.msgSuccess(`已自动同步违纪记录扣分汇总 ${totalDeduction} 分到班级扣分字段`);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 监听学生违纪记录数据变化,自动同步扣分
|
|
|
+watch(() => studentRecordsData.value?.disciplineRecords, (newRecords) => {
|
|
|
+ if (newRecords && studentRecordsVisible.value) {
|
|
|
+ // 延迟执行,确保数据完全加载,但不显示提示消息
|
|
|
+ nextTick(() => {
|
|
|
+ autoSyncDeductionToClassScore(false);
|
|
|
+ });
|
|
|
+ }
|
|
|
+}, { deep: true });
|
|
|
+
|
|
|
+/** 将违纪记录扣分汇总应用到班级扣分字段 */
|
|
|
+const applyDeductionToClassScore = () => {
|
|
|
+ const totalDeduction = calculateTotalDeduction();
|
|
|
+
|
|
|
+ if (totalDeduction === 0) {
|
|
|
+ proxy?.$modal.msgWarning('当前没有生效的违纪记录扣分可以应用');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确认应用操作
|
|
|
+ proxy?.$modal.confirm(`确定要将违纪记录扣分汇总 ${totalDeduction} 分重新应用到班级扣分字段吗?`).then(() => {
|
|
|
+ // 将汇总的扣分设置到班级扣分字段
|
|
|
+ managementEffectivenessForm.classDeduction = totalDeduction;
|
|
|
+ // 自动计算50%计
|
|
|
+ calculateDeductionHalf();
|
|
|
+
|
|
|
+ proxy?.$modal.msgSuccess(`已重新应用违纪记录扣分汇总 ${totalDeduction} 分到班级扣分字段`);
|
|
|
+
|
|
|
+ // 关闭学生记录弹窗
|
|
|
+ studentRecordsVisible.value = false;
|
|
|
+ }).catch(() => {
|
|
|
+ // 用户取消操作
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
/** 保存考核数据 */
|
|
|
const handleSubmit = async () => {
|
|
|
try {
|