Explorar o código

feat: 命题任务附件支持mp3

zhangjie hai 10 meses
pai
achega
c012884961

+ 25 - 1
src/assets/styles/pages.scss

@@ -34,9 +34,10 @@
       border-top: 0;
       padding: 10px;
 
-      i {
+      .icon {
         display: inline-block;
         vertical-align: middle;
+        margin-top: -2px;
       }
     }
 
@@ -109,6 +110,29 @@
       }
     }
   }
+  .audio-item {
+    margin-bottom: 5px;
+    audio {
+      display: inline-block;
+      vertical-align: middle;
+      height: 32px;
+    }
+    .audio-delete {
+      display: inline-block;
+      vertical-align: middle;
+      margin-left: 10px;
+      height: 32px;
+      line-height: 32px;
+      width: 32px;
+      border-radius: 50%;
+      text-align: center;
+      background-color: $--color-background;
+      cursor: pointer;
+      &:hover {
+        color: $--color-danger;
+      }
+    }
+  }
   .image-add {
     font-size: 40px;
     line-height: 1;

+ 5 - 3
src/components/UploadButton.vue

@@ -47,9 +47,6 @@ export default {
     btnContent: {
       type: String,
     },
-    accept: {
-      type: String,
-    },
     format: {
       type: Array,
       default() {
@@ -86,6 +83,11 @@ export default {
       uploadDataDict: {},
     };
   },
+  computed: {
+    accept() {
+      return this.format.map((item) => `.${item}`).join();
+    },
+  },
   methods: {
     checkFileFormat(fileType) {
       const _file_format = fileType.split(".").pop().toLocaleLowerCase();

+ 6 - 0
src/components/UploadFileView.vue

@@ -11,6 +11,7 @@
       :headers="headers"
       :max-size="maxSize"
       :format="format"
+      :accept="accept"
       :data="uploadDataDict"
       :on-change="handleFileChange"
       :before-upload="handleBeforeUpload"
@@ -94,6 +95,11 @@ export default {
       res: {},
     };
   },
+  computed: {
+    accept() {
+      return this.format.map((item) => `.${item}`).join();
+    },
+  },
   methods: {
     startUpload() {
       this.loading = true;

+ 0 - 1
src/modules/admin/views/AuthSet.vue

@@ -34,7 +34,6 @@
             btn-type="primary"
             :upload-url="uploadUrl"
             :format="['lic']"
-            accept=".lic"
             style="margin: 0"
             @valid-error="validError"
             @upload-success="uploadSuccess"

+ 2 - 1
src/modules/exam/components/UploadPaperDialog.vue

@@ -85,7 +85,7 @@ export default {
         },
         paperConfirm: {
           title: "附件",
-          format: ["jpg", "png"],
+          format: ["jpg", "png", "mp3"],
           uploadData: { type: "FILE" },
           uploadUrl: "/api/admin/common/file/upload",
         },
@@ -140,6 +140,7 @@ export default {
           filename: data.filename,
           url: data.url,
           pages: data.pages,
+          fileType: data.filename.endsWith(".mp3") ? "audio" : "image",
         };
       }
       this.attachment = Object.assign(this.attachment, infos);

+ 44 - 12
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -337,34 +337,48 @@
           </el-form-item>
         </el-form>
 
-        <h4 class="mb-2">附件<span>(最多4)</span>:</h4>
+        <h4 class="mb-2">附件<span>(最多4)</span>:</h4>
         <div class="image-list">
           <div
+            v-for="(item, index) in imageAttachments"
+            :key="`image${index}`"
             class="image-item"
-            v-for="(img, index) in paperConfirmAttachments"
-            :key="index"
           >
             <img
-              :src="img.url"
-              :alt="img.filename"
+              :src="item.url"
+              :alt="item.filename"
               title="点击查看大图"
               @click="toPreview(index)"
             />
             <div class="image-delete">
               <i
                 class="el-icon-delete-solid"
-                @click="deletePaperConfirmAttachment(index)"
+                @click="deletePaperConfirmAttachment(item)"
               ></i>
             </div>
           </div>
           <div
             v-if="paperConfirmAttachments.length < 4"
             class="image-item image-add"
-            title="上传入库审核表"
+            title="上传附件"
             @click="toUploadPaperConfirm"
           >
             <i class="el-icon-plus"></i>
           </div>
+          <br />
+          <div
+            class="audio-item"
+            v-for="(item, index) in audioAttachments"
+            :key="`audio${index}`"
+          >
+            <audio :src="item.url" :alt="item.filename" controls></audio>
+            <div class="audio-delete">
+              <i
+                class="el-icon-delete-solid"
+                @click="deletePaperConfirmAttachment(item)"
+              ></i>
+            </div>
+          </div>
         </div>
 
         <h4 class="mb-2">附件说明:</h4>
@@ -510,7 +524,12 @@ export default {
       cardBuildPresetData: {},
       // exam-task-detail
       examTaskDetail: { makeMethod: "" },
-      paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
+      paperConfirmAttachmentId: {
+        attachmentId: "",
+        filename: "",
+        url: "",
+        fileType: "",
+      },
       paperAttachments: [],
       paperConfirmAttachments: [],
       curAttachment: {},
@@ -548,6 +567,16 @@ export default {
     IS_REBUILD() {
       return this.examTask.category === "REBUILD";
     },
+    imageAttachments() {
+      return this.paperConfirmAttachments.filter(
+        (item) => item.fileType === "image"
+      );
+    },
+    audioAttachments() {
+      return this.paperConfirmAttachments.filter(
+        (item) => item.fileType === "audio"
+      );
+    },
   },
   watch: {
     "examTask.examId": function (val, oldval) {
@@ -1024,7 +1053,10 @@ export default {
         this.paperConfirmAttachments.push(attachment);
       }
     },
-    deletePaperConfirmAttachment(index) {
+    deletePaperConfirmAttachment(data) {
+      const index = this.paperConfirmAttachments.findIndex(
+        (item) => item.url === data.url
+      );
       this.paperConfirmAttachments.splice(index, 1);
     },
     // cardConfirm(data) {
@@ -1048,11 +1080,11 @@ export default {
       this.$refs.SimpleImagePreview.open();
     },
     selectImage(index) {
-      this.curImage = this.paperConfirmAttachments[index];
+      this.curImage = this.imageAttachments[index];
     },
     toPrevImage() {
       if (this.curImageIndex === 0) {
-        this.curImageIndex = this.paperConfirmAttachments.length - 1;
+        this.curImageIndex = this.imageAttachments.length - 1;
       } else {
         this.curImageIndex--;
       }
@@ -1060,7 +1092,7 @@ export default {
       this.selectImage(this.curImageIndex);
     },
     toNextImage() {
-      if (this.curImageIndex === this.paperConfirmAttachments.length - 1) {
+      if (this.curImageIndex === this.imageAttachments.length - 1) {
         this.curImageIndex = 0;
       } else {
         this.curImageIndex++;

+ 43 - 11
src/modules/exam/components/taskApply/TaskPaper.vue

@@ -337,24 +337,24 @@
 
     <!-- 附件 -->
     <h4 class="mb-2">
-      附件<span v-if="taskStatus.IS_APPLY">(最多4)</span>:
+      附件<span v-if="taskStatus.IS_APPLY">(最多4)</span>:
     </h4>
     <div class="image-list">
       <div
+        v-for="(item, index) in imageAttachments"
+        :key="`image${index}`"
         class="image-item"
-        v-for="(img, index) in paperConfirmAttachments"
-        :key="index"
       >
         <img
-          :src="img.url"
-          :alt="img.filename"
+          :src="item.url"
+          :alt="item.filename"
           title="点击查看大图"
           @click="toPreview(index)"
         />
         <div v-if="taskStatus.IS_APPLY" class="image-delete">
           <i
             class="el-icon-delete-solid"
-            @click="deletePaperConfirmAttachment(index)"
+            @click="deletePaperConfirmAttachment(item)"
           ></i>
         </div>
       </div>
@@ -366,6 +366,20 @@
       >
         <i class="el-icon-plus"></i>
       </div>
+      <br />
+      <div
+        class="audio-item"
+        v-for="(item, index) in audioAttachments"
+        :key="`audio${index}`"
+      >
+        <audio :src="item.url" :alt="item.filename" controls></audio>
+        <div class="audio-delete">
+          <i
+            class="el-icon-delete-solid"
+            @click="deletePaperConfirmAttachment(item)"
+          ></i>
+        </div>
+      </div>
     </div>
     <div
       v-if="!taskStatus.IS_APPLY && !paperConfirmAttachments.length"
@@ -463,7 +477,12 @@ export default {
       curTab: "upload",
       uuid: "",
       user: {},
-      paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
+      paperConfirmAttachmentId: {
+        attachmentId: "",
+        filename: "",
+        url: "",
+        fileType: "",
+      },
       paperAttachments: [],
       paperConfirmAttachments: [],
       curAttachment: {},
@@ -496,6 +515,16 @@ export default {
         ? 1
         : this.paperAttachments.length;
     },
+    imageAttachments() {
+      return this.paperConfirmAttachments.filter(
+        (item) => item.fileType === "image"
+      );
+    },
+    audioAttachments() {
+      return this.paperConfirmAttachments.filter(
+        (item) => item.fileType === "audio"
+      );
+    },
   },
   mounted() {
     this.initData();
@@ -651,7 +680,10 @@ export default {
         this.paperConfirmAttachments.push(attachment);
       }
     },
-    deletePaperConfirmAttachment(index) {
+    deletePaperConfirmAttachment(data) {
+      const index = this.paperConfirmAttachments.findIndex(
+        (item) => item.url === data.url
+      );
       this.paperConfirmAttachments.splice(index, 1);
     },
     toViewCard(attachment) {
@@ -852,11 +884,11 @@ export default {
       this.$refs.SimpleImagePreview.open();
     },
     selectImage(index) {
-      this.curImage = this.paperConfirmAttachments[index];
+      this.curImage = this.imageAttachments[index];
     },
     toPrevImage() {
       if (this.curImageIndex === 0) {
-        this.curImageIndex = this.paperConfirmAttachments.length - 1;
+        this.curImageIndex = this.imageAttachments.length - 1;
       } else {
         this.curImageIndex--;
       }
@@ -864,7 +896,7 @@ export default {
       this.selectImage(this.curImageIndex);
     },
     toNextImage() {
-      if (this.curImageIndex === this.paperConfirmAttachments.length - 1) {
+      if (this.curImageIndex === this.imageAttachments.length - 1) {
         this.curImageIndex = 0;
       } else {
         this.curImageIndex++;