zhangjie 4 days ago
parent
commit
da4e04e57f

+ 54 - 10
src/modules/question/components/QuestionImportEdit.vue

@@ -100,6 +100,7 @@
                     :upload-data="uploadData"
                     :upload-data="uploadData"
                     :upload-url="uploadUrl"
                     :upload-url="uploadUrl"
                     :format="importFileTypes"
                     :format="importFileTypes"
+                    :accept="accept"
                     @valid-error="validError"
                     @valid-error="validError"
                     @upload-success="uploaded"
                     @upload-success="uploaded"
                     :auto-upload="false"
                     :auto-upload="false"
@@ -195,7 +196,7 @@
               <div class="qe-part-head-menu">
               <div class="qe-part-head-menu">
                 <el-tabs
                 <el-tabs
                   v-model="filterQuestionType"
                   v-model="filterQuestionType"
-                  @tab-click="filterQuestionTypeChange"
+                  :before-leave="(val) => filterQuestionTypeChange(val, true)"
                 >
                 >
                   <el-tab-pane
                   <el-tab-pane
                     :label="`全部(${
                     :label="`全部(${
@@ -360,6 +361,9 @@ export default {
         });
         });
       });
       });
     },
     },
+    accept() {
+      return this.importFileTypes.map((item) => `.${item}`).join(",");
+    },
   },
   },
   data() {
   data() {
     return {
     return {
@@ -428,7 +432,7 @@ export default {
     paperData: {
     paperData: {
       handler() {
       handler() {
         this.parseQuestionStatData();
         this.parseQuestionStatData();
-        this.filterQuestionTypeChange({ name: this.filterQuestionType });
+        this.filterQuestionTypeChange(this.filterQuestionType);
         this.questionKey = randomCode();
         this.questionKey = randomCode();
       },
       },
     },
     },
@@ -450,6 +454,17 @@ export default {
       this.getCourseProperty();
       this.getCourseProperty();
       this.uploadData = { courseId: this.modalForm.courseId };
       this.uploadData = { courseId: this.modalForm.courseId };
     },
     },
+    checkQuestionNormal(question) {
+      if (question.subQuestions?.length) {
+        return (
+          question.subQuestions.filter((sub) => {
+            return sub.questionExceptions.length;
+          }).length === 0
+        );
+      } else {
+        return !question.questionExceptions.length;
+      }
+    },
     parseQuestionStatData() {
     parseQuestionStatData() {
       const total = calcSum(
       const total = calcSum(
         this.paperData.map((item) => item.questions.length)
         this.paperData.map((item) => item.questions.length)
@@ -457,20 +472,26 @@ export default {
       const successCount = calcSum(
       const successCount = calcSum(
         this.paperData.map(
         this.paperData.map(
           (item) =>
           (item) =>
-            item.questions.filter((v) => !v.questionExceptions.length).length
+            item.questions.filter((v) => {
+              return this.checkQuestionNormal(v);
+            }).length
         )
         )
       );
       );
       const errorCount = calcSum(
       const errorCount = calcSum(
         this.paperData.map(
         this.paperData.map(
           (item) =>
           (item) =>
-            item.questions.filter((v) => v.questionExceptions.length).length
+            item.questions.filter((v) => {
+              return !this.checkQuestionNormal(v);
+            }).length
         )
         )
       );
       );
       const questionTypeStat = {};
       const questionTypeStat = {};
       this.paperData.forEach((detail) => {
       this.paperData.forEach((detail) => {
         let questions = detail.questions;
         let questions = detail.questions;
         if (this.onlyErrorQuestion) {
         if (this.onlyErrorQuestion) {
-          questions = questions.filter((v) => v.questionExceptions.length);
+          questions = questions.filter((v) => {
+            return !this.checkQuestionNormal(v);
+          });
         }
         }
         questions.forEach((question) => {
         questions.forEach((question) => {
           const { questionType } = question;
           const { questionType } = question;
@@ -500,7 +521,8 @@ export default {
     },
     },
     onlyErrorQuestionChange() {
     onlyErrorQuestionChange() {
       this.parseQuestionStatData();
       this.parseQuestionStatData();
-      this.filterQuestionTypeChange({ name: this.filterQuestionType });
+      this.filterQuestionTypeChange(this.filterQuestionType, true);
+
       this.questionKey = randomCode();
       this.questionKey = randomCode();
     },
     },
     inHasIgnore(indexes) {
     inHasIgnore(indexes) {
@@ -587,12 +609,14 @@ export default {
         this.getRichTextIndexList();
         this.getRichTextIndexList();
       });
       });
     },
     },
-    filterQuestionTypeChange(val) {
-      this.filterQuestionType = val.name;
+    filterQuestionTypeChange(val, updateModify = false) {
+      if (updateModify) this.updateCurTagPaperData();
+
+      this.filterQuestionType = val;
 
 
       const onlyErrorValidater = (question) => {
       const onlyErrorValidater = (question) => {
         if (this.onlyErrorQuestion) {
         if (this.onlyErrorQuestion) {
-          return Boolean(question.questionExceptions.length);
+          return !this.checkQuestionNormal(question);
         }
         }
         return true;
         return true;
       };
       };
@@ -966,9 +990,29 @@ export default {
       });
       });
       return data;
       return data;
     },
     },
+    updateCurTagPaperData() {
+      let tagPaperData = this.$refs.QuestionImportPaperEdit?.getData();
+      const tagPaperMap = {};
+      tagPaperData.forEach((detail) => {
+        detail.questions.forEach((question) => {
+          const id = `${detail.number}-${question.number}`;
+          tagPaperMap[id] = question;
+        });
+      });
+
+      this.paperData.forEach((detail) => {
+        detail.questions.forEach((question) => {
+          const id = `${detail.number}-${question.number}`;
+          if (tagPaperMap[id]) {
+            Object.assign(question, tagPaperMap[id]);
+          }
+        });
+      });
+    },
     getImportPaperData() {
     getImportPaperData() {
       if (!this.$refs.QuestionImportPaperEdit) return [];
       if (!this.$refs.QuestionImportPaperEdit) return [];
-      let paperData = deepCopy(this.$refs.QuestionImportPaperEdit.getData());
+      this.updateCurTagPaperData();
+      let paperData = deepCopy(this.paperData);
       const transformFieldMap = { body: "quesBody", options: "quesOptions" };
       const transformFieldMap = { body: "quesBody", options: "quesOptions" };
       const fields = Object.keys(transformFieldMap);
       const fields = Object.keys(transformFieldMap);
       const course = {
       const course = {

+ 7 - 1
src/modules/question/views/QuestionManage.vue

@@ -545,6 +545,7 @@ export default {
       this.setCheckOptionRepeat(res.data);
       this.setCheckOptionRepeat(res.data);
     },
     },
     async checkGptEnable() {
     async checkGptEnable() {
+      this.aiWarningMsg = "";
       const res = await checkGptQuestionEnableApi();
       const res = await checkGptQuestionEnableApi();
       // this.gptQuestionEnable = res.data;
       // this.gptQuestionEnable = res.data;
       if (res.data) {
       if (res.data) {
@@ -636,7 +637,12 @@ export default {
         this.$refs.QuestionImportDialog.open();
         this.$refs.QuestionImportDialog.open();
       }
       }
     },
     },
-    toAIQuestion() {
+    async toAIQuestion() {
+      await this.checkGptEnable();
+      if (this.aiWarningMsg) {
+        return;
+      }
+
       if (!this.filter.courseId) {
       if (!this.filter.courseId) {
         this.$message.error("请先选择课程!");
         this.$message.error("请先选择课程!");
         return;
         return;

+ 1 - 1
src/modules/questions/views/Course.vue

@@ -234,7 +234,7 @@
     <course-outline-dialog
     <course-outline-dialog
       ref="CourseOutlineDialog"
       ref="CourseOutlineDialog"
       :course="curCourse"
       :course="curCourse"
-      @comfirm="searchForm"
+      @modified="searchForm"
     ></course-outline-dialog>
     ></course-outline-dialog>
   </section>
   </section>
 </template>
 </template>