zlwu 1 éve
szülő
commit
9f4668df93

+ 9 - 8
web/src/views/xskh/assessmentApplication/IndicatorDataDialog.vue

@@ -1,15 +1,15 @@
 <template>
   <el-dialog :title="`${indicatorName} - 学生数据详情`" v-model="dialogVisible" width="1000px" append-to-body destroy-on-close>
     <div v-loading="loading" element-loading-text="正在加载数据...">
-      <!-- 违纪处分记录区域 -->
-      <el-card class="mb-4" shadow="never">
+      <!-- 违纪处分记录区域 - 只有数据时才显示 -->
+      <el-card class="mb-4" shadow="never" v-if="disciplineRecords.length > 0">
         <template #header>
           <div class="card-header">
             <span>违纪处分记录</span>
             <el-tag type="danger" size="small">{{ disciplineRecords.length }} 条记录</el-tag>
           </div>
         </template>
-        <el-table :data="disciplineRecords" border style="width: 100%" v-if="disciplineRecords.length > 0">
+        <el-table :data="disciplineRecords" border style="width: 100%">
           <el-table-column label="违纪日期" prop="disciplineDate" width="120">
             <template #default="scope">
               {{ formatDate(scope.row.disciplineDate) }}
@@ -24,18 +24,17 @@
             </template>
           </el-table-column>
         </el-table>
-        <el-empty v-else description="暂无违纪处分记录" />
       </el-card>
 
-      <!-- 奖励记录区域 -->
-      <el-card shadow="never">
+      <!-- 奖励记录区域 - 只有数据时才显示 -->
+      <el-card shadow="never" v-if="rewardRecords.length > 0">
         <template #header>
           <div class="card-header">
             <span>奖励记录</span>
             <el-tag type="success" size="small">{{ rewardRecords.length }} 条记录</el-tag>
           </div>
         </template>
-        <el-table :data="rewardRecords" border style="width: 100%" v-if="rewardRecords.length > 0">
+        <el-table :data="rewardRecords" border style="width: 100%">
           <el-table-column label="奖励日期" prop="rewardDate" width="120">
             <template #default="scope">
               {{ formatDate(scope.row.rewardDate) }}
@@ -49,8 +48,10 @@
             </template>
           </el-table-column>
         </el-table>
-        <el-empty v-else description="暂无奖励记录" />
       </el-card>
+
+      <!-- 当没有任何数据时显示 -->
+      <el-empty v-if="disciplineRecords.length === 0 && rewardRecords.length === 0 && !loading" description="暂无相关数据记录" />
     </div>
   </el-dialog>
 </template>

+ 118 - 21
web/src/views/xskh/assessmentApproval/AssessmentApprovalForm.vue

@@ -67,10 +67,10 @@
               <el-card shadow="never">
                 <template #header>
                   <div class="card-header">
-                    <span>指标模块</span>
+                    <span>指标模块(基础分:100分)</span>
                   </div>
                 </template>
-                <el-table :data="form.selfScoreList" border style="width: 100%">
+                <el-table :data="sortedSelfScoreList" border style="width: 100%">
                   <el-table-column label="指标名称" prop="indicatorName" min-width="120">
                     <template #default="scope">
                       <div class="indicator-name-cell">
@@ -484,46 +484,130 @@ const isViewMode = computed(() => {
   return dialog.title === '查看考核申请' || form.value.status === '6';
 });
 
-/** 计算总得分 */
+// 计算排序后的指标列表
+const sortedSelfScoreList = computed(() => {
+  if (!form.value.selfScoreList || form.value.selfScoreList.length === 0) {
+    return [];
+  }
+
+  // 创建副本进行排序,避免修改原数据
+  const list = [...form.value.selfScoreList];
+
+  return list.sort((a, b) => {
+    const scoreA = parseFloat(String(a.selfScore || 0)) || 0;
+    const scoreB = parseFloat(String(b.selfScore || 0)) || 0;
+
+    // 如果A不为0,B为0,A排前面
+    if (scoreA !== 0 && scoreB === 0) return -1;
+    // 如果A为0,B不为0,B排前面
+    if (scoreA === 0 && scoreB !== 0) return 1;
+    // 如果都不为0,按分值倒序排列(高分在前)
+    if (scoreA !== 0 && scoreB !== 0) return scoreB - scoreA;
+    // 如果都为0,保持原顺序
+    return 0;
+  });
+});
+
+/** 计算总得分(新算分规则) */
 const calculateTotalScore = () => {
-  // 计算自评得分
-  let selfScore = 0;
+  // 第1步:基础分100分 - 指标模块的扣分,最小为0
+  const baseScore = 100;
+  let totalIndicatorDeduction = 0;
+  let totalIndicatorAddition = 0;
+
+  // 计算指标模块的总扣分和总加分
   if (form.value.selfScoreList && form.value.selfScoreList.length > 0) {
-    selfScore += form.value.selfScoreList.reduce((sum, item) => {
-      const score = parseFloat(String(item.selfScore || 0)) || 0;
-      return sum + score;
-    }, 0);
+    form.value.selfScoreList.forEach((item) => {
+      // 兼容性处理:如果存在 deductionScore 和 additionScore 字段,使用新算分规则
+      const itemWithNewFields = item as any; // 类型断言以访问可能的新字段
+      if (itemWithNewFields.deductionScore !== undefined || itemWithNewFields.additionScore !== undefined) {
+        const deduction = parseFloat(String(itemWithNewFields.deductionScore || 0)) || 0;
+        const addition = parseFloat(String(itemWithNewFields.additionScore || 0)) || 0;
+        totalIndicatorDeduction += deduction;
+        totalIndicatorAddition += addition;
+      } else {
+        // 兼容性处理:如果没有新字段,从 selfScore 推算(假设都是加分)
+        const score = parseFloat(String(item.selfScore || 0)) || 0;
+        if (score >= 0) {
+          totalIndicatorAddition += score;
+        } else {
+          totalIndicatorDeduction += Math.abs(score);
+        }
+      }
+    });
   }
 
+  // 第1步:基础分 - 扣分,结果不能小于0
+  let step1Score = baseScore - totalIndicatorDeduction;
+  if (step1Score < 0) {
+    step1Score = 0;
+  }
+
+  // 第2步:加上指标模块的加分
+  const step2Score = step1Score + totalIndicatorAddition;
+
+  // 第3步:加上附加分模块的分值(可正可负)
+  let totalBonusScore = 0;
   if (form.value.bonusApprovalList && form.value.bonusApprovalList.length > 0) {
-    selfScore += form.value.bonusApprovalList.reduce((sum, item) => {
+    totalBonusScore = form.value.bonusApprovalList.reduce((sum, item) => {
       const score = parseFloat(String(item.bonusScore || 0)) || 0;
       return sum + score;
     }, 0);
   }
 
-  form.value.selfScore = parseFloat(selfScore.toFixed(1));
+  // 最终自评得分
+  const finalSelfScore = step2Score + totalBonusScore;
+  form.value.selfScore = parseFloat(finalSelfScore.toFixed(1));
+
+  console.log(
+    `自评得分计算详情: 基础分=${baseScore}, 指标扣分=${totalIndicatorDeduction}, 第1步结果=${step1Score}, 指标加分=${totalIndicatorAddition}, 第2步结果=${step2Score}, 附加分=${totalBonusScore}, 最终得分=${form.value.selfScore}`
+  );
 
-  // 计算班主任评分
-  let teacherScore = 0;
+  // 班主任评分采用相同逻辑,但使用班主任的评分数据
+  let teacherTotalIndicatorDeduction = 0;
+  let teacherTotalIndicatorAddition = 0;
+
+  // 计算班主任对指标模块的评分
   if (form.value.selfScoreList && form.value.selfScoreList.length > 0) {
-    teacherScore += form.value.selfScoreList.reduce((sum, item) => {
-      const score = parseFloat(String(item.teacherScore || 0)) || 0;
-      return sum + score;
-    }, 0);
+    form.value.selfScoreList.forEach((item) => {
+      const teacherScore = parseFloat(String(item.teacherScore || 0)) || 0;
+      // 班主任评分:负数视为扣分,正数视为加分
+      if (teacherScore < 0) {
+        teacherTotalIndicatorDeduction += Math.abs(teacherScore);
+      } else {
+        teacherTotalIndicatorAddition += teacherScore;
+      }
+    });
+  }
+
+  // 第1步:基础分 - 班主任评定的扣分
+  let teacherStep1Score = baseScore - teacherTotalIndicatorDeduction;
+  if (teacherStep1Score < 0) {
+    teacherStep1Score = 0;
   }
 
+  // 第2步:加上班主任评定的加分
+  const teacherStep2Score = teacherStep1Score + teacherTotalIndicatorAddition;
+
+  // 第3步:加上附加分模块的审核得分
+  let totalApprovalScore = 0;
   if (form.value.bonusApprovalList && form.value.bonusApprovalList.length > 0) {
-    teacherScore += form.value.bonusApprovalList.reduce((sum, item) => {
+    totalApprovalScore = form.value.bonusApprovalList.reduce((sum, item) => {
       const score = parseFloat(String(item.approvalScore || 0)) || 0;
       return sum + score;
     }, 0);
   }
 
-  form.value.teacherScore = parseFloat(teacherScore.toFixed(1));
+  // 最终班主任评分
+  const finalTeacherScore = teacherStep2Score + totalApprovalScore;
+  form.value.teacherScore = parseFloat(finalTeacherScore.toFixed(1));
 
   // 总得分等于班主任评分
-  form.value.totalScore = parseFloat(teacherScore.toFixed(1));
+  form.value.totalScore = parseFloat(finalTeacherScore.toFixed(1));
+
+  console.log(
+    `班主任评分计算详情: 基础分=${baseScore}, 指标扣分=${teacherTotalIndicatorDeduction}, 第1步结果=${teacherStep1Score}, 指标加分=${teacherTotalIndicatorAddition}, 第2步结果=${teacherStep2Score}, 附加审核分=${totalApprovalScore}, 最终得分=${form.value.teacherScore}`
+  );
 };
 
 /** 获取状态标签类型 */
@@ -1465,11 +1549,24 @@ defineExpose({
 .indicator-name-cell {
   display: flex;
   align-items: center;
-  gap: 8px;
+  gap: 6px;
+}
+
+.indicator-name-cell span {
+  flex: 1;
+  font-size: inherit;
 }
 
 .indicator-data-btn {
   flex-shrink: 0;
   margin-left: 4px;
+  transform: scale(0.7);
+  opacity: 0.7;
+}
+
+.indicator-data-btn:hover {
+  transform: scale(0.8);
+  opacity: 1;
+  transition: all 0.2s ease;
 }
 </style>