刘洋 пре 9 месеци
родитељ
комит
72f617a16e

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

@@ -369,6 +369,9 @@ body {
 }
 .tips-error {
   color: $--color-danger;
+  &.hide{
+    opacity:0;
+  }
 }
 .dialog-input-width {
   width: 200px;

+ 14 - 1
src/modules/question/components/QuestionEditDialog.vue

@@ -323,7 +323,9 @@ export default {
         this.close();
         return;
       }
-      const res = await updateQuestionApi(questionModel).catch(() => {});
+      const res = await updateQuestionApi({
+        ...questionModel,
+      }).catch(() => {});
       this.loading = false;
       if (!res) return;
 
@@ -353,3 +355,14 @@ export default {
   },
 };
 </script>
+<style lang="scss" scoped>
+.common-form-item {
+  display: flex;
+  align-items: center;
+  .label {
+    width: 100px;
+    text-align: right;
+    padding-right: 12px;
+  }
+}
+</style>

+ 68 - 5
src/modules/question/components/QuestionImportEdit.vue

@@ -101,6 +101,7 @@
                       v-for="(exception, index) in richJsonItem.exceptions"
                       :key="index"
                       @click="highLightErrorText(exception)"
+                      :class="{ hide: inHasIgnore(exception.indexs) }"
                     >
                       {{ exception.message }}
                     </p>
@@ -210,8 +211,35 @@ export default {
   mixins: [scrollMixins, timeMixin],
   computed: {
     hasErrorTips() {
-      return (this.paperRichJsonGroup || []).some((item) => {
-        return item?.exceptions?.length;
+      // return (this.paperRichJsonGroup || []).some((item) => {
+      //   return item?.exceptions?.length;
+      // });
+      let detailInfo = this.paperData;
+      if (!Array.isArray(detailInfo)) {
+        return false;
+      }
+      return detailInfo.some((detail) => {
+        return detail?.questions?.some((item) => {
+          let questionExceptions = item.questionExceptions;
+          let arr = item.ignoreOptionRepeat
+            ? questionExceptions.filter(
+                (v) => !v.cause.includes("选项内容相同")
+              )
+            : questionExceptions;
+          if (!item.subQuestions?.length) {
+            return !!arr.length;
+          } else {
+            return item.subQuestions.some((sub) => {
+              let { questionExceptions = [] } = sub;
+              let ar = sub.ignoreOptionRepeat
+                ? questionExceptions.filter(
+                    (v) => !v.cause.includes("选项内容相同")
+                  )
+                : questionExceptions;
+              return !!ar.length;
+            });
+          }
+        });
       });
     },
   },
@@ -236,6 +264,7 @@ export default {
   },
   data() {
     return {
+      ignoreRepeatExceptionIndexArr: [],
       modalIsShow: false,
       loading: false,
       questionKey: "",
@@ -259,8 +288,42 @@ export default {
       showIframeDialog: false,
     };
   },
-
+  created() {
+    this.$bus.on("markIgnoreRepeatQuestion", this.markIgnoreRepeat);
+  },
   methods: {
+    inHasIgnore(indexes) {
+      return this.ignoreRepeatExceptionIndexArr.includes(indexes.toString());
+    },
+    markIgnoreRepeat(exceptionIndex, bool) {
+      this.paperData.forEach((detail) => {
+        detail.questions.forEach((question) => {
+          if (
+            question.questionExceptions?.length &&
+            question.questionExceptions.find(
+              (v) => v.exceptionIndex.toString() == exceptionIndex
+            )
+          ) {
+            question.ignoreOptionRepeat = bool;
+          }
+          if (question.subQuestions?.length) {
+            question.subQuestions.forEach((sub) => {
+              if (
+                sub.questionExceptions?.length &&
+                sub.questionExceptions.find(
+                  (v) => v.exceptionIndex.toString() == exceptionIndex
+                )
+              ) {
+                sub.ignoreOptionRepeat = bool;
+              }
+            });
+          }
+        });
+      });
+      this.paperData = JSON.parse(JSON.stringify(this.paperData));
+      this.paperRichJsonGroup = this.getRichTextGroup();
+      this.ignoreRepeatExceptionIndexArr.push(exceptionIndex);
+    },
     urlToBlob(url, callback) {
       let xhr = new XMLHttpRequest();
       xhr.open("GET", url, true);
@@ -282,6 +345,7 @@ export default {
       });
     },
     async visibleChange() {
+      this.ignoreRepeatExceptionIndexArr = [];
       await this.getCourseProperty();
 
       // this.resetData({
@@ -965,7 +1029,7 @@ export default {
 
       if (this.loading) return;
       this.loading = true;
-
+      console.log("detailInfo", detailInfo);
       const res = await questionImportPaperSave({
         ...this.data.importData,
         detailInfo,
@@ -1036,7 +1100,6 @@ export default {
     },
     // rich test editor
     richTextFocus(richTextGroup) {
-      console.log("ggg", richTextGroup);
       this.$refs.QuestionImportPaperEdit.scrollToContentByIndex(
         richTextGroup.indexs
       );

+ 6 - 1
src/modules/question/components/QuestionImportPaperEdit.vue

@@ -82,6 +82,12 @@ export default {
       if (val && oldval && val.id !== oldval.id)
         this.updateQuestionContIndexTop();
     },
+    paper() {
+      this.transformPaperData();
+      this.$nextTick(() => {
+        this.updateQuestionContIndexTop();
+      });
+    },
   },
   mounted() {
     this.transformPaperData();
@@ -150,7 +156,6 @@ export default {
     transformPaperData() {
       let paperData = deepCopy(this.paper);
       let questionContIndexList = [];
-
       paperData.forEach((detail, dIndex) => {
         questionContIndexList.push([
           `detail-${dIndex}`,

+ 8 - 0
src/modules/question/components/edit/SelectQuestion.vue

@@ -93,6 +93,14 @@
           </el-checkbox>
         </el-checkbox-group> -->
       </el-form-item>
+      <el-form-item prop="ignoreOptionRepeat" label="允许答案重复">
+        <el-switch
+          v-model="modalForm.ignoreOptionRepeat"
+          active-text="是"
+          inactive-text="否"
+        >
+        </el-switch>
+      </el-form-item>
       <el-form-item label="答案解析">
         <v-editor
           v-model="modalForm.answerAnalysis"

+ 18 - 1
src/modules/question/components/import-edit/SelectQuestion.vue

@@ -44,7 +44,19 @@
           v-for="(cont, index) in question.exceptions"
           :key="index"
         >
-          {{ cont }}
+          <!-- {{ cont }} -->
+          {{
+            question.ignoreOptionRepeat && cont.includes("选项内容相同")
+              ? ""
+              : cont
+          }}
+          <el-button
+            size="mini"
+            type="primary"
+            v-if="!question.ignoreOptionRepeat && cont.includes('选项内容相同')"
+            @click.stop="setIgnore(question, index, true)"
+            >忽略</el-button
+          >
         </p>
       </div>
       <question-info-view
@@ -145,6 +157,11 @@ export default {
   },
   methods: {
     ...mapMutations("import-edit", ["setCurQuestion"]),
+    setIgnore(question, index, bool) {
+      let targetQuestionException = question.questionExceptions[index];
+      let exceptionIndex = targetQuestionException.exceptionIndex.toString();
+      this.$bus.emit("markIgnoreRepeatQuestion", exceptionIndex, bool);
+    },
     initData() {
       this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
       // 因为会缓存答案,所以会导致答案的格式完全不确定。

+ 13 - 13
src/modules/question/components/import-edit/scrollMixins.js

@@ -1,24 +1,27 @@
+import { throttle } from "lodash";
 export default {
   methods: {
     registScrollEvent() {
       document
         .getElementById("qe-part-paper")
-        .addEventListener("scroll", this.paperScrollEvent);
+        .addEventListener("scroll", this._paperScrollEvent);
       document
         .getElementById("qe-part-richtext-list")
-        .parentNode.addEventListener("scroll", this.richTextScrollEvent);
+        .parentNode.addEventListener("scroll", this._richTextScrollEvent);
     },
     removeScrollEvent() {
       document
         .getElementById("qe-part-paper")
-        .removeEventListener("scroll", this.paperScrollEvent);
+        .removeEventListener("scroll", this._paperScrollEvent);
       document
         .getElementById("qe-part-richtext-list")
-        .parentNode.removeEventListener("scroll", this.richTextScrollEvent);
+        .parentNode.removeEventListener("scroll", this._richTextScrollEvent);
     },
+    _paperScrollEvent: throttle(function (e) {
+      this.paperScrollEvent(e);
+    }, 20),
     paperScrollEvent(e) {
-      // e.preventDefault();
-      // e.stopPropagation();
+      console.log(2, e.target);
       if (this.scrollType === "rich-text") {
         this.lastPaperScrollTop =
           document.getElementById("qe-part-paper").scrollTop;
@@ -84,18 +87,15 @@ export default {
       const textScrollTop =
         sectionOffsetTop +
         targeContPercent * (nextSectionOffsetTop - sectionOffsetTop);
-      // console.log(
-      //   targeCont[2],
-      //   textScrollTop,
-      //   targeContPercent,
-      //   nextSectionOffsetTop,
-      //   sectionOffsetTop
-      // );
       richTextContainerDom.scrollTop = isScrollDown
         ? Math.max(textScrollTop, richTextContainerDom.scrollTop)
         : Math.min(textScrollTop, richTextContainerDom.scrollTop);
     },
+    _richTextScrollEvent: throttle(function (e) {
+      this.richTextScrollEvent(e);
+    }, 20),
     richTextScrollEvent(e) {
+      console.log(1, e.target);
       if (this.scrollType === "paper") {
         this.lastRichTextScrollTop = document.getElementById(
           "qe-part-richtext-list"