Răsfoiți Sursa

试卷上传校验修改

zhangjie 2 ani în urmă
părinte
comite
0275f9d320

+ 0 - 8
src/modules/base/components/RuleExam.vue

@@ -56,13 +56,6 @@
         <el-switch v-model="modalForm.review" inactive-color="#dcdfe6">
         </el-switch>
       </el-form-item>
-      <el-form-item label="入库强制包含试卷:" required>
-        <el-switch v-model="modalForm.includePaper" inactive-color="#dcdfe6">
-        </el-switch>
-        <p class="tips-info">
-          注意:若入库时非强制包含试卷,适用于同时有课程要求打印试卷,有的课程不打印试卷的场景。因此,印刷计划里即使勾选了“试卷”,有试卷则打印,否则不打印。
-        </p>
-      </el-form-item>
       <el-form-item label="提交印刷方式:" required>
         <el-radio-group v-model="modalForm.printMethod">
           <el-radio
@@ -98,7 +91,6 @@ import { getEnums } from "../../login/api";
 const initModalForm = {
   id: null,
   review: true,
-  includePaper: true,
   examNumberDigit: 8,
   printMethod: "AUTO",
   requiredFields: "[]",

+ 23 - 6
src/modules/exam/components/ApplyContent.vue

@@ -691,6 +691,8 @@ export default {
       this.curTaskApply.cardRuleId = this.examTask.cardRuleId;
       this.curTaskApply.customCard = this.examTask.customCard;
       this.curTaskApply.setup = this.examTask.setup;
+      this.curTaskApply.includePaper =
+        data.printContent.indexOf("PAPER") !== -1;
       this.paperAttachments = this.curTaskApply.paperAttachmentIds
         ? JSON.parse(this.curTaskApply.paperAttachmentIds)
         : [];
@@ -1019,14 +1021,29 @@ export default {
       return data;
     },
     checkDataValid() {
-      const attachmentValid = !this.paperAttachments.some(
-        item => !item.attachmentId
-      );
       // 设置了入库强制包含试卷时,校验试卷是否上传。
-      if (this.curTaskApply.includePaper && !attachmentValid) {
-        this.$message.error("请完成试卷文件上传!");
-        return;
+      // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
+      if (this.curTaskApply.includePaper) {
+        const attachmentValid = !this.paperAttachments.some(
+          item => !item.attachmentId
+        );
+        if (!attachmentValid) {
+          this.$message.error("请完成试卷文件上传!");
+          return Promise.reject();
+        }
+      } else {
+        const hasUploadPaperAttachments = this.paperAttachments.filter(
+          item => item.attachmentId
+        );
+        if (
+          hasUploadPaperAttachments.length > 0 &&
+          hasUploadPaperAttachments.length !== this.paperAttachments.length
+        ) {
+          this.$message.error("有试卷文件未完成上传!");
+          return Promise.reject();
+        }
       }
+
       // if (!this.paperConfirmAttachments.length) {
       //   this.$message.error("请上传附件!");
       //   return;

+ 0 - 1
src/modules/exam/components/ModifyTaskApply.vue

@@ -222,7 +222,6 @@ export default {
     },
     initData(val) {
       this.modalForm = this.$objAssign(initModalForm, val);
-      this.modalForm.includePaper = this.examRule.includePaper;
       this.modalForm.review = this.examRule.review;
       this.modalForm.customCard = this.examRule.customCard;
     },

+ 22 - 16
src/modules/exam/components/ModifyTaskPaper.vue

@@ -235,7 +235,6 @@ import UploadPaperDialog from "./UploadPaperDialog";
 import ModifyCard from "../../card/components/ModifyCard";
 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";
 
@@ -316,18 +315,10 @@ export default {
       curAttachment: {},
       curUploadType: "paper",
       abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      includePaper: false,
       cards: []
     };
   },
-  created() {
-    this.getExamRule();
-  },
   methods: {
-    async getExamRule() {
-      const examRule = await examRuleDetail();
-      this.includePaper = examRule && examRule.includePaper;
-    },
     async getCardList() {
       if (!this.curTaskApply.courseCode || !this.curTaskApply.examId) return;
       const data = await cardForSelectList({
@@ -342,7 +333,8 @@ export default {
       this.curTaskApply.courseCode = this.instance.courseCode;
       this.curTaskApply.courseName = this.instance.courseName;
       this.curTaskApply.cardRuleId = this.instance.cardRuleId;
-      this.curTaskApply.includePaper = this.includePaper;
+      this.curTaskApply.includePaper =
+        data.printContent.indexOf("PAPER") !== -1;
       this.paperAttachments = data.paperAttachmentIds
         ? JSON.parse(data.paperAttachmentIds)
         : [];
@@ -511,13 +503,27 @@ export default {
       });
     },
     checkDataValid() {
-      const attachmentValid = !this.paperAttachments.some(
-        item => !item.attachmentId
-      );
       // 设置了入库强制包含试卷时,校验试卷是否上传。
-      if (this.curTaskApply.includePaper && !attachmentValid) {
-        this.$message.error("请完成试卷文件上传!");
-        return;
+      // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
+      if (this.curTaskApply.includePaper) {
+        const attachmentValid = !this.paperAttachments.some(
+          item => !item.attachmentId
+        );
+        if (!attachmentValid) {
+          this.$message.error("请完成试卷文件上传!");
+          return Promise.reject();
+        }
+      } else {
+        const hasUploadPaperAttachments = this.paperAttachments.filter(
+          item => item.attachmentId
+        );
+        if (
+          hasUploadPaperAttachments.length > 0 &&
+          hasUploadPaperAttachments.length !== this.paperAttachments.length
+        ) {
+          this.$message.error("有试卷文件未完成上传!");
+          return Promise.reject();
+        }
       }
 
       const cardValid = !this.paperAttachments.some(item => !item.cardId);

+ 21 - 6
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -582,14 +582,29 @@ export default {
       const valid = await this.$refs.examTaskComp.validate().catch(() => {});
       if (!valid) return Promise.reject();
 
-      const attachmentValid = !this.paperAttachments.some(
-        item => !item.attachmentId
-      );
       // 设置了入库强制包含试卷时,校验试卷是否上传。
-      if (this.examTaskDetail.includePaper && !attachmentValid) {
-        this.$message.error("请完成试卷文件上传!");
-        return Promise.reject();
+      // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
+      if (this.examTaskDetail.includePaper) {
+        const attachmentValid = !this.paperAttachments.some(
+          item => !item.attachmentId
+        );
+        if (!attachmentValid) {
+          this.$message.error("请完成试卷文件上传!");
+          return Promise.reject();
+        }
+      } else {
+        const hasUploadPaperAttachments = this.paperAttachments.filter(
+          item => item.attachmentId
+        );
+        if (
+          hasUploadPaperAttachments.length > 0 &&
+          hasUploadPaperAttachments.length !== this.paperAttachments.length
+        ) {
+          this.$message.error("有试卷文件未完成上传!");
+          return Promise.reject();
+        }
       }
+
       // if (!this.paperConfirmAttachments.length) {
       //   this.$message.error("请上传附件!");
       //   return;