Ver código fonte

题卡新增复制功能以及自定义名称

zhangjie 2 anos atrás
pai
commit
ae46905905

+ 3 - 0
src/modules/card/api.js

@@ -14,3 +14,6 @@ export const saveCard = (datas, config = {}) => {
     return $post("/api/admin/exam/card/save", datas, config);
   }
 };
+export const copyCard = cardId => {
+  return $postParam("/api/admin/exam/card/copy", { id: cardId });
+};

+ 19 - 4
src/modules/card/views/CardEdit.vue

@@ -45,6 +45,7 @@ export default {
       cardType: "CUSTOM",
       cardCreateMethod: "STANDARD",
       cardContent: {},
+      cardName: "", // 题卡自定义名称
       cardPreviewUrl: "",
       canSave: false,
       dataReady: false
@@ -93,6 +94,7 @@ export default {
           cardConfig,
           paperParams: {}
         };
+        this.cardName = "";
       }
       this.dataReady = true;
     },
@@ -112,6 +114,7 @@ export default {
       // 可能存在题卡内容没有记录的情况
       if (detData.content) {
         this.cardContent = JSON.parse(detData.content);
+        this.cardName = detData.title;
       } else {
         let cardConfig = await this.getCardConfig();
         // 没有题卡内容时,直接创建新的内容
@@ -123,6 +126,7 @@ export default {
           cardConfig,
           paperParams: {}
         };
+        this.cardName = "";
       }
     },
     async getCardConfig() {
@@ -184,7 +188,8 @@ export default {
     getCardInfo(data) {
       let cardInfo = {
         ...data,
-        ...this.prepareTcPCard
+        ...this.prepareTcPCard,
+        title: this.cardName
       };
       if (this.cardId) cardInfo.id = this.cardId;
       return cardInfo;
@@ -218,10 +223,19 @@ export default {
       this.$message.success("保存成功!");
     },
     async toSubmit(cardData) {
-      const res = await this.$confirm("确定要提交当前题卡吗?", "提示", {
-        type: "warning"
+      const res = await this.$prompt("确定要提交当前题卡吗?", "提示", {
+        type: "warning",
+        showInput: true,
+        inputPlaceholder: "请输入题卡名称",
+        inputValue: this.cardName,
+        inputValidator: val => {
+          if (!val) return "请输入题卡名称!";
+          if (val.length > 50) return "题卡名称不得超过50个字符!";
+          return true;
+        }
       }).catch(() => {});
-      if (res !== "confirm") return;
+      if (!res || res.action !== "confirm") return;
+      this.cardName = res.value;
 
       this.$refs.CardDesign.loading();
       window.cardData = {
@@ -261,6 +275,7 @@ export default {
         this.$refs.CardDesign.unloading();
         window.cardData = null;
         if (result) {
+          this.cardName = "";
           this.cardId = result;
           this.$ls.set("cardId", this.cardId);
           this.canSave = false;

+ 14 - 4
src/modules/exam/components/ApplyContent.vue

@@ -80,6 +80,13 @@
                 @click="toViewCard(attachment)"
                 >预览</el-button
               >
+              <el-button
+                class="btn-primary"
+                type="text"
+                :disabled="!attachment.cardId"
+                @click="toCopyCard(attachment)"
+                >复制</el-button
+              >
               <el-button
                 class="btn-primary"
                 type="text"
@@ -494,6 +501,7 @@ import {
   taskFlowApprover,
   flowDetailByFlowId
 } from "../../base/api";
+import { copyCard } from "../../card/api";
 
 const initTaskApply = {
   examId: "",
@@ -883,6 +891,11 @@ export default {
         })
       );
     },
+    async toCopyCard(attachment) {
+      this.curAttachment = { ...attachment };
+      const newCardId = await copyCard(attachment.cardId);
+      this.cardModified(newCardId);
+    },
     toEditCard(attachment) {
       this.curAttachment = { ...attachment };
       this.$ls.set("prepareTcPCard", {
@@ -899,11 +912,8 @@ export default {
     },
     async cardModified(cardId) {
       if (!cardId) return;
+      await this.getCardList();
       let card = this.cards.find(item => item.id === cardId);
-      if (!card) {
-        await this.getCardList();
-        card = this.cards.find(item => item.id === cardId);
-      }
 
       const aind = this.paperAttachments.findIndex(
         item => item.name === this.curAttachment.name

+ 14 - 4
src/modules/exam/components/ModifyTaskPaper.vue

@@ -138,6 +138,13 @@
                   @click="toViewCard(attachment)"
                   >预览</el-button
                 >
+                <el-button
+                  class="btn-primary"
+                  type="text"
+                  :disabled="!attachment.cardId"
+                  @click="toCopyCard(attachment)"
+                  >复制</el-button
+                >
                 <el-button
                   class="btn-primary"
                   type="text"
@@ -226,6 +233,7 @@ import { taskApplyDetail, taskPaperApplyEdit, cardForSelectList } from "../api";
 import { attachmentPreview } from "../../login/api";
 import { examRuleDetail } from "../../base/api";
 import { COMMON_CARD_RULE_ID } from "@/constants/enumerate";
+import { copyCard } from "../../card/api";
 
 const initTaskApply = {
   examId: "",
@@ -423,6 +431,11 @@ export default {
         })
       );
     },
+    async toCopyCard(attachment) {
+      this.curAttachment = { ...attachment };
+      const newCardId = await copyCard(attachment.cardId);
+      this.cardModified(newCardId);
+    },
     toEditCard(attachment) {
       this.curAttachment = { ...attachment };
       this.$ls.set("prepareTcPCard", {
@@ -440,11 +453,8 @@ export default {
     },
     async cardModified(cardId) {
       if (!cardId) return;
+      await this.getCardList();
       let card = this.cards.find(item => item.id === cardId);
-      if (!card) {
-        await this.getCardList();
-        card = this.cards.find(item => item.id === cardId);
-      }
 
       const aind = this.paperAttachments.findIndex(
         item => item.name === this.curAttachment.name

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

@@ -149,6 +149,13 @@
                 @click="toViewCard(attachment)"
                 >预览</el-button
               >
+              <el-button
+                class="btn-primary"
+                type="text"
+                :disabled="!attachment.cardId"
+                @click="toCopyCard(attachment)"
+                >复制</el-button
+              >
               <el-button
                 class="btn-primary"
                 type="text"
@@ -271,6 +278,7 @@ import { COMMON_CARD_RULE_ID } from "../../../../constants/enumerate";
 import { cardForSelectList } from "../../api";
 import { courseQuery, examConfigByExamIdOrgId } from "../../../base/api";
 import { mapState, mapMutations } from "vuex";
+import { copyCard } from "../../../card/api";
 
 export default {
   name: "info-exam-task",
@@ -524,13 +532,15 @@ export default {
         })
       );
     },
+    async toCopyCard(attachment) {
+      this.curAttachment = { ...attachment };
+      const newCardId = await copyCard(attachment.cardId);
+      this.cardModified(newCardId);
+    },
     async cardModified(cardId) {
       if (!cardId) return;
+      await this.getCardList();
       let card = this.cards.find(item => item.id === cardId);
-      if (!card) {
-        await this.getCardList();
-        card = this.cards.find(item => item.id === cardId);
-      }
 
       const aind = this.paperAttachments.findIndex(
         item => item.name === this.curAttachment.name