zhangjie 2 년 전
부모
커밋
4ac3d48b70

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

@@ -250,6 +250,9 @@
         background-color: #ffa280;
       }
     }
+    &.is-danger {
+      box-shadow: 0px 0 10px inset #ffa280;
+    }
   }
   .edit-property {
     flex-grow: 0;

+ 2 - 2
src/modules/card/autoBuild/paperStruct.js

@@ -46,8 +46,8 @@ function parseCommonTypeQuestion(question) {
 function parseNestedTypeQuestion(question) {
   let struct = [];
   let qinfo = `${question.number}`;
-  question.question.subQuestions.forEach((subq) => {
-    subq.number = subq.subNumber;
+  question.question.subQuestions.forEach((subq, sindex) => {
+    subq.number = sindex + 1;
     const info = parseCommonTypeQuestion(subq);
     struct.push(`${qinfo}-${info}`);
   });

+ 7 - 9
src/modules/paper/components/AuditPaperApply.vue

@@ -109,15 +109,13 @@ export default {
       this.toPage(1);
     },
     toDetail(row) {
-      window.open(
-        this.getRouterPath({
-          name: "EditPaper",
-          params: {
-            id: row.id,
-            parentView: "audit-paper",
-          },
-        })
-      );
+      this.$router.push({
+        name: "EditPaper",
+        params: {
+          id: row.id,
+          parentView: "audit-paper",
+        },
+      });
     },
     async toWithdraw(row) {
       const confirm = await this.$confirm(`确定要撤销该试卷的提交吗?`, "提示", {

+ 15 - 3
src/modules/paper/views/EditPaper.vue

@@ -267,6 +267,7 @@
                   'question-duplicate':
                     paperDetailUnit.question.checkDuplicateStatus ==
                     'TO_BE_DISPOSE',
+                  'is-danger': !paperDetailUnit.score,
                 },
               ]"
             >
@@ -423,15 +424,24 @@
                 v-for="(subQuestion, subIndex) in paperDetailUnit.question
                   .subQuestions"
                 :key="subIndex"
-                class="edit-part"
+                :class="[
+                  'edit-part',
+                  {
+                    'is-danger': !paperDetailUnit.subScoreList[subIndex],
+                  },
+                ]"
               >
                 <div class="edit-cont">
                   <div class="edit-cont-title">
                     <span>{{ subIndex + 1 }}. </span>
                     <rich-text :text-json="subQuestion.quesBody"></rich-text>
                     <span
-                      >({{ paperDetailUnit.subScoreList[subIndex] }}分)</span
+                      :class="{
+                        'color-danger': !paperDetailUnit.subScoreList[subIndex],
+                      }"
                     >
+                      ({{ paperDetailUnit.subScoreList[subIndex] }}分)
+                    </span>
                   </div>
                   <div
                     v-if="!isMatchingQuestion(paperDetailUnit.questionType)"
@@ -584,6 +594,7 @@ import ModifyDetailStruct from "../components/ModifyDetailStruct.vue";
 import ModifyRichText from "@/components/ModifyRichText.vue";
 import QuestionEditDialog from "../../question/components/QuestionEditDialog.vue";
 import SelectQuestionDialog from "../components/SelectQuestionDialog.vue";
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 import { calcSum } from "@/plugins/utils";
 
 export default {
@@ -598,6 +609,7 @@ export default {
     QuestionEditDialog,
     ImportFileDialog,
     SelectQuestionDialog,
+    QuestionAnswer,
   },
   data() {
     return {
@@ -689,7 +701,7 @@ export default {
     },
     checkPaperQuestionAllHasScore() {
       return !this.paper.paperDetails.some((detail) => {
-        return detail.paperDetailUnits.some((qUnit) => !qUnit.question.score);
+        return detail.paperDetailUnits.some((qUnit) => !qUnit.score);
       });
     },
     // 保存试卷

+ 42 - 7
src/modules/questions/component/QuestionAnswer.vue → src/modules/question/components/QuestionAnswer.vue

@@ -18,6 +18,8 @@
 </template>
 
 <script>
+import { deepCopy } from "@/plugins/utils";
+
 export default {
   name: "QuestionAnswer",
   props: {
@@ -66,18 +68,51 @@ export default {
   },
   methods: {
     initData() {
+      if (!this.data.quesAnswer) return;
+
+      if (this.IS_BOOL_QUESTION) {
+        this.quesAnswer = this.data.quesAnswer === "true" ? "正确" : "错误";
+        return;
+      }
+
+      let quesAnswer = null;
+      try {
+        quesAnswer = JSON.parse(this.data.quesAnswer);
+      } catch (error) {
+        console.error("答案格式错误");
+      }
+
+      if (!quesAnswer) return;
+
       if (this.IS_SELECT_QUESTION) {
-        this.quesAnswer = JSON.parse(this.data.quesAnswer)
+        this.quesAnswer = quesAnswer
           .map((item) => this.optionNames[item - 1])
           .join("");
-      } else if (this.IS_BOOL_QUESTION) {
-        this.quesAnswer = this.data.quesAnswer === "true" ? "正确" : "错误";
       } else if (this.IS_FILL_QUESTION) {
-        const answer = JSON.parse(this.data.quesAnswer);
-        this.quesAnswer = answer;
+        this.quesAnswer = quesAnswer.map((item) => {
+          let nitem = deepCopy(item);
+          if (!nitem.sections || !nitem.sections.length) {
+            nitem.sections = [
+              {
+                blocks: [
+                  {
+                    type: "text",
+                    value: `(${item.index + 1})`,
+                  },
+                ],
+              },
+            ];
+          } else {
+            nitem.sections[0].blocks.unshift({
+              type: "text",
+              value: `(${item.index + 1})`,
+            });
+          }
+
+          return nitem;
+        });
       } else if (this.IS_TEXT_QUESTION) {
-        const answer = JSON.parse(this.data.quesAnswer);
-        this.quesAnswer = answer[0];
+        this.quesAnswer = quesAnswer[0];
       }
     },
   },

+ 6 - 67
src/modules/question/components/QuestionBasePreview.vue

@@ -14,35 +14,21 @@
     </div>
     <div class="question-answer">
       <h4 class="question-answer-title">答案</h4>
-      <div class="question-answer-body">
-        <div v-if="IS_SELECTION">
-          {{ quesAnswer | selectionAnswerFilter }}
-        </div>
-        <div v-else-if="IS_BOOL_ANSWER_QUESTION">
-          {{ quesAnswer ? "对" : "错" }}
-        </div>
-        <div v-else-if="IS_FILL_BLANK_QUESTION || IS_TEXT_ANSWER_QUESTION">
-          <rich-text
-            v-for="(cont, cindex) in textQuesAnswer"
-            :key="cindex"
-            :text-json="cont"
-          ></rich-text>
-        </div>
-      </div>
+      <question-answer
+        class="question-answer-body"
+        :data="question"
+      ></question-answer>
     </div>
   </div>
 </template>
 
 <script>
 import { deepCopy } from "@/plugins/utils";
+import QuestionAnswer from "./QuestionAnswer.vue";
 
 export default {
   name: "QuestionBasePreview",
-  filters: {
-    selectionAnswerFilter(val) {
-      return val.map((value) => String.fromCharCode(64 + value)).join("");
-    },
-  },
+  components: { QuestionAnswer },
   props: {
     question: {
       type: Object,
@@ -63,23 +49,6 @@ export default {
       quesOptions: [],
     };
   },
-  computed: {
-    IS_FILL_BLANK_QUESTION() {
-      return this.question.questionType === "FILL_BLANK_QUESTION";
-    },
-    IS_SELECTION() {
-      return (
-        this.question.questionType === "SINGLE_ANSWER_QUESTION" ||
-        this.question.questionType === "MULTIPLE_ANSWER_QUESTION"
-      );
-    },
-    IS_TEXT_ANSWER_QUESTION() {
-      return this.question.questionType === "TEXT_ANSWER_QUESTION";
-    },
-    IS_BOOL_ANSWER_QUESTION() {
-      return this.question.questionType === "BOOL_ANSWER_QUESTION";
-    },
-  },
   created() {
     this.initData();
   },
@@ -118,36 +87,6 @@ export default {
         });
         this.quesOptions = quesOptions;
       }
-
-      if (!this.question.quesAnswer) return;
-      this.quesAnswer = JSON.parse(this.question.quesAnswer);
-
-      if (this.IS_FILL_BLANK_QUESTION) {
-        this.textQuesAnswer = this.quesAnswer.map((item) => {
-          let nitem = deepCopy(item);
-          if (!nitem.sections || !nitem.sections.length) {
-            nitem.sections = [
-              {
-                blocks: [
-                  {
-                    type: "text",
-                    value: `(${item.index + 1})`,
-                  },
-                ],
-              },
-            ];
-          } else {
-            nitem.sections[0].blocks.unshift({
-              type: "text",
-              value: `(${item.index + 1})`,
-            });
-          }
-
-          return nitem;
-        });
-      } else if (this.IS_TEXT_ANSWER_QUESTION) {
-        this.textQuesAnswer = this.quesAnswer;
-      }
     },
   },
 };

+ 3 - 0
src/modules/question/components/QuestionPreviewDialog.vue

@@ -119,8 +119,11 @@
 </template>
 
 <script>
+import QuestionAnswer from "./QuestionAnswer.vue";
+
 export default {
   name: "QuestionPreviewDialog",
+  components: { QuestionAnswer },
   props: {
     question: {
       type: Object,

+ 2 - 0
src/modules/questions/views/EditPaper.vue

@@ -1194,6 +1194,7 @@ import PaperBasicComposition from "./PaperBasicComposition.vue";
 import PaperQuestionType from "./PaperQuestionType.vue";
 import PaperBlue from "./PaperBlue.vue";
 import AuditInfo from "./AuditInfo.vue";
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 import { checkRichTextContentIsEmpty } from "@/plugins/utils";
 
 export default {
@@ -1203,6 +1204,7 @@ export default {
     PaperQuestionType,
     PaperBlue,
     AuditInfo,
+    QuestionAnswer,
   },
   data() {
     return {

+ 2 - 0
src/modules/questions/views/EditPaperPendingTrial.vue

@@ -1228,6 +1228,7 @@ import PaperQuestionType from "./PaperQuestionType.vue";
 import PaperBlue from "./PaperBlue.vue";
 import AuditInfo from "./AuditInfo.vue";
 import AuditPaper from "./AuditPaper.vue";
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 import { checkRichTextContentIsEmpty } from "@/plugins/utils";
 
 export default {
@@ -1238,6 +1239,7 @@ export default {
     PaperBlue,
     AuditInfo,
     AuditPaper,
+    QuestionAnswer,
   },
   data() {
     return {

+ 2 - 0
src/modules/questions/views/QuestionInfo.vue

@@ -149,8 +149,10 @@
 </template>
 <script>
 import { mapState } from "vuex";
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 
 export default {
+  components: { QuestionAnswer },
   props: {
     question: {
       type: Object,

+ 3 - 0
src/modules/questions/views/QuestionPreview.vue

@@ -83,8 +83,11 @@
 </template>
 
 <script>
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
+
 export default {
   name: "QuestionPreview",
+  components: { QuestionAnswer },
   props: {
     quesModel: {
       type: Object,

+ 2 - 1
src/modules/questions/views/ViewPaper.vue

@@ -409,10 +409,11 @@
 import { QUESTION_API } from "@/constants/constants";
 import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
 import { mapState } from "vuex";
+import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 
 export default {
   name: "EditPaperApp",
-  components: {},
+  components: { QuestionAnswer },
   data() {
     return {
       hValue: "100px",