zhangjie 1 год назад
Родитель
Сommit
cff266b729

+ 17 - 0
src/modules/target/components/target-score/SetBlueDialog.vue

@@ -57,6 +57,7 @@
           </template>
         </el-table-column>
       </el-table>
+      <div v-if="totalInfo" class="mt-2">{{ totalInfo }}</div>
       <div slot="footer">
         <el-button type="primary" :disabled="isSubmit" @click="submit"
           >确认</el-button
@@ -104,6 +105,7 @@ export default {
       selectedData: [],
       treeData: [],
       loading: false,
+      totalInfo: "",
     };
   },
   watch: {
@@ -139,6 +141,7 @@ export default {
         courseId: this.course.courseId,
       });
       this.dataList = res || [];
+      this.updateTotalInfo();
     },
     visibleChange() {
       this.getBlueDetail();
@@ -188,6 +191,20 @@ export default {
     dimensionSelected(targetList) {
       this.curRow.targetList = targetList;
       this.curRow.courseTargetName = targetList[0].targetName;
+      this.updateTotalInfo();
+    },
+    updateTotalInfo() {
+      const data = {};
+      this.dataList.forEach((item) => {
+        const target = item.targetList[0];
+        if (!target) return;
+
+        if (!data[target.targetName]) data[target.targetName] = 0;
+        data[target.targetName] += item.score;
+      });
+      this.totalInfo = Object.keys(data)
+        .map((key) => `${key}共${data[key]}分`)
+        .join(",");
     },
     async submit() {
       if (!this.checkData()) {

+ 28 - 7
src/modules/target/components/target-statistics/DetailTargetStatistics.vue

@@ -328,9 +328,13 @@
             :label="target.targetName"
             align="center"
           >
-            <el-table-column width="140" align="center">
+            <el-table-column
+              v-if="target.finalDimensions.length"
+              width="140"
+              align="center"
+            >
               <template slot="header">
-                期末考试({{ target.finalWeight | percentFilter }})
+                期末考试 <br />({{ target.finalWeight | percentFilter }})
               </template>
               <el-table-column
                 label="期末成绩"
@@ -340,9 +344,13 @@
               >
               </el-table-column>
             </el-table-column>
-            <el-table-column min-width="120" align="center">
+            <el-table-column
+              v-if="target.usualWorks.length"
+              min-width="120"
+              align="center"
+            >
               <template slot="header">
-                平时考试({{ target.usualWeight | percentFilter }})
+                平时考试<br />({{ target.usualWeight | percentFilter }})
               </template>
               <el-table-column
                 v-for="work in target.usualWorks"
@@ -748,7 +756,7 @@ export default {
           usualWeight: target.usualScore?.targetWeight,
           evaluationValue: targetVals[target.targetId],
         };
-        ntarget.finalDimensions = ["期末成绩"];
+        ntarget.finalDimensions = target.finalScore ? ["期末成绩"] : [];
         ntarget.usualWorks = (target.usualScore?.scoreList || []).map(
           (item) => item.evaluation
         );
@@ -757,6 +765,10 @@ export default {
         );
         return ntarget;
       });
+      // 只展示有期末成绩或平时成绩的目标
+      this.courseTargets = this.courseTargets.filter(
+        (item) => item.finalDimensions.length || item.usualWorks.length
+      );
 
       let tCount = 0;
       this.targetColumnCounts = tColumnCounts.map((item) => {
@@ -764,7 +776,15 @@ export default {
         return tCount;
       });
     },
+    getTargetFirseKey(target) {
+      if (target.finalDimensions.length) {
+        return `${target.targetId}-final`;
+      } else {
+        return `${target.targetId}-usual-${target.usualWorks[0]}`;
+      }
+    },
     parseStudentScoreTable(examStudentList) {
+      if (!this.courseTargets.length) return;
       const lastIndex = examStudentList.length - 1;
       const studentScoreTable = examStudentList.map((student, sindex) => {
         const nitem = {
@@ -794,14 +814,15 @@ export default {
         score: "",
       };
       this.courseTargets.forEach((target) => {
-        targetData[`${target.targetId}-final`] = target.evaluationValue;
+        targetData[this.getTargetFirseKey(target)] = target.evaluationValue;
       });
       studentScoreTable.push(targetData);
 
       const fTarget = this.courseTargets[0];
+      const fKey = this.getTargetFirseKey(fTarget);
       studentScoreTable.push({
         name: "课程达成度",
-        [`${fTarget.targetId}-final`]: this.courseTargetValue,
+        [fKey]: this.courseTargetValue,
       });
       this.studentScoreTable = studentScoreTable;
     },