Переглянути джерело

feat: 电子交卷选择答题卡

zhangjie 11 місяців тому
батько
коміт
b0fdf1cb00

+ 57 - 4
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -167,12 +167,23 @@
                 v-model="attachment.cardId"
                 placeholder="请选择"
                 style="width: 260px; margin-right: 10px"
+                @change="(val) => tkCardChange(val, attachment)"
               >
                 <el-option
-                  v-if="attachment.cardId"
-                  :value="attachment.cardId"
-                  :label="attachment.cardTitle"
+                  v-for="item in attachment.cards"
+                  :key="item.id"
+                  :value="item.id"
+                  :label="item.title"
                 >
+                  <div class="box-justify">
+                    <div class="box-grow">{{ item.title }}</div>
+                    <el-button
+                      class="btn-danger btn-icon box-static"
+                      type="text"
+                      icon="el-icon-remove"
+                      @click="toDeleteCard(item, attachment)"
+                    ></el-button>
+                  </div>
                 </el-option>
               </el-select>
               <el-button
@@ -394,7 +405,11 @@ import ModifyCard from "../../../card/components/ModifyCard.vue";
 import SelectTikuPaperDialog from "./SelectTikuPaperDialog.vue";
 import { COMMON_CARD_RULE_ID } from "../../../../constants/enumerate";
 import { cardForSelectList } from "../../api";
-import { courseQuery, examConfigByExamIdOrgId } from "../../../base/api";
+import {
+  courseQuery,
+  deleteCard,
+  examConfigByExamIdOrgId,
+} from "../../../base/api";
 import { copyCard } from "../../../card/api";
 
 import CardBuildDialog from "../../../card/components/CardBuildDialog.vue";
@@ -584,6 +599,20 @@ export default {
         this.cards = this.cards.filter((item) => item.type === "GENERIC");
       }
     },
+    async getTkCardList(attachment) {
+      if (
+        !this.examTask.courseId ||
+        !this.examTask.examId ||
+        !attachment.paperId
+      )
+        return;
+      const data = await cardForSelectList({
+        courseId: this.examTask.courseId,
+        examId: this.examTask.examId,
+        paperId: attachment.paperId,
+      });
+      attachment.cards = data || [];
+    },
     async getCourses() {
       if (!this.examTask.teachingRoomId || !this.examTask.examId) return;
       const res = await courseQuery({
@@ -741,6 +770,7 @@ export default {
           (item) => item.name === this.curAttachment.name
         );
         this.paperAttachments[aind].cardTitle = data.title;
+        await this.getTkCardList(this.curAttachment);
         return;
       }
 
@@ -759,6 +789,27 @@ export default {
         this.paperAttachments[aind].createId = card.createId;
       }
     },
+    tkCardChange(card, attachment) {
+      attachment.cardTitle = card.title;
+    },
+    async toDeleteCard(card, attachment) {
+      const confirm = await this.$confirm(
+        `确定要删除题卡【${card.title}】吗?`,
+        "提示",
+        {
+          type: "warning",
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      await deleteCard(card.id);
+      this.$message.success("删除成功!");
+      attachment.cards = attachment.cards.filter((item) => item.id !== card.id);
+      if (attachment.cardId === card.id) {
+        attachment.cardId = null;
+        attachment.cardTitle = "";
+      }
+    },
     async checkData() {
       const valid = await this.$refs.examTaskComp.validate().catch(() => {});
       if (!valid) return Promise.reject();
@@ -876,6 +927,7 @@ export default {
         attachmentId: info.attachmentId,
         paperUrl: info.paperUrl,
       });
+      this.getTkCardList(this.paperAttachments[ind]);
     },
     toViewPaper(attachment) {
       if (!attachment.paperUrl) return;
@@ -900,6 +952,7 @@ export default {
         used: false,
         createId: null,
       };
+      if (this.IS_TIKU_TAB) newAttachment.cards = [];
       this.paperAttachments.push(newAttachment);
     },
     deleteAttachment(index) {

+ 59 - 3
src/modules/exam/components/taskApply/TaskPaper.vue

@@ -34,6 +34,7 @@
           <span class="color-gray-2" v-if="attachment.isExposed">(已曝光)</span>
         </td>
         <template v-if="IS_TIKU_TAB">
+          <!-- 试卷文件 -->
           <td>
             <template v-if="!attachment.isExposed && taskStatus.IS_APPLY">
               <div class="box-justify">
@@ -78,18 +79,30 @@
               </div>
             </el-button>
           </td>
+          <!-- 答题卡 -->
           <td>
             <template v-if="taskStatus.IS_APPLY">
               <el-select
                 v-model="attachment.cardId"
                 placeholder="请选择"
                 style="width: 260px; margin-right: 10px"
+                @change="(val) => tkCardChange(val, attachment)"
               >
                 <el-option
-                  v-if="attachment.cardId"
-                  :value="attachment.cardId"
-                  :label="attachment.cardTitle"
+                  v-for="item in attachment.cards"
+                  :key="item.id"
+                  :value="item.id"
+                  :label="item.title"
                 >
+                  <div class="box-justify">
+                    <div class="box-grow">{{ item.title }}</div>
+                    <el-button
+                      class="btn-danger btn-icon box-static"
+                      type="text"
+                      icon="el-icon-remove"
+                      @click="toDeleteCard(item, attachment)"
+                    ></el-button>
+                  </div>
                 </el-option>
               </el-select>
               <el-button
@@ -123,6 +136,7 @@
           </td>
         </template>
         <template v-else>
+          <!-- 试卷文件 -->
           <td>
             <el-button
               v-if="!attachment.isExposed && taskStatus.IS_APPLY"
@@ -161,6 +175,7 @@
               </div>
             </el-button>
           </td>
+          <!-- 答题卡 -->
           <td>
             <template v-if="taskStatus.IS_APPLY">
               <el-select
@@ -261,6 +276,7 @@
             </el-button>
           </td>
         </template>
+        <!-- 操作 -->
         <td
           v-if="taskStatus.IS_APPLY && !taskStatus.IS_REBUILD"
           class="text-right"
@@ -398,6 +414,7 @@ import { mapState, mapMutations, mapActions } from "vuex";
 
 import { cardForSelectList } from "../../api";
 import { attachmentPreview } from "../../../login/api";
+import { deleteCard } from "../../../base/api";
 import { copyCard } from "../../../card/api";
 
 import UploadPaperDialog from "../UploadPaperDialog.vue";
@@ -535,6 +552,20 @@ export default {
         this.cards = this.cards.filter((item) => item.type === "GENERIC");
       }
     },
+    async getTkCardList(attachment) {
+      if (
+        !this.curTaskApply.courseId ||
+        !this.curTaskApply.examId ||
+        !attachment.paperId
+      )
+        return;
+      const data = await cardForSelectList({
+        courseId: this.curTaskApply.courseId,
+        examId: this.curTaskApply.examId,
+        paperId: attachment.paperId,
+      });
+      attachment.cards = data || [];
+    },
     addAtachment() {
       if (this.paperAttachments.length >= this.attachmentLimitCount) return;
 
@@ -556,6 +587,7 @@ export default {
         used: false,
         createId: null,
       };
+      if (this.IS_TIKU_TAB) newAttachment.cards = [];
       this.paperAttachments.push(newAttachment);
     },
     deleteAttachment(index) {
@@ -645,6 +677,8 @@ export default {
           (item) => item.name === this.curAttachment.name
         );
         this.paperAttachments[aind].cardTitle = data.title;
+        await this.getTkCardList(this.curAttachment);
+
         return;
       }
 
@@ -673,6 +707,27 @@ export default {
         attachment.createId = card.createId;
       }
     },
+    tkCardChange(card, attachment) {
+      attachment.cardTitle = card.title;
+    },
+    async toDeleteCard(card, attachment) {
+      const confirm = await this.$confirm(
+        `确定要删除题卡【${card.title}】吗?`,
+        "提示",
+        {
+          type: "warning",
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      await deleteCard(card.id);
+      this.$message.success("删除成功!");
+      attachment.cards = attachment.cards.filter((item) => item.id !== card.id);
+      if (attachment.cardId === card.id) {
+        attachment.cardId = null;
+        attachment.cardTitle = "";
+      }
+    },
     async toCreateCard(attachment) {
       if (!this.examTask.cardRuleId) {
         this.$message.error("题卡规则缺失!");
@@ -758,6 +813,7 @@ export default {
         attachmentId: info.attachmentId,
         paperUrl: info.paperUrl,
       });
+      this.getTkCardList(this.paperAttachments[ind]);
     },
     toViewPaper(attachment) {
       if (!attachment.paperUrl) return;