ソースを参照

feat: 题库试卷选择新增试卷预览

zhangjie 1 年間 前
コミット
72132291c7

+ 1 - 0
src/modules/card/components/CardBuildDialog.vue

@@ -153,6 +153,7 @@ export default {
         this.paperInfo = {
           uuid: this.presetData.uuid,
           attachmentId: res.attachmentId,
+          paperUrl: res.paperUrl,
         };
         const answerJson = res.answerJson
           ? json5.parse(res.answerJson)

+ 28 - 28
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -120,19 +120,28 @@
             <td>{{ attachment.name }}卷</td>
 
             <td v-if="IS_TIKU_TAB">
-              <el-button
-                type="text"
-                class="btn-primary"
-                @click="toSelect(attachment)"
-              >
-                <i
-                  :class="[
-                    'icon',
-                    attachment.attachmentId ? 'icon-files-act' : 'icon-files',
-                  ]"
-                ></i
-                >{{ attachment.filename || "选择试卷" }}
-              </el-button>
+              <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
@@ -189,9 +198,6 @@
                 placeholder="请选择"
                 style="width: 200px"
                 filterable
-                @visible-change="
-                  (visible) => cardOptionOpened(visible, attachment)
-                "
                 @change="cardChange(attachment)"
               >
                 <el-option
@@ -663,18 +669,6 @@ export default {
         attachment.createId = card.createId;
       }
     },
-    cardOptionOpened(visible, attachment) {
-      if (!visible) return;
-
-      //   const selectedCardIds = this.paperAttachments.map((item) => item.cardId);
-      //   this.cards = this.cards.map((card) => {
-      //     card.disabled =
-      //       card.id !== attachment.cardId &&
-      //       selectedCardIds.includes(card.id) &&
-      //       card.type !== "GENERIC";
-      //     return card;
-      //   });
-    },
     async toCreateCard(attachment) {
       if (!this.examTask.cardRuleId) {
         this.$message.error("题卡规则缺失!");
@@ -880,8 +874,13 @@ export default {
         cardTitle: info.title,
         uuid: info.uuid,
         attachmentId: info.attachmentId,
+        paperUrl: info.paperUrl,
       });
     },
+    toViewPaper(attachment) {
+      if (!attachment.paperUrl) return;
+      window.open(attachment.paperUrl);
+    },
     // exam-task-detail edit
     addAtachment() {
       if (this.paperAttachments.length >= this.attachmentLimitCount) return;
@@ -891,6 +890,7 @@ export default {
         attachmentId: "",
         filename: "",
         paperId: null,
+        paperUrl: null,
         uuid: null,
         cardId: "",
         cardType: "",

+ 30 - 29
src/modules/exam/components/taskApply/TaskPaper.vue

@@ -35,20 +35,30 @@
         </td>
         <template v-if="IS_TIKU_TAB">
           <td>
-            <el-button
-              v-if="!attachment.isExposed && taskStatus.IS_APPLY"
-              type="text"
-              class="btn-primary"
-              @click="toSelect(attachment)"
-            >
-              <i
-                :class="[
-                  'icon',
-                  attachment.attachmentId ? 'icon-files-act' : 'icon-files',
-                ]"
-              ></i
-              >{{ attachment.filename || "选择试卷" }}
-            </el-button>
+            <template v-if="!attachment.isExposed && taskStatus.IS_APPLY">
+              <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>
+            </template>
             <el-button
               v-else
               type="text"
@@ -159,9 +169,6 @@
                 placeholder="请选择"
                 style="width: 200px"
                 filterable
-                @visible-change="
-                  (visible) => cardOptionOpened(visible, attachment)
-                "
                 @change="cardChange(attachment)"
               >
                 <el-option
@@ -537,6 +544,7 @@ export default {
         attachmentId: "",
         filename: "",
         paperId: null,
+        paperUrl: null,
         uuid: null,
         cardId: "",
         cardType: "",
@@ -665,18 +673,6 @@ export default {
         attachment.createId = card.createId;
       }
     },
-    cardOptionOpened(visible, attachment) {
-      if (!visible) return;
-
-      //   const selectedCardIds = this.paperAttachments.map((item) => item.cardId);
-      //   this.cards = this.cards.map((card) => {
-      //     card.disabled =
-      //       card.id !== attachment.cardId &&
-      //       selectedCardIds.includes(card.id) &&
-      //       card.type !== "GENERIC";
-      //     return card;
-      //   });
-    },
     async toCreateCard(attachment) {
       if (!this.examTask.cardRuleId) {
         this.$message.error("题卡规则缺失!");
@@ -760,8 +756,13 @@ export default {
         cardTitle: info.title,
         uuid: info.uuid,
         attachmentId: info.attachmentId,
+        paperUrl: info.paperUrl,
       });
     },
+    toViewPaper(attachment) {
+      if (!attachment.paperUrl) return;
+      window.open(attachment.paperUrl);
+    },
     // image-preview
     toPreview(index) {
       this.curImageIndex = index;