zhangjie 8 ماه پیش
والد
کامیت
07530d8800

+ 9 - 8
src/modules/exam/components/createExamAndPrintTask/CreateExamAndPrintTask.vue

@@ -116,16 +116,9 @@ const initExamTask = {
   teacherName: "",
   paperName: "",
   uuid: "",
-};
-
-const initExamTaskDetail = {
-  operateType: "STAGE",
-  paperType: "A",
-  paperAttachmentIds: "[]",
+  openAb: false,
   paperConfirmAttachmentIds: "[]",
-  drawCount: 2,
   remark: "",
-  makeMethod: "SELECT",
   // 题卡状态
   status: "",
   // 考务规则
@@ -134,6 +127,14 @@ const initExamTaskDetail = {
   customCard: false,
 };
 
+// const examTaskDetailItem = {
+//   serialNumber: 1,
+//   paperType: "A",
+//   paperAttachmentIds: "[]",
+// };
+
+const initExamTaskDetail = []; // examTaskDetailItem[]
+
 const initPrintPlan = {
   printContent: [],
   backupMethod: "ROOM",

+ 348 - 273
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -85,6 +85,16 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="启用AB卷:">
+              <el-switch
+                v-model="examTask.openAb"
+                @change="openAbChange"
+              ></el-switch>
+            </el-form-item>
+          </el-col>
+        </el-row>
       </el-form>
     </div>
 
@@ -106,12 +116,14 @@
         <table class="table mb-2">
           <colgroup>
             <col width="90" />
+            <col width="60" />
             <col width="280" />
             <col />
             <col v-if="!IS_REBUILD" width="80" />
           </colgroup>
           <tr>
-            <th>试卷类型</th>
+            <th>备用卷</th>
+            <th>卷型</th>
             <th>试卷文件</th>
             <th>
               答题卡
@@ -121,15 +133,50 @@
             </th>
             <th v-if="!IS_REBUILD">操作</th>
           </tr>
-          <tr v-for="(attachment, index) in paperAttachments" :key="index">
-            <td>{{ attachment.name }}卷</td>
+          <template v-for="(paperAttachment, pindex) in paperAttachments">
+            <tr
+              v-for="(attachment, index) in paperAttachment.paperAttachmentIds"
+              :key="`${pindex}-${index}`"
+            >
+              <td
+                v-if="index === 0"
+                :rowspan="paperAttachment.paperAttachmentIds.length"
+              >
+                卷{{ paperAttachment.serialNumber }}
+              </td>
+              <td>{{ attachment.name }}</td>
 
-            <td v-if="IS_TIKU_TAB">
-              <div class="box-justify">
+              <td v-if="IS_TIKU_TAB">
+                <div class="box-justify">
+                  <el-button
+                    type="text"
+                    class="btn-primary box-grow"
+                    @click="toSelect(attachment)"
+                  >
+                    <i
+                      :class="[
+                        'icon',
+                        attachment.attachmentId
+                          ? 'icon-files-act'
+                          : 'icon-files',
+                      ]"
+                    ></i
+                    >{{ attachment.filename || "选择试卷" }}
+                  </el-button>
+                  <el-button
+                    type="text"
+                    class="btn-primary box-static"
+                    :disabled="!attachment.paperUrl"
+                    @click="toViewPaper(attachment)"
+                    >预览</el-button
+                  >
+                </div>
+              </td>
+              <td v-else>
                 <el-button
                   type="text"
-                  class="btn-primary box-grow"
-                  @click="toSelect(attachment)"
+                  class="btn-primary"
+                  @click="toUpload(attachment)"
                 >
                   <i
                     :class="[
@@ -137,186 +184,168 @@
                       attachment.attachmentId ? 'icon-files-act' : 'icon-files',
                     ]"
                   ></i
-                  >{{ attachment.filename || "选择试卷" }}
+                  >{{
+                    attachment.attachmentId
+                      ? attachment.filename
+                      : "点击上传试卷文件"
+                  }}
                 </el-button>
-                <el-button
-                  type="text"
-                  class="btn-primary box-static"
-                  :disabled="!attachment.paperUrl"
-                  @click="toViewPaper(attachment)"
-                  >预览</el-button
-                >
-              </div>
-            </td>
-            <td v-else>
-              <el-button
-                type="text"
-                class="btn-primary"
-                @click="toUpload(attachment)"
-              >
-                <i
-                  :class="[
-                    'icon',
-                    attachment.attachmentId ? 'icon-files-act' : 'icon-files',
-                  ]"
-                ></i
-                >{{
-                  attachment.attachmentId
-                    ? attachment.filename
-                    : "点击上传试卷文件"
-                }}
-              </el-button>
-            </td>
-            <td v-if="IS_TIKU_TAB">
-              <el-select
-                v-model="attachment.cardId"
-                placeholder="请选择"
-                style="width: 260px; margin-right: 10px"
-                @change="(val) => tkCardChange(val, attachment)"
-              >
-                <el-option
-                  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
-                class="btn-primary"
-                type="text"
-                :disabled="!attachment.cardId"
-                @click="toViewCard(attachment)"
-                >预览</el-button
-              >
-              <el-button
-                v-if="!IS_REBUILD"
-                class="btn-primary"
-                type="text"
-                :disabled="!attachment.cardId"
-                @click="toEditCard(attachment)"
-                >编辑</el-button
-              >
-            </td>
-            <td v-else>
-              <el-select
-                class="mr-2"
-                v-model="attachment.cardId"
-                placeholder="请选择"
-                style="width: 200px"
-                filterable
-                @change="cardChange(attachment)"
-              >
-                <el-option
-                  v-for="item in cards"
-                  :key="item.id"
-                  :value="item.id"
-                  :label="item.title"
-                  :disabled="item.disabled"
+              </td>
+              <td v-if="IS_TIKU_TAB">
+                <el-select
+                  v-model="attachment.cardId"
+                  placeholder="请选择"
+                  style="width: 260px; margin-right: 10px"
+                  @change="(val) => tkCardChange(val, attachment)"
                 >
-                  <div class="box-justify">
-                    <div class="box-grow">
-                      <span
-                        :class="[
-                          item.type === 'GENERIC'
-                            ? 'color-success'
-                            : 'color-primary',
-                          'mr-1',
-                          {
-                            'color-danger': item.used,
-                          },
-                        ]"
-                        >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
-                      >
-                      {{ item.title }}
+                  <el-option
+                    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-button
-                      v-if="item.type !== 'GENERIC'"
-                      class="btn-danger btn-icon box-static"
-                      type="text"
-                      icon="el-icon-remove"
-                      @click="toDeleteCard(item, attachment)"
-                    ></el-button>
-                  </div>
-                </el-option>
-              </el-select>
-              <span
-                v-if="attachment.cardId"
-                :class="[
-                  attachment.cardType === 'GENERIC'
-                    ? 'color-success'
-                    : 'color-primary',
-                  'mr-1',
-                  {
-                    'color-danger': attachment.used,
-                  },
-                ]"
-                >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
-              >
-              <el-button
-                class="btn-primary"
-                type="text"
-                :disabled="!attachment.cardId"
-                @click="toViewCard(attachment)"
-                >预览</el-button
-              >
-              <template v-if="!IS_REBUILD">
+                  </el-option>
+                </el-select>
                 <el-button
                   class="btn-primary"
                   type="text"
-                  :disabled="
-                    !attachment.cardId ||
-                    (attachment.cardType === 'GENERIC' &&
-                      attachment.createMethod !== 'STANDARD')
-                  "
-                  @click="toCopyCard(attachment)"
-                  >复制</el-button
+                  :disabled="!attachment.cardId"
+                  @click="toViewCard(attachment)"
+                  >预览</el-button
                 >
                 <el-button
+                  v-if="!IS_REBUILD"
                   class="btn-primary"
                   type="text"
-                  :disabled="
-                    !attachment.cardId ||
-                    attachment.cardType === 'GENERIC' ||
-                    !(!attachment.used && attachment.createId === user.id)
-                  "
+                  :disabled="!attachment.cardId"
                   @click="toEditCard(attachment)"
                   >编辑</el-button
                 >
+              </td>
+              <td v-else>
+                <el-select
+                  class="mr-2"
+                  v-model="attachment.cardId"
+                  placeholder="请选择"
+                  style="width: 200px"
+                  filterable
+                  @change="cardChange(attachment)"
+                >
+                  <el-option
+                    v-for="item in cards"
+                    :key="item.id"
+                    :value="item.id"
+                    :label="item.title"
+                    :disabled="item.disabled"
+                  >
+                    <div class="box-justify">
+                      <div class="box-grow">
+                        <span
+                          :class="[
+                            item.type === 'GENERIC'
+                              ? 'color-success'
+                              : 'color-primary',
+                            'mr-1',
+                            {
+                              'color-danger': item.used,
+                            },
+                          ]"
+                          >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
+                        >
+                        {{ item.title }}
+                      </div>
+                      <el-button
+                        v-if="item.type !== 'GENERIC'"
+                        class="btn-danger btn-icon box-static"
+                        type="text"
+                        icon="el-icon-remove"
+                        @click="toDeleteCard(item, attachment)"
+                      ></el-button>
+                    </div>
+                  </el-option>
+                </el-select>
+                <span
+                  v-if="attachment.cardId"
+                  :class="[
+                    attachment.cardType === 'GENERIC'
+                      ? 'color-success'
+                      : 'color-primary',
+                    'mr-1',
+                    {
+                      'color-danger': attachment.used,
+                    },
+                  ]"
+                  >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
+                >
                 <el-button
                   class="btn-primary"
                   type="text"
-                  :disabled="!canCreateCard"
-                  @click="toCreateCard(attachment)"
-                  >新建</el-button
+                  :disabled="!attachment.cardId"
+                  @click="toViewCard(attachment)"
+                  >预览</el-button
                 >
-              </template>
-            </td>
-            <td v-if="!IS_REBUILD" class="text-right">
-              <el-button
-                v-if="index === paperAttachments.length - 1"
-                class="btn-primary btn-icon"
-                type="text"
-                icon="el-icon-circle-plus"
-                @click="addAtachment"
-              ></el-button>
-              <el-button
-                class="btn-danger btn-icon"
-                type="text"
-                icon="el-icon-remove"
-                @click="deleteAttachment(index)"
-              ></el-button>
-            </td>
-          </tr>
+                <template v-if="!IS_REBUILD">
+                  <el-button
+                    class="btn-primary"
+                    type="text"
+                    :disabled="
+                      !attachment.cardId ||
+                      (attachment.cardType === 'GENERIC' &&
+                        attachment.createMethod !== 'STANDARD')
+                    "
+                    @click="toCopyCard(attachment)"
+                    >复制</el-button
+                  >
+                  <el-button
+                    class="btn-primary"
+                    type="text"
+                    :disabled="
+                      !attachment.cardId ||
+                      attachment.cardType === 'GENERIC' ||
+                      !(!attachment.used && attachment.createId === user.id)
+                    "
+                    @click="toEditCard(attachment)"
+                    >编辑</el-button
+                  >
+                  <el-button
+                    class="btn-primary"
+                    type="text"
+                    :disabled="!canCreateCard"
+                    @click="toCreateCard(attachment)"
+                    >新建</el-button
+                  >
+                </template>
+              </td>
+              <td
+                v-if="!IS_REBUILD && index === 0"
+                :rowspan="paperAttachment.paperAttachmentIds.length"
+                class="text-right"
+              >
+                <el-button
+                  v-if="pindex === paperAttachments.length - 1"
+                  class="btn-primary btn-icon"
+                  type="text"
+                  icon="el-icon-circle-plus"
+                  @click="addAtachment"
+                ></el-button>
+                <el-button
+                  class="btn-danger btn-icon"
+                  type="text"
+                  icon="el-icon-remove"
+                  @click="deleteAttachment(pindex)"
+                ></el-button>
+              </td>
+            </tr>
+          </template>
           <tr v-if="!paperAttachments.length">
             <td colspan="5">
               <p class="tips-info text-center">暂无数据</p>
@@ -324,19 +353,6 @@
           </tr>
         </table>
 
-        <el-form v-if="!IS_REBUILD">
-          <el-form-item label="单次抽卷卷型数量:" label-width="150">
-            <el-input-number
-              v-model="examTaskDetail.drawCount"
-              :min="1"
-              :max="1"
-              :step="1"
-              step-strictly
-              :controls="false"
-            ></el-input-number>
-          </el-form-item>
-        </el-form>
-
         <h4 class="mb-2">
           附件<span>(最多4个,仅限{{ attachmentFormat.join("、") }}文件)</span
           >:
@@ -454,6 +470,7 @@ import { copyCard } from "../../../card/api";
 
 import CardBuildDialog from "../../../card/components/CardBuildDialog.vue";
 import CardPreviewDialog from "../../../card/components/CardPreviewDialog.vue";
+import { deepCopy } from "@/plugins/utils";
 
 // type=GENERIC时, 为通卡,不可复制,不可编辑,可预览。
 // type=CUSTOM时,可复制,不可编辑,如果是当前自己任务的题卡,才可编辑。
@@ -535,7 +552,7 @@ export default {
       // card-build
       cardBuildPresetData: {},
       // exam-task-detail
-      examTaskDetail: { makeMethod: "" },
+      examTaskDetail: [],
       paperConfirmAttachmentId: {
         attachmentId: "",
         filename: "",
@@ -546,7 +563,6 @@ export default {
       paperConfirmAttachments: [],
       curAttachment: {},
       curUploadType: "paper",
-      attachmentLimitCount: 26,
       abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
       examTaskInstr: this.$ls.get("schoolInfo", { examTaskInstr: "" })
         .examTaskInstr,
@@ -609,18 +625,22 @@ export default {
       const userOrg = this.user.orgInfo;
       this.teachingRoomName = userOrg.name;
       this.examTask = { ...this.infoExamTask, teachingRoomId: userOrg.id };
-      this.examTaskDetail = { ...this.infoExamTaskDetail };
-      this.paperAttachments = this.examTaskDetail.paperAttachmentIds
-        ? JSON.parse(this.examTaskDetail.paperAttachmentIds)
-        : [];
+      this.paperAttachments = this.examTaskDetail.map((item) => {
+        const paperAttachmentIds = item.paperAttachmentIds
+          ? JSON.parse(item.paperAttachmentIds)
+          : [];
+        return {
+          ...item,
+          paperAttachmentIds,
+        };
+      });
 
       if (!this.paperAttachments.length) {
         this.addAtachment();
       }
 
-      this.paperConfirmAttachments = this.examTaskDetail
-        .paperConfirmAttachmentIds
-        ? JSON.parse(this.examTaskDetail.paperConfirmAttachmentIds)
+      this.paperConfirmAttachments = this.examTask.paperConfirmAttachmentIds
+        ? JSON.parse(this.examTask.paperConfirmAttachmentIds)
         : [];
 
       this.getCourses();
@@ -630,21 +650,35 @@ export default {
         this.$refs.examTaskComp.clearValidate();
       });
     },
+    openAbChange() {
+      if (this.examTask.openAb) {
+        this.paperAttachments.forEach((paperAttachment) => {
+          const attachment = paperAttachment.paperAttachmentIds[0];
+          paperAttachment.paperAttachmentIds.push(
+            Object.assign(deepCopy(attachment), {
+              name: "B",
+            })
+          );
+        });
+      } else {
+        this.paperAttachments.forEach((paperAttachment) => {
+          paperAttachment.paperAttachmentIds =
+            paperAttachment.paperAttachmentIds.slice(0, 1);
+        });
+      }
+    },
     async selectMenu(tab) {
-      const attachment = this.paperAttachments[0];
-      if (attachment.cardId || attachment.attachmentId) {
-        const result = await this.$confirm(
-          "更改类型会清空已设置数据,确定要更改类型?",
-          "提示",
-          {
-            type: "warning",
-          }
-        ).catch(() => {});
-        if (result !== "confirm") return;
+      const result = await this.$confirm(
+        "更改类型会清空已设置数据,确定要更改类型?",
+        "提示",
+        {
+          type: "warning",
+        }
+      ).catch(() => {});
+      if (result !== "confirm") return;
 
-        this.paperAttachments = [];
-        this.addAtachment();
-      }
+      this.paperAttachments = [];
+      this.addAtachment();
 
       this.curTab = tab;
     },
@@ -724,6 +758,14 @@ export default {
       this.cards = [];
       this.getCardList();
     },
+    updateExamTaskDetail() {
+      this.examTaskDetail = this.paperAttachments.map((item) => {
+        return {
+          ...item,
+          paperAttachmentIds: JSON.stringify(item.paperAttachmentIds),
+        };
+      });
+    },
     async examAndRoomChange() {
       this.updateTaskInfo({ infoExamTask: this.examTask });
 
@@ -734,9 +776,11 @@ export default {
           orgId: teachingRoomId,
         });
         this.examTask.cardRuleId = examPrintPlan.cardRuleId;
-        this.examTaskDetail.review = examPrintPlan.review;
-        this.examTaskDetail.includePaper =
+        this.examTask.review = examPrintPlan.review;
+        this.examTask.includePaper =
           examPrintPlan.printContent.indexOf("PAPER") !== -1;
+        this.updateExamTaskDetail();
+
         this.updateTaskInfo({
           infoExamPrintPlan: Object.assign(
             {},
@@ -818,28 +862,31 @@ export default {
       // data: {id,title}
       if (!data.id) return;
 
+      const pos = this.getAttachmentPos(this.curAttachment);
+      if (!pos) return;
+
       if (this.IS_TIKU_TAB) {
-        const aind = this.paperAttachments.findIndex(
-          (item) => item.name === this.curAttachment.name
-        );
-        this.paperAttachments[aind].cardTitle = data.title;
+        this.paperAttachments[pos.pindex].paperAttachmentIds[
+          pos.index
+        ].cardTitle = data.title;
         await this.getTkCardList(this.curAttachment);
         return;
       }
 
       await this.getCardList();
       let card = this.cards.find((item) => item.id === data.id);
-
-      const aind = this.paperAttachments.findIndex(
-        (item) => item.name === this.curAttachment.name
-      );
-      if (aind !== -1 && card) {
-        this.paperAttachments[aind].cardId = card.id;
-        this.paperAttachments[aind].cardType = card.type;
-        this.paperAttachments[aind].createMethod = card.createMethod;
-        this.paperAttachments[aind].cardTitle = card.title;
-        this.paperAttachments[aind].used = card.used;
-        this.paperAttachments[aind].createId = card.createId;
+      if (card) {
+        Object.assign(
+          this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
+          {
+            cardId: card.id,
+            cardType: card.type,
+            createMethod: card.createMethod,
+            cardTitle: card.title,
+            used: card.used,
+            createId: card.createId,
+          }
+        );
       }
     },
     tkCardChange(card, attachment) {
@@ -873,14 +920,18 @@ export default {
       const valid = await this.$refs.examTaskComp.validate().catch(() => {});
       if (!valid) return Promise.reject();
 
+      const paperAttachments = this.paperAttachments
+        .map((item) => item.paperAttachmentIds)
+        .flat();
+
       if (this.IS_TIKU_TAB) {
-        const paperValid = !this.paperAttachments.some((item) => !item.paperId);
+        const paperValid = !paperAttachments.some((item) => !item.paperId);
         if (!paperValid) {
           this.$message.error("请完成试卷选择!");
           return Promise.reject();
         }
 
-        const cardValid = !this.paperAttachments.some((item) => !item.cardId);
+        const cardValid = !paperAttachments.some((item) => !item.cardId);
         if (!cardValid) {
           this.$message.error("有试卷类型未选择题卡!");
           return Promise.reject();
@@ -890,8 +941,8 @@ export default {
 
       // 设置了入库强制包含试卷时,校验试卷是否上传。
       // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
-      if (this.examTaskDetail.includePaper) {
-        const attachmentValid = !this.paperAttachments.some(
+      if (this.examTask.includePaper) {
+        const attachmentValid = !paperAttachments.some(
           (item) => !item.attachmentId
         );
         if (!attachmentValid) {
@@ -899,12 +950,12 @@ export default {
           return Promise.reject();
         }
       } else {
-        const hasUploadPaperAttachments = this.paperAttachments.filter(
+        const hasUploadPaperAttachments = paperAttachments.filter(
           (item) => item.attachmentId
         );
         if (
           hasUploadPaperAttachments.length > 0 &&
-          hasUploadPaperAttachments.length !== this.paperAttachments.length
+          hasUploadPaperAttachments.length !== paperAttachments.length
         ) {
           this.$message.error("有试卷文件未完成上传!");
           return Promise.reject();
@@ -916,12 +967,12 @@ export default {
       //   return;
       // }
 
-      const cardValid = !this.paperAttachments.some((item) => !item.cardId);
+      const cardValid = !paperAttachments.some((item) => !item.cardId);
       if (!cardValid) {
         this.$message.error("有试卷类型未选择题卡!");
         return Promise.reject();
       }
-      //   const usedCards = this.paperAttachments
+      //   const usedCards = paperAttachments
       //     .filter((item) => item.cardId && item.used)
       //     .map((item) => item.name);
       //   if (usedCards.length) {
@@ -932,9 +983,10 @@ export default {
       return Promise.resolve(true);
     },
     updateData() {
+      this.updateExamTaskDetail();
       let data = {
         infoExamTask: this.examTask,
-        infoExamTaskDetail: this.getTaskDetailData(),
+        infoExamTaskDetail: this.examTaskDetail,
       };
       this.updateTaskInfo(data);
     },
@@ -942,6 +994,19 @@ export default {
       this.$emit("relate-info-change", this.getData(), type);
     },
     // select-paper
+    getAttachmentPos(attachment) {
+      const pindex = this.paperAttachments.findIndex(
+        (item) => item.serialNumber === attachment.serialNumber
+      );
+      if (pindex === -1) return;
+
+      const index = this.paperAttachments[pindex].paperAttachmentIds.findIndex(
+        (item) => item.name === attachment.name
+      );
+      if (index === -1) return;
+
+      return { pindex, index };
+    },
     toSelect(attachment) {
       this.curAttachment = {
         ...attachment,
@@ -972,25 +1037,31 @@ export default {
         this.$message.error(data.message);
         return;
       }
-      const ind = this.paperAttachments.findIndex(
-        (item) => item.name === this.curAttachment.name
-      );
-      if (ind === -1) return;
+      const pos = this.getAttachmentPos(this.curAttachment);
+      if (!pos) return;
 
       const info = data.data;
-      this.curAttachment = { ...this.paperAttachments[ind] };
-      this.paperAttachments[ind] = Object.assign(this.paperAttachments[ind], {
-        paperId: this.cardBuildPresetData.paperId,
-        cardType: this.cardBuildPresetData.type,
-        createMethod: this.cardBuildPresetData.createMethod,
-        filename: this.cardBuildPresetData.paperName,
-        cardId: info.id,
-        cardTitle: info.title,
-        uuid: info.uuid,
-        attachmentId: info.attachmentId,
-        paperUrl: info.paperUrl,
-      });
-      this.getTkCardList(this.paperAttachments[ind]);
+      this.curAttachment = {
+        ...this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
+      };
+
+      Object.assign(
+        this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
+        {
+          paperId: this.cardBuildPresetData.paperId,
+          cardType: this.cardBuildPresetData.type,
+          createMethod: this.cardBuildPresetData.createMethod,
+          filename: this.cardBuildPresetData.paperName,
+          cardId: info.id,
+          cardTitle: info.title,
+          uuid: info.uuid,
+          attachmentId: info.attachmentId,
+          paperUrl: info.paperUrl,
+        }
+      );
+      this.getTkCardList(
+        this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index]
+      );
     },
     toViewPaper(attachment) {
       if (!attachment.paperUrl) return;
@@ -998,10 +1069,10 @@ export default {
     },
     // exam-task-detail edit
     addAtachment() {
-      if (this.paperAttachments.length >= this.attachmentLimitCount) return;
-
+      const serialNumber = this.paperAttachments.length + 1;
       const newAttachment = {
-        name: this.abc[this.paperAttachments.length],
+        name: "A",
+        serialNumber,
         attachmentId: "",
         filename: "",
         paperId: null,
@@ -1016,7 +1087,19 @@ export default {
         createId: null,
         cards: [],
       };
-      this.paperAttachments.push(newAttachment);
+      const paperAttachment = {
+        serialNumber,
+        paperType: "",
+        paperAttachmentIds: [],
+      };
+      paperAttachment.paperAttachmentIds.push(newAttachment);
+
+      if (this.examTask.openAb) {
+        paperAttachment.paperAttachmentIds.push(
+          Object.assign(deepCopy(newAttachment), { name: "B" })
+        );
+      }
+      this.paperAttachments.push(paperAttachment);
     },
     deleteAttachment(index) {
       if (this.paperAttachments.length <= 1) {
@@ -1025,14 +1108,11 @@ export default {
       }
       this.paperAttachments.splice(index, 1);
       this.paperAttachments.forEach((item, itemIndex) => {
-        item.name = this.abc[itemIndex];
+        item.serialNumber = itemIndex + 1;
+        item.paperAttachmentIds.forEach((attachment) => {
+          attachment.serialNumber = item.serialNumber;
+        });
       });
-      if (
-        this.examTaskDetail.drawCount &&
-        this.examTaskDetail.drawCount > this.paperAttachments.length
-      ) {
-        this.examTaskDetail.drawCount = this.paperAttachments.length;
-      }
     },
     toUpload(attachment) {
       this.curUploadType = "paper";
@@ -1051,10 +1131,16 @@ export default {
     },
     uploadConfirm(attachment, uploadType) {
       if (uploadType === "paper") {
-        const index = this.paperAttachments.findIndex(
-          (item) => item.name === attachment.name
+        const pos = this.getAttachmentPos(attachment);
+        if (!pos) return;
+
+        this.paperAttachments[pos.pindex].paperAttachmentIds.splice(
+          pos.index,
+          1,
+          {
+            ...attachment,
+          }
         );
-        this.paperAttachments.splice(index, 1, { ...attachment });
       } else {
         this.paperConfirmAttachments.push(attachment);
       }
@@ -1068,17 +1154,6 @@ export default {
     // cardConfirm(data) {
     //   this.examTaskDetail = this.$objAssign(this.examTaskDetail, data);
     // },
-    getTaskDetailData() {
-      let data = { ...this.examTaskDetail };
-      data.paperType = this.paperAttachments.map((item) => item.name).join(",");
-      data.paperAttachmentIds = JSON.stringify(this.paperAttachments, (k, v) =>
-        k === "url" ? undefined : v
-      );
-      data.paperConfirmAttachmentIds = JSON.stringify(
-        this.paperConfirmAttachments
-      );
-      return data;
-    },
     // image-preview
     toPreview(index) {
       this.curImageIndex = index;

+ 42 - 0
src/modules/exam/components/createExamAndPrintTask/data.json

@@ -0,0 +1,42 @@
+{
+  "examTask": {
+    "semesterId": "563733644493979648",
+    "examId": "563734073508364288",
+    "examModel": "MODEL1",
+    "category": "FORMAL",
+    "courseId": "539049424593092608",
+    "courseCode": "",
+    "courseName": "汉语言文学",
+    "paperNumber": "dy2",
+    "cardRuleId": "539028101917573120",
+    "teachingRoomId": "539033379098591232",
+    "teacherName": "",
+    "paperName": "3.4.1学期",
+    "uuid": "i1mavs0g6gln2b4od5ltrpg8q4q8m5bo",
+    "examStartTime": "",
+    "examEndTime": "",
+    "openAb": false
+  },
+  "examTaskDetail": [
+    {
+      "serialNumber": "Ⅰ",
+      "paperType": "A",
+      "paperAttachmentIds": "[{\"name\":\"A\",\"attachmentId\":\"563738306609676288\",\"filename\":\"解剖生理学1.pdf\",\"paperId\":null,\"paperUrl\":null,\"uuid\":null,\"cardId\":\"563738420979957760\",\"cardType\":\"CUSTOM\",\"createMethod\":null,\"cardTitle\":\"dy2\",\"pages\":2,\"used\":false,\"createId\":\"539033700742987776\",\"cards\":[],\"original\":{\"id\":\"563738306609676288\",\"updateTime\":1725346486093,\"pages\":2,\"pageSize\":\"A3\"}}]"
+    }
+  ],
+  "examDetail": {
+    "paperNumber": "",
+    "courseName": "汉语言文学",
+    "courseCode": "",
+    "courseId": "539049424593092608",
+    "printCount": 1,
+    "printHouseId": "",
+    "classId": "",
+    "className": "",
+    "basicStudentIds": [],
+    "list": [],
+    "totalSubjects": 1,
+    "backupCount": null,
+    "model2Students": []
+  }
+}