Răsfoiți Sursa

课程管理接口调试

zhangjie 1 an în urmă
părinte
comite
37d3c8168c

+ 38 - 33
src/modules/base/components/course-simple/CourseWeightManage.vue

@@ -95,7 +95,8 @@
         >
       </div>
       <el-table
-        :data="dataList"
+        v-if="resultDataList.length"
+        :data="resultDataList"
         :header-cell-style="{ textAlign: 'center' }"
         :cell-style="{ textAlign: 'center' }"
         :span-method="spanMethod"
@@ -121,8 +122,8 @@
           >
             <template slot-scope="scope">
               {{
-                scope.row.evaluation[eindex].enable
-                  ? scope.row.evaluation[eindex].targetScore
+                scope.row.evaluationList[eindex].enable
+                  ? scope.row.evaluationList[eindex].targetScore
                   : ""
               }}
             </template>
@@ -130,7 +131,7 @@
         </el-table-column>
         <el-table-column label="目标分值统计" width="120">
           <template slot-scope="scope">
-            {{ getEvaluationSumScore(scope.row.evaluation) }}
+            {{ getEvaluationSumScore(scope.row.evaluationList) }}
           </template>
         </el-table-column>
       </el-table>
@@ -140,7 +141,7 @@
 
 <script>
 import { courseWeightDetail, courseWeightSave } from "../../api";
-import { weightList } from "./targetData";
+// import { weightList } from "./targetData";
 import { omit, pick } from "lodash";
 import { calcSum } from "@/plugins/utils";
 
@@ -160,13 +161,14 @@ export default {
       tableSetData: [],
       targetTotalWeight: {},
       evaluationData: [],
+      resultDataList: [],
       loading: false,
     };
   },
   mounted() {
-    // this.getList();
-    this.dataList = weightList;
-    this.transformData(this.dataList);
+    this.getList();
+    // this.dataList = weightList;
+    // this.transformData(this.dataList);
   },
   methods: {
     async getList() {
@@ -174,39 +176,39 @@ export default {
         examId: this.course.examId,
         courseCode: this.course.courseCode,
       });
-      this.dataList = res.submitForm || [];
+      this.dataList = res || [];
       this.transformData(this.dataList);
     },
     transformData(data) {
       if (!data || !data.length) return [];
 
-      const evaluationList = [];
+      const tableSetData = [];
       const evaluationMap = {};
       const targetTotalWeight = {};
-      data[0].evaluation.forEach((item, index) => {
+      data[0].evaluationList.forEach((item, index) => {
         evaluationMap[item.evaluationName] = index;
       });
 
-      this.evaluationData = data[0].evaluation.map(
+      this.evaluationData = data[0].evaluationList.map(
         (item) => item.evaluationName
       );
 
       data.forEach((target) => {
         targetTotalWeight[target.courseTargetId] = target.totalWeight;
         const targetData = {
-          ...omit(target, ["evaluation"]),
+          ...omit(target, ["evaluationList"]),
           totalWeight: target.totalWeight || undefined,
         };
 
-        target.evaluation.forEach((item) => {
+        target.evaluationList.forEach((item) => {
           const index = evaluationMap[item.evaluationName];
-          if (!evaluationList[index]) {
-            evaluationList[index] = {
+          if (!tableSetData[index]) {
+            tableSetData[index] = {
               evaluationName: item.evaluationName,
               targets: [],
             };
           }
-          evaluationList[index].targets.push({
+          tableSetData[index].targets.push({
             ...targetData,
             enable: item.enable,
             weight: item.weight || undefined,
@@ -216,7 +218,7 @@ export default {
       });
 
       this.targetTotalWeight = targetTotalWeight;
-      this.tableSetData = evaluationList;
+      this.tableSetData = tableSetData;
     },
     usedChange(rowIndex, tindex) {
       const target = this.tableSetData[rowIndex].targets[tindex];
@@ -225,13 +227,13 @@ export default {
         target.targetScore = undefined;
       }
     },
-    getEvaluationSumScore(evaluation) {
+    getEvaluationSumScore(evaluationList) {
       return calcSum(
-        evaluation.map((item) => (item.enable ? item.targetScore : 0))
+        evaluationList.map((item) => (item.enable ? item.targetScore : 0))
       );
     },
     spanMethod({ rowIndex, columnIndex }) {
-      const lineCount = this.dataList.length - 1;
+      const lineCount = this.resultDataList.length - 1;
       if (rowIndex === lineCount) {
         if (columnIndex === 0) {
           return [1, 2];
@@ -256,7 +258,7 @@ export default {
 
       this.dataList.forEach((target) => {
         target.totalWeight = this.targetTotalWeight[target.courseTargetId];
-        target.evaluation.forEach((item) => {
+        target.evaluationList.forEach((item) => {
           const key = `${item.evaluationName}_${target.courseTargetId}`;
           Object.assign(item, evaluationData[key]);
         });
@@ -267,7 +269,7 @@ export default {
         (evaluationName, eindex) => {
           const targetScore = calcSum(
             this.dataList.map(
-              (item) => item.evaluation[eindex].targetScore || 0
+              (item) => item.evaluationList[eindex].targetScore || 0
             )
           );
           return {
@@ -278,15 +280,18 @@ export default {
           };
         }
       );
-      this.dataList.push({
-        courseTargetId: "total",
-        courseTargetName: "合计",
-        degreeRequirement: "",
-        totalWeight: calcSum(
-          this.dataList.map((item) => item.totalWeight || 0)
-        ),
-        evaluation: tatolEvaluation,
-      });
+      this.resultDataList = [
+        ...this.dataList,
+        {
+          courseTargetId: "total",
+          courseTargetName: "合计",
+          degreeRequirement: "",
+          totalWeight: calcSum(
+            this.dataList.map((item) => item.totalWeight || 0)
+          ),
+          evaluationList: tatolEvaluation,
+        },
+      ];
     },
     checkDataList() {
       if (!this.dataList.length) return;
@@ -303,7 +308,7 @@ export default {
       // 目标分值统计
       const weightList = [];
       this.dataList.forEach((item) => {
-        item.evaluation.forEach((ev) => {
+        item.evaluationList.forEach((ev) => {
           if (ev.enable) {
             weightList.push(ev.weight);
           }

+ 1 - 1
src/modules/base/components/course-simple/TeacherSimpleAssignCourseDialog.vue

@@ -57,7 +57,7 @@
 import { teacherSimpleCourseQuery, teacherSimpleAssignCourse } from "../../api";
 
 export default {
-  name: "select-dimension-dialog",
+  name: "teacher-simple-assign-course-dialog",
   props: {
     teacher: {
       type: Object,