Quellcode durchsuchen

feat: 试题预览流水

zhangjie vor 7 Monaten
Ursprung
Commit
119cd63671

+ 72 - 46
src/assets/styles/pages.scss

@@ -142,19 +142,18 @@
 // paper-structure-info
 .topic-set {
   text-align: center;
-  border: 1px solid #FFCF8B;
-  color: #FF7D00;
+  border: 1px solid #ffcf8b;
+  color: #ff7d00;
   border-radius: 6px;
-  background-color: #FFF7E8;
+  background-color: #fff7e8;
   overflow: hidden;
-  font-size:14px;
-  height:62px;
+  font-size: 14px;
+  height: 62px;
   &-title {
     height: 30px;
     line-height: 34px;
   }
   &-content {
-
     .el-input__inner {
       border: none;
       text-align: center;
@@ -263,7 +262,7 @@
     }
     &.is-danger {
       // box-shadow: 0px 0 10px inset #ffa280;
-      box-shadow: inset 0px 0px 10px 0px #F76560;
+      box-shadow: inset 0px 0px 10px 0px #f76560;
     }
   }
   .edit-property {
@@ -279,39 +278,39 @@
       display: inline-block;
       vertical-align: top;
       width: 78px;
-      height:62px;
-      margin-right:10px;
+      height: 62px;
+      margin-right: 10px;
       padding: 0;
       font-size: 14px;
-      &:nth-child(4n){
-        margin-right:0;
+      &:nth-child(4n) {
+        margin-right: 0;
       }
-      margin-bottom:10px;
+      margin-bottom: 10px;
     }
 
     &-body {
-      width:100%;
-      height:100%;
+      width: 100%;
+      height: 100%;
       text-align: center;
       color: #393c4c;
       border-radius: 8px;
       // background-color: #73c7ff;
       line-height: 24px;
       overflow: hidden;
-      &.level1,&.level2{
-        background-color: #FFF7E8;
-        color:#FF7D00;
-      border: 1px solid #FFCF8B;
-
+      &.level1,
+      &.level2 {
+        background-color: #fff7e8;
+        color: #ff7d00;
+        border: 1px solid #ffcf8b;
       }
-      &.level2{
-        background-color: #E8F3FF;
-        color:#165DFF;
-        border: 1px solid #6AA1FF;
+      &.level2 {
+        background-color: #e8f3ff;
+        color: #165dff;
+        border: 1px solid #6aa1ff;
       }
     }
     &-title {
-      line-height:30px;
+      line-height: 30px;
       // color: #fff;
       // border-bottom: 1px solid #6e7590;
     }
@@ -873,7 +872,9 @@
 }
 
 // question-edit-dialog
-.question-edit-dialog,.question-identify-dialog,.gpt-question-dialog {
+.question-edit-dialog,
+.question-identify-dialog,
+.gpt-question-dialog {
   .el-dialog__header {
     h2 {
       display: inline-block;
@@ -1066,13 +1067,13 @@
     border-radius: 5px;
     // background-color: $--color-background;
     margin-right: 10px;
-    border:1px solid #eee;
+    border: 1px solid #eee;
 
     .el-tree {
       // background-color: $--color-background;
-      .el-tree-node__content{
-        &:hover{
-          background:#f0f0f0;
+      .el-tree-node__content {
+        &:hover {
+          background: #f0f0f0;
         }
       }
     }
@@ -1160,16 +1161,16 @@
     padding: 15px 12px;
     background-color: #fff;
     border-radius: 10px;
-    transition:all .2s;
-    overflow:auto;
-    &.collapse{
-      width:0;
-      overflow:hidden;
-      padding:0;
-      margin-right:0;
+    transition: all 0.2s;
+    overflow: auto;
+    &.collapse {
+      width: 0;
+      overflow: hidden;
+      padding: 0;
+      margin-right: 0;
     }
-    .el-tree-node > .el-tree-node__children{
-      overflow:visible;
+    .el-tree-node > .el-tree-node__children {
+      overflow: visible;
     }
   }
   .question-list {
@@ -1179,11 +1180,11 @@
     border-radius: 10px;
     overflow-x: hidden;
     overflow-y: auto;
-    &>.el-table{
-      .cell{
-        .rich-text{
-          width:100%;
-          &>div{
+    & > .el-table {
+      .cell {
+        .rich-text {
+          width: 100%;
+          & > div {
             overflow: hidden;
             white-space: nowrap;
             text-overflow: ellipsis;
@@ -1238,8 +1239,33 @@
 
 // question-preview-dialog
 .question-preview-dialog {
+  &.el-dialog {
+    width: 1000px;
+    height: 100%;
+    overflow: hidden;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    margin-bottom: 0;
+  }
+  .el-dialog__header,
+  .el-dialog__footer {
+    flex-grow: 0;
+    flex-shrink: 0;
+  }
+  .el-dialog__header {
+    border-bottom: 1px solid #f0f0f0;
+    padding: 15px;
+  }
+  .el-dialog__footer {
+    border-top: 1px solid #f0f0f0;
+    padding: 15px;
+  }
   .el-dialog__body {
     padding: 0;
+    flex-grow: 2;
+    overflow-x: hidden;
+    overflow-y: auto;
   }
   .edit-part {
     margin-bottom: 15px;
@@ -1249,9 +1275,9 @@
     }
   }
 }
-.synthesis-paper-storage-dialog{
-  width:100vw;
-  margin-top:0 !important;
+.synthesis-paper-storage-dialog {
+  width: 100vw;
+  margin-top: 0 !important;
   .el-dialog__body {
     height: 100vh;
     overflow: auto;

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

@@ -235,7 +235,7 @@
 
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :data="curQuestion"
     ></question-preview-dialog>
   </el-dialog>
 </template>

+ 1 - 1
src/modules/question/components/AuditQuestionApply.vue

@@ -80,7 +80,7 @@
     <!-- QuestionPreviewDialog -->
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :data="curQuestion"
     ></question-preview-dialog>
   </div>
 </template>

+ 1 - 1
src/modules/question/components/AuditQuestionAudited.vue

@@ -73,7 +73,7 @@
     <!-- QuestionPreviewDialog -->
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :data="curQuestion"
     ></question-preview-dialog>
   </div>
 </template>

+ 1 - 1
src/modules/question/components/AuditQuestionUnsubmit.vue

@@ -82,7 +82,7 @@
     <!-- QuestionPreviewDialog -->
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :data="curQuestion"
     ></question-preview-dialog>
   </div>
 </template>

+ 1 - 1
src/modules/question/components/FolderQuestionManageDialog.vue

@@ -180,7 +180,7 @@
     <!-- QuestionPreviewDialog -->
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :data="curQuestion"
     ></question-preview-dialog>
     <!-- QuestionFolderDialog -->
     <question-folder-dialog

+ 115 - 9
src/modules/question/components/QuestionPreviewDialog.vue

@@ -3,13 +3,13 @@
     custom-class="question-preview-dialog edit-paper"
     :visible.sync="modalIsShow"
     title="试题预览"
-    width="1000px"
-    top="20px"
+    top="0"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
     append-to-body
+    @open="openHandle"
   >
-    <div v-if="modalIsShow" class="edit-part">
+    <div class="edit-part" :key="question.id">
       <div class="edit-cont">
         <div class="edit-cont-title">
           <rich-text :text-json="question.quesBody"></rich-text>
@@ -110,8 +110,18 @@
       </div>
     </div>
 
-    <div slot="footer">
-      <el-button @click="cancel">关闭</el-button>
+    <div class="box-justify" slot="footer">
+      <div>
+        <template v-if="showSwitch">
+          <el-button :disabled="loading" size="mini" @click="toPrev"
+            >上一题</el-button
+          >
+          <el-button :disabled="loading" size="mini" @click="toNext"
+            >下一题</el-button
+          >
+        </template>
+      </div>
+      <el-button size="mini" @click="cancel">关闭</el-button>
     </div>
   </el-dialog>
 </template>
@@ -123,19 +133,48 @@ export default {
   name: "QuestionPreviewDialog",
   components: { QuestionAnswer },
   props: {
-    question: {
+    data: {
+      type: Object,
+      default: null,
+    },
+    showSwitch: {
+      type: Boolean,
+      default: false,
+    },
+    listInfo: {
       type: Object,
-      default() {
-        return {};
-      },
+      default: null,
+      // {dataList,curIndex,pageNumber,totalPages}
+    },
+    fetchPage: {
+      type: Function,
+      default: null,
     },
   },
   data() {
     return {
       modalIsShow: false,
+      question: {},
+      curIndex: 0,
+      loading: false,
     };
   },
+  watch: {
+    data(val) {
+      this.question = val;
+    },
+  },
   methods: {
+    openHandle() {
+      if (this.data) {
+        this.question = this.data;
+        return;
+      }
+
+      if (!this.listInfo) return;
+      this.curIndex = this.listInfo.curIndex;
+      this.selectQuestion();
+    },
     cancel() {
       this.modalIsShow = false;
     },
@@ -157,6 +196,73 @@ export default {
       const typeQuestion = ["PARAGRAPH_MATCHING", "BANKED_CLOZE"];
       return typeQuestion.includes(questionType);
     },
+    toPrev() {
+      if (this.listInfo && this.fetchPage) {
+        this.prevQuestion();
+        return;
+      }
+
+      this.$emit("on-prev");
+    },
+    toNext() {
+      if (this.listInfo && this.fetchPage) {
+        this.nextQuestion();
+        return;
+      }
+
+      this.$emit("on-next");
+    },
+    // question view
+    selectQuestion() {
+      this.question = this.listInfo.dataList[this.curIndex];
+    },
+    async prevQuestion() {
+      const { pageNumber } = this.listInfo;
+      if (this.curIndex <= 0) {
+        if (pageNumber <= 1) {
+          this.$message.error("已经是第一道试题!");
+          return;
+        }
+        this.loading = true;
+        let result = true;
+        await this.fetchPage(pageNumber - 1).catch(() => {
+          result = false;
+        });
+        this.loading = false;
+        if (!result) return;
+        this.$nextTick(() => {
+          this.curIndex = this.listInfo.dataList.length - 1;
+          this.selectQuestion();
+        });
+      } else {
+        this.curIndex--;
+        this.selectQuestion();
+      }
+    },
+    async nextQuestion() {
+      const { pageNumber, totalPages, dataList } = this.listInfo;
+      if (this.curIndex >= dataList.length - 1) {
+        if (pageNumber >= totalPages) {
+          this.$message.error("已经是最后一道试题!");
+          return;
+        }
+        this.loading = true;
+        let result = true;
+        await this.fetchPage(pageNumber + 1).catch(() => {
+          result = false;
+        });
+        this.loading = false;
+        if (!result) return;
+
+        this.$nextTick(() => {
+          this.curIndex = 0;
+          this.selectQuestion();
+        });
+      } else {
+        this.curIndex++;
+        this.selectQuestion();
+      }
+    },
   },
 };
 </script>

+ 20 - 4
src/modules/question/views/QuestionManage.vue

@@ -308,7 +308,9 @@
     <!-- QuestionPreviewDialog -->
     <question-preview-dialog
       ref="QuestionPreviewDialog"
-      :question="curQuestion"
+      :list-info="listInfo"
+      :fetchPage="toPage"
+      show-switch
     ></question-preview-dialog>
     <!-- QuestionStatisticsDialog -->
     <question-statistics-dialog
@@ -415,10 +417,12 @@ export default {
       curFolderAction: "",
       folderList: [],
       questionList: [],
+      curQuestionIndex: 0,
       selectedQuestionIds: [],
       currentPage: 1,
       pageSize: 10,
       total: 0,
+      totalPages: 0,
       loading: false,
       curQuestion: {},
       curFolder: {},
@@ -431,10 +435,18 @@ export default {
     };
   },
   computed: {
+    ...mapGetters(["authButtons"]),
     user() {
       return this.$store.state.user;
     },
-    ...mapGetters(["authButtons"]),
+    listInfo() {
+      return {
+        dataList: this.questionList,
+        curIndex: this.curQuestionIndex,
+        pageNumber: this.currentPage,
+        totalPages: this.totalPages,
+      };
+    },
   },
   mounted() {
     this.$refs.QuestionFolder.selectDefaultNode();
@@ -481,9 +493,9 @@ export default {
         this.aiWarningMsg = "未开通AI命题功能,请联系教务处老师进行开通";
       }
     },
-    toPage(page) {
+    async toPage(page) {
       this.currentPage = page;
-      this.getList();
+      await this.getList();
     },
     async getList() {
       this.loading = true;
@@ -502,6 +514,7 @@ export default {
       if (!res) return;
       this.questionList = res.data.content;
       this.total = res.data.totalElements;
+      this.totalPages = res.data.totalPages;
     },
     handleSizeChange(val) {
       this.pageSize = val;
@@ -567,6 +580,9 @@ export default {
     },
     toViewQuestion(row) {
       this.curQuestion = row;
+      this.curQuestionIndex = this.questionList.findIndex(
+        (q) => q.id === row.id
+      );
       this.$refs.QuestionPreviewDialog.open();
     },
     toEditQuestion(row) {

+ 7 - 6
src/modules/questions/views/CheckDuplicateList.vue

@@ -97,12 +97,13 @@
         </el-table-column>
         <el-table-column label="题干" min-width="240">
           <template slot-scope="scope">
-            <rich-text
-              class="row-question-body"
-              title="点击查看试题"
-              :text-json="scope.row.quesBody"
-              @click="prevViewQues(scope.row)"
-            ></rich-text>
+            <div @click="prevViewQues(scope.row)">
+              <rich-text
+                class="row-question-body"
+                title="点击查看试题"
+                :text-json="scope.row.quesBody"
+              ></rich-text>
+            </div>
           </template>
         </el-table-column>
         <!-- <el-table-column label="题型大类" width="100">

+ 7 - 6
src/modules/questions/views/Question.vue

@@ -153,12 +153,13 @@
         </el-table-column>
         <el-table-column label="题干">
           <template slot-scope="scope">
-            <rich-text
-              class="row-question-body"
-              title="点击查看试题"
-              :text-json="scope.row.quesBody"
-              @click="prevViewQues(scope.row)"
-            ></rich-text>
+            <div @click="prevViewQues(scope.row)">
+              <rich-text
+                class="row-question-body"
+                title="点击查看试题"
+                :text-json="scope.row.quesBody"
+              ></rich-text>
+            </div>
           </template>
         </el-table-column>
         <el-table-column label="操作" width="160">

+ 2 - 6
src/modules/questions/views/SelectQuestion.vue

@@ -125,12 +125,8 @@
         </el-table-column>
         <el-table-column label="题干">
           <template slot-scope="scope">
-            <span class="small">
-              <rich-text
-                :text-json="scope.row.quesBody"
-                @click="prevViewQues(scope.row)"
-              >
-              </rich-text>
+            <span class="small" @click="prevViewQues(scope.row)">
+              <rich-text :text-json="scope.row.quesBody"> </rich-text>
             </span>
           </template>
         </el-table-column>