瀏覽代碼

新需求和bug修复

刘洋 1 年之前
父節點
當前提交
91b9c54908

+ 4 - 4
src/modules/paper/components/SelectQuestionDialog.vue

@@ -99,8 +99,8 @@
                 v-for="(content, propIndex) in scope.row.quesProperties"
                 :key="propIndex"
               >
-                {{ content.courseProperty && content.courseProperty.name }}
-                <span style="margin: 0 3px">/</span>
+                <!-- {{ content.courseProperty && content.courseProperty.name }}
+                <span style="margin: 0 3px">/</span> -->
                 {{ content.firstProperty && content.firstProperty.name }}
                 <span v-if="content.secondProperty" style="margin: 0 3px"
                   >/</span
@@ -186,8 +186,8 @@
                 v-for="(content, propIndex) in scope.row.quesProperties"
                 :key="propIndex"
               >
-                {{ content.courseProperty && content.courseProperty.name }}
-                <span style="margin: 0 3px">/</span>
+                <!-- {{ content.courseProperty && content.courseProperty.name }}
+                <span style="margin: 0 3px">/</span> -->
                 {{ content.firstProperty && content.firstProperty.name }}
                 <span v-if="content.secondProperty" style="margin: 0 3px"
                   >/</span

+ 4 - 4
src/modules/paper/views/EditPaper.vue

@@ -560,8 +560,8 @@
                     effect="dark"
                     style="margin-right: 5px; margin-bottom: 5px"
                   >
-                    {{ content.courseProperty && content.courseProperty.name }}
-                    <span style="margin: 0 3px">/</span>
+                    <!-- {{ content.courseProperty && content.courseProperty.name }}
+                    <span style="margin: 0 3px">/</span> -->
                     {{ content.firstProperty && content.firstProperty.name }}
                     <span v-if="content.secondProperty" style="margin: 0 3px"
                       >/</span
@@ -655,10 +655,10 @@
                       effect="dark"
                       style="margin-right: 5px; margin-bottom: 5px"
                     >
-                      {{
+                      <!-- {{
                         content.courseProperty && content.courseProperty.name
                       }}
-                      <span style="margin: 0 3px">/</span>
+                      <span style="margin: 0 3px">/</span> -->
                       {{ content.firstProperty && content.firstProperty.name }}
                       <span v-if="content.secondProperty" style="margin: 0 3px"
                         >/</span

+ 2 - 2
src/modules/question/components/GptQuestionEditDialog.vue

@@ -54,8 +54,8 @@
             type="primary"
             style="margin-right: 5px; margin-bottom: 5px"
           >
-            {{ content.courseProperty && content.courseProperty.name }}
-            <span style="margin: 0 3px">/</span>
+            <!-- {{ content.courseProperty && content.courseProperty.name }}
+            <span style="margin: 0 3px">/</span> -->
             {{ content.firstProperty && content.firstProperty.name }}
             <span
               v-if="content.secondProperty && content.secondProperty.name"

+ 14 - 7
src/modules/question/components/KnowledgePoints.vue

@@ -66,9 +66,11 @@ export default {
     };
   },
   methods: {
-    getTreeData(cId) {
+    getTreeData() {
       this.$http
-        .post(QUESTION_API + "/property/all/by/course?courseId=" + cId)
+        .post(
+          QUESTION_API + "/property/all/by/course?courseId=" + this.courseId
+        )
         .then((res) => {
           res.data.propertys.forEach((item) => {
             item.propertyList = item.propertyList.map((v) => {
@@ -140,11 +142,20 @@ export default {
       this.showDialog = false;
     },
     whenOpen() {
+      this.getTreeData();
+    },
+  },
+  watch: {
+    // courseId(cId) {
+    //   this.getTreeData(cId);
+    // },
+    treeData() {
       this.$nextTick(() => {
         // if (this.checkedIds.length) {
         //   this.$refs.tree.setCheckedKeys(this.checkedIds);
         // }
         if (this.checkedProperties.length) {
+          console.log("this.checkedProperties", this.checkedProperties);
           let ids = [];
           for (let i = 0; i < this.checkedProperties.length; i++) {
             let obj = this.checkedProperties[i];
@@ -154,16 +165,12 @@ export default {
               ids.push(obj.firstProperty.id);
             }
           }
+          console.log("ids", ids);
           this.$refs.tree.setCheckedKeys(Array.from(new Set(ids)));
         }
       });
     },
   },
-  watch: {
-    courseId(cId) {
-      this.getTreeData(cId);
-    },
-  },
 };
 </script>
 <style lang="scss" scoped></style>

+ 1 - 0
src/modules/question/components/QuestionImportEdit.vue

@@ -978,6 +978,7 @@ export default {
     },
     // rich test editor
     richTextFocus(richTextGroup) {
+      console.log("ggg", richTextGroup);
       this.$refs.QuestionImportPaperEdit.scrollToContentByIndex(
         richTextGroup.indexs
       );

+ 0 - 1
src/modules/question/components/QuestionInfoEdit.vue

@@ -208,7 +208,6 @@ export default {
           this.question.control
         );
       }
-      console.log("modalForm.quesProperties", modalForm.quesProperties);
       if (modalForm.quesProperties && modalForm.quesProperties.length) {
         modalForm.quesProperties.forEach((item) => {
           // let ids = [item.courseProperty.id, item.firstProperty.id];

+ 4 - 4
src/modules/question/components/QuestionPreviewDialog.vue

@@ -40,8 +40,8 @@
             effect="dark"
             style="margin-right: 5px; margin-bottom: 5px"
           >
-            {{ content.courseProperty && content.courseProperty.name }}
-            <span style="margin: 0 3px">/</span>
+            <!-- {{ content.courseProperty && content.courseProperty.name }}
+            <span style="margin: 0 3px">/</span> -->
             {{ content.firstProperty && content.firstProperty.name }}
             <span
               v-if="content.secondProperty && content.secondProperty.name"
@@ -93,8 +93,8 @@
                   effect="dark"
                   style="margin-right: 5px; margin-bottom: 5px"
                 >
-                  {{ content.courseProperty && content.courseProperty.name }}
-                  <span style="margin: 0 3px">/</span>
+                  <!-- {{ content.courseProperty && content.courseProperty.name }}
+                  <span style="margin: 0 3px">/</span> -->
                   {{ content.firstProperty && content.firstProperty.name }}
                   <span
                     v-if="content.secondProperty && content.secondProperty.name"

+ 2 - 2
src/modules/question/components/import-edit/QuestionInfoView.vue

@@ -35,8 +35,8 @@
           type="info"
           style="margin-right: 5px; margin-bottom: 5px"
         >
-          {{ content.courseProperty && content.courseProperty.name }}
-          <span style="margin: 0 3px">/</span>
+          <!-- {{ content.courseProperty && content.courseProperty.name }}
+          <span style="margin: 0 3px">/</span> -->
           {{ content.firstProperty && content.firstProperty.name }}
           <span v-if="content.secondProperty" style="margin: 0 3px">/</span>
           {{ content.secondProperty && content.secondProperty.name }}

+ 39 - 1
src/modules/question/components/import-edit/TextAnswerQuestion.vue

@@ -33,8 +33,9 @@
         </el-form-item>
         <el-form-item label="答案解析">
           <v-editor
-            v-model="modalForm.answerAnalysis"
+            v-model="answerAnalysis"
             :enable-audio="false"
+            @change="answerAnalysisChange"
           ></v-editor>
         </el-form-item>
       </el-form>
@@ -75,6 +76,7 @@ export default {
     return {
       modalForm: {},
       quesAnswer: null,
+      answerAnalysis: null,
     };
   },
   computed: {
@@ -91,9 +93,13 @@ export default {
     initData() {
       this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
       this.initAnswer(this.question.quesAnswer);
+      this.initAnswerAnalysis(this.question.answerAnalysis);
       this.quesAnswer = this.modalForm.quesAnswer[0] || {
         sections: [],
       };
+      this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
+        sections: [],
+      };
     },
     initAnswer(answer) {
       let quesAnswer = [];
@@ -116,6 +122,27 @@ export default {
         this.modalForm.quesAnswer = [];
       }
     },
+    initAnswerAnalysis(answer) {
+      let answerAnalysis = [];
+      if (answer) {
+        try {
+          answerAnalysis = JSON.parse(answer);
+        } catch (err) {
+          console.log(`answer error:${answer}`);
+        }
+      }
+      if (this.checkAnswerFormatValid(answerAnalysis)) {
+        this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
+          isAnEmptyRichText(item)
+            ? {
+                sections: [],
+              }
+            : item
+        );
+      } else {
+        this.modalForm.answerAnalysis = [];
+      }
+    },
     checkAnswerFormatValid(answer) {
       return objTypeOf(answer) === "array";
     },
@@ -127,6 +154,13 @@ export default {
         },
       ];
     },
+    answerAnalysisChange() {
+      this.modalForm.answerAnalysis = [
+        {
+          ...this.answerAnalysis,
+        },
+      ];
+    },
     questionInfoChange(questionInfo) {
       this.modalForm = Object.assign({}, this.modalForm, questionInfo);
     },
@@ -136,6 +170,10 @@ export default {
     getData() {
       let data = Object.assign({}, this.question, this.modalForm);
       data.quesAnswer = JSON.stringify(data.quesAnswer);
+      data.answerAnalysis =
+        data.answerAnalysis && data.answerAnalysis?.length
+          ? data.answerAnalysis[0]
+          : { sections: [] };
       return data;
     },
     activeQuestion() {

+ 55 - 0
src/modules/questions/views/PropertyInfo.vue

@@ -39,6 +39,8 @@
           <svg-btn name="bianji" :disabled="showButton" @click="updateProperty"
             >编辑</svg-btn
           >
+          <svg-btn name="daoru" @click="impCourseProperty">导入</svg-btn>
+          <svg-btn name="daochu" @click="exportCourseProperty">导出</svg-btn>
           <svg-btn
             name="shanchu"
             :disabled="!multipleSelection.length"
@@ -198,16 +200,30 @@
         <el-button type="danger" plain @click="closeModel">取消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 导入弹窗 -->
+    <import-file-dialog
+      ref="ImportCourseDialog"
+      dialog-title="导入知识点"
+      :template-url="courseTemplateUrl"
+      :upload-url="uploadCourseUrl"
+      @uploaded="uploadSuccess"
+    ></import-file-dialog>
   </section>
 </template>
 
 <script>
 import { QUESTION_API } from "@/constants/constants";
 import { mapState } from "vuex";
+import ImportFileDialog from "@/components/ImportFileDialog.vue";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
+  components: { ImportFileDialog },
   data() {
     return {
+      uploadCourseUrl: `${QUESTION_API}/courseProperty/import`,
+      courseTemplateUrl: `${QUESTION_API}/courseProperty/importTemplate`,
       courseProperty: {
         name: "",
         courseId: "",
@@ -303,6 +319,45 @@ export default {
     }, 200);
   },
   methods: {
+    // 导出
+    async exportCourseProperty() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/courseProperty/detail/export`,
+          {
+            params: { coursePropertyId: this.coursePropertyId },
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "导出失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("导出成功!");
+    },
+    impCourseProperty() {
+      this.$refs.ImportCourseDialog.open();
+    },
+    uploadSuccess(res) {
+      if (res.success) {
+        this.$notify({
+          message: "导入成功",
+          type: "success",
+        });
+        // this.searchCourProperty();
+        this.$refs.ImportCourseDialog.cancel();
+      } else {
+        this.$notify({
+          message: res.message,
+          type: "error",
+        });
+      }
+    },
     disAllBtn() {
       this.showButton = true;
       this.showSonButtton = true;

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

@@ -125,8 +125,8 @@
           effect="dark"
           style="margin-right: 5px; margin-bottom: 5px"
         >
-          {{ content.courseProperty && content.courseProperty.name }}
-          <span style="margin: 0 3px">/</span>
+          <!-- {{ content.courseProperty && content.courseProperty.name }}
+          <span style="margin: 0 3px">/</span> -->
           {{ content.firstProperty && content.firstProperty.name }}
           <span v-if="content.secondProperty" style="margin: 0 3px">/</span>
           {{ content.secondProperty && content.secondProperty.name }}