ソースを参照

命题任务题卡选择调整

zhangjie 2 年 前
コミット
c2c6d6b4d8

+ 6 - 0
src/assets/styles/base.scss

@@ -351,6 +351,12 @@ body {
 .color-gray-2 {
   color: $--color-text-gray-2;
 }
+.color-gray-3 {
+  color: $--color-text-gray-3;
+}
+.color-gray-4 {
+  color: $--color-text-gray-4;
+}
 .color-white {
   color: #fff;
 }

+ 39 - 3
src/modules/exam/components/ApplyContent.vue

@@ -75,8 +75,28 @@
                   :label="item.title"
                   :disabled="item.disabled"
                 >
+                  <span
+                    :class="[
+                      item.type === 'GENERIC'
+                        ? 'color-success'
+                        : 'color-primary',
+                      'mr-1'
+                    ]"
+                    >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
+                  >
+                  {{ item.title }}
                 </el-option>
               </el-select>
+              <span
+                v-if="attachment.cardId"
+                :class="[
+                  attachment.cardType === 'GENERIC'
+                    ? 'color-success'
+                    : 'color-primary',
+                  'mr-1'
+                ]"
+                >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
+              >
               <el-button
                 class="btn-primary"
                 type="text"
@@ -99,7 +119,9 @@
                 class="btn-primary"
                 type="text"
                 :disabled="
-                  !attachment.cardId || attachment.cardType === 'GENERIC'
+                  !attachment.cardId ||
+                    attachment.cardType === 'GENERIC' ||
+                    !(!attachment.used && attachment.createId === user.id)
                 "
                 @click="toEditCard(attachment)"
                 >编辑</el-button
@@ -559,6 +581,7 @@ export default {
   data() {
     return {
       isSubmit: false,
+      user: {},
       curTaskApply: { ...initTaskApply },
       paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
       paperAttachments: [],
@@ -670,6 +693,7 @@ export default {
     }
   },
   mounted() {
+    this.user = this.$ls.get("user", {});
     this.initData();
   },
   methods: {
@@ -841,7 +865,9 @@ export default {
         cardTitle: "",
         pages: 0,
         canDelete: true,
-        isExposed: false
+        isExposed: false,
+        used: false,
+        createId: null
       };
       this.paperAttachments.push(newAttachment);
     },
@@ -944,6 +970,8 @@ export default {
         attachment.cardType = card.type;
         attachment.createMethod = card.createMethod;
         attachment.cardTitle = card.title;
+        attachment.used = card.used;
+        attachment.createId = card.createId;
       }
     },
     cardOptionOpened(visible, attachment) {
@@ -1054,12 +1082,20 @@ export default {
       //   return;
       // }
 
-      const cardValid = !this.paperAttachments.some(item => !item.cardId);
+      let cardValid = !this.paperAttachments.some(item => !item.cardId);
       if (!cardValid) {
         this.$message.error("有试卷类型未选择题卡!");
         return;
       }
 
+      const usedCards = this.paperAttachments
+        .filter(item => item.cardId && item.used)
+        .map(item => item.name);
+      if (!usedCards.length) {
+        this.$message.error(`${usedCards.join()}卷选择的题卡已经被使用过!`);
+        return Promise.reject();
+      }
+
       if (this.IS_NEED_SELECT_APPROVE_USER && !this.approveUsers.length) {
         this.$message.error("请设置审核人员!");
         return;

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

@@ -133,8 +133,28 @@
                     :label="item.title"
                     :disabled="item.disabled"
                   >
+                    <span
+                      :class="[
+                        item.type === 'GENERIC'
+                          ? 'color-success'
+                          : 'color-primary',
+                        'mr-1'
+                      ]"
+                      >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
+                    >
+                    {{ item.title }}
                   </el-option>
                 </el-select>
+                <span
+                  v-if="attachment.cardId"
+                  :class="[
+                    attachment.cardType === 'GENERIC'
+                      ? 'color-success'
+                      : 'color-primary',
+                    'mr-1'
+                  ]"
+                  >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
+                >
                 <el-button
                   class="btn-primary"
                   type="text"
@@ -157,7 +177,14 @@
                   class="btn-primary"
                   type="text"
                   :disabled="
-                    !attachment.cardId || attachment.cardType === 'GENERIC'
+                    !attachment.cardId ||
+                      attachment.cardType === 'GENERIC' ||
+                      !(!attachment.used && attachment.createId === user.id) ||
+                      !(
+                        attachment.used &&
+                        attachment.savedCardId &&
+                        attachment.savedCardId === attachment.cardId
+                      )
                   "
                   @click="toEditCard(attachment)"
                   >编辑</el-button
@@ -315,7 +342,8 @@ export default {
       curAttachment: {},
       curUploadType: "paper",
       abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      cards: []
+      cards: [],
+      user: this.$ls.get("user", {})
     };
   },
   methods: {
@@ -349,6 +377,7 @@ export default {
           ? paper.name > maxExposedPaperType
           : true;
         paper.isExposed = exposedPaperTypes.includes(paper.name);
+        paper.savedCardId = paper.cardId;
       });
 
       this.$nextTick(() => {
@@ -371,13 +400,16 @@ export default {
         name,
         attachmentId: "",
         filename: "",
+        savedCardId: null,
         cardId: "",
         cardType: "",
         createMethod: "",
         cardTitle: "",
         pages: 0,
         canDelete: true,
-        isExposed: false
+        isExposed: false,
+        used: false,
+        createId: null
       };
       this.paperAttachments.push(newAttachment);
     },
@@ -491,6 +523,8 @@ export default {
         attachment.cardType = card.type;
         attachment.createMethod = card.createMethod;
         attachment.cardTitle = card.title;
+        attachment.used = card.used;
+        attachment.createId = card.createId;
       }
     },
     cardOptionOpened(visible, attachment) {
@@ -529,12 +563,20 @@ export default {
         }
       }
 
-      const cardValid = !this.paperAttachments.some(item => !item.cardId);
+      let cardValid = !this.paperAttachments.some(item => !item.cardId);
       if (!cardValid) {
         this.$message.error("有试卷类型未选择题卡!");
         return;
       }
 
+      const usedCards = this.paperAttachments
+        .filter(item => item.cardId && item.used)
+        .map(item => item.name);
+      if (!usedCards.length) {
+        this.$message.error(`${usedCards.join()}卷选择的题卡已经被使用过!`);
+        return Promise.reject();
+      }
+
       return true;
     },
     async submit() {

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

@@ -145,8 +145,28 @@
                   :label="item.title"
                   :disabled="item.disabled"
                 >
+                  <span
+                    :class="[
+                      item.type === 'GENERIC'
+                        ? 'color-success'
+                        : 'color-primary',
+                      'mr-1'
+                    ]"
+                    >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
+                  >
+                  {{ item.title }}
                 </el-option>
               </el-select>
+              <span
+                v-if="attachment.cardId"
+                :class="[
+                  attachment.cardType === 'GENERIC'
+                    ? 'color-success'
+                    : 'color-primary',
+                  'mr-1'
+                ]"
+                >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
+              >
               <el-button
                 class="btn-primary"
                 type="text"
@@ -169,7 +189,9 @@
                 class="btn-primary"
                 type="text"
                 :disabled="
-                  !attachment.cardId || attachment.cardType === 'GENERIC'
+                  !attachment.cardId ||
+                    attachment.cardType === 'GENERIC' ||
+                    !(!attachment.used && attachment.createId === user.id)
                 "
                 @click="toEditCard(attachment)"
                 >编辑</el-button
@@ -285,11 +307,14 @@ import { courseQuery, examConfigByExamIdOrgId } from "../../../base/api";
 import { mapState, mapMutations } from "vuex";
 import { copyCard } from "../../../card/api";
 
+// type=GENERIC时, 为通卡,不可复制,不可编辑,可预览。
+// type=CUSTOM时,可复制,不可编辑,如果是当前自己任务的题卡,才可编辑。
 export default {
   name: "info-exam-task",
   components: { UploadPaperDialog, SimpleImagePreview, ModifyCard },
   data() {
     return {
+      user: {},
       task: {},
       rules: {
         semesterId: [
@@ -388,7 +413,8 @@ export default {
   methods: {
     ...mapMutations("exam", ["updateTaskInfo"]),
     initData() {
-      const userOrg = this.$ls.get("user", { orgInfo: {} }).orgInfo;
+      this.user = this.$ls.get("user", {});
+      const userOrg = this.user.orgInfo;
       this.teachingRoomName = userOrg.name;
       this.examTask = { ...this.infoExamTask, teachingRoomId: userOrg.id };
       this.examTaskDetail = { ...this.infoExamTaskDetail };
@@ -501,6 +527,8 @@ export default {
         attachment.cardType = card.type;
         attachment.createMethod = card.createMethod;
         attachment.cardTitle = card.title;
+        attachment.used = card.used;
+        attachment.createId = card.createId;
       }
     },
     cardOptionOpened(visible, attachment) {
@@ -613,11 +641,18 @@ export default {
       //   return;
       // }
 
-      const cardValid = !this.paperAttachments.some(item => !item.cardId);
+      let cardValid = !this.paperAttachments.some(item => !item.cardId);
       if (!cardValid) {
         this.$message.error("有试卷类型未选择题卡!");
         return Promise.reject();
       }
+      const usedCards = this.paperAttachments
+        .filter(item => item.cardId && item.used)
+        .map(item => item.name);
+      if (!usedCards.length) {
+        this.$message.error(`${usedCards.join()}卷选择的题卡已经被使用过!`);
+        return Promise.reject();
+      }
 
       return Promise.resolve(true);
     },
@@ -643,7 +678,9 @@ export default {
         createMethod: "",
         cardTitle: "",
         filename: "",
-        pages: 0
+        pages: 0,
+        used: false,
+        createId: null
       };
       this.paperAttachments.push(newAttachment);
     },