zhangjie 2 роки тому
батько
коміт
3b2f806279

+ 6 - 0
src/api/examwork-course.js

@@ -67,3 +67,9 @@ export function savePaper({ id = "", weight = "", audioPlayCount = "" }) {
 export function savePapers(papers) {
   return httpApp.post("/api/admin/exam/paper/save", papers);
 }
+
+export function searchUnionPapers(courseCode) {
+  return httpApp.post(
+    "/api/admin/exam/union/paper/query?" + object2QueryString({ courseCode })
+  );
+}

+ 35 - 2
src/features/examwork/CourseManagement/CoursePaperDialog.vue

@@ -25,7 +25,22 @@
       </div>
       <el-table :data="papers" stripe style="width: 100%;">
         <el-table-column label="试卷名称">
-          <span slot-scope="scope">{{ scope.row.name }}</span>
+          <template slot-scope="scope">
+            <el-select
+              v-if="scope.row.isHandleAdd"
+              v-model="scope.row.id"
+              placeholder="请选择"
+              @change="selectPaperChange(scope)"
+            >
+              <ol-option
+                v-for="paper in paperSources"
+                :key="paper.id"
+                :value="paper.id"
+                :label="paper.name"
+              ></ol-option>
+            </el-select>
+            <span v-else>{{ scope.row.name }}</span>
+          </template>
         </el-table-column>
         <el-table-column width="100" label="分值">
           <span slot-scope="scope">{{ scope.row.totalScore }}</span>
@@ -59,7 +74,7 @@
         <el-table-column label="操作" width="100">
           <div slot-scope="scope">
             <el-button size="mini" type="danger" plain @click="toDelete(scope)">
-              编辑
+              删除
             </el-button>
           </div>
         </el-table-column>
@@ -100,6 +115,7 @@ import {
   searchPapers,
   saveCourse,
   savePapers,
+  searchUnionPapers,
 } from "@/api/examwork-course";
 
 export default {
@@ -115,6 +131,7 @@ export default {
       refreshCourse: {},
       papers: [],
       loading: false,
+      paperSources: [],
     };
   },
   watch: {
@@ -123,11 +140,16 @@ export default {
       handler() {
         this.refreshCourse = {};
         this.papers = [];
+        this.getPaperSources();
         this.initData();
       },
     },
   },
   methods: {
+    async getPaperSources() {
+      const res = await searchUnionPapers(this.course.courseCode);
+      this.paperSources = res.data || [];
+    },
     async initData() {
       if (!this.course?.examId) return;
       const courseRes = await searchCourses({
@@ -159,11 +181,22 @@ export default {
         totalScore: null,
         weight: 100,
         audioPlayCount: 2,
+        isHandleAdd: true,
       });
     },
     toDelete({ $index }) {
       this.papers.splice($index, 1);
     },
+    selectPaperChange({ row, $index }) {
+      const sPapers = this.papers
+        .filter((item, index) => index !== $index)
+        .map((item) => item.id);
+      if (sPapers.includes(row.id)) {
+        row.id = null;
+        this.$message.error("当前试卷已经被选择!");
+        return;
+      }
+    },
     async submitForm() {
       try {
         const totalWieght = this.papers

+ 5 - 1
src/features/examwork/StudentExamDetail/PreviewPaperDialog.vue

@@ -194,7 +194,11 @@ export default {
       if (randomPaperStructPath.details.length) {
         studentPaperStructJson.details = randomPaperStructPath.details.map(
           (detail, dindex) => {
-            const rDetail = { ...paperStructJson.details[detail.number - 1] };
+            // const rDetail = { ...paperStructJson.details[detail.number - 1] };
+            const rDetail = paperStructJson.details.find(
+              (item) => item.number === detail.number
+            );
+            if (!rDetail) return;
             rDetail.number = dindex + 1;
             rDetail.questions = detail.questions.map((question, qindex) => {
               // 试题乱序