zhangjie 1 年之前
父节点
当前提交
d3333c1345

+ 13 - 8
src/modules/paper/components/ModifyDetailStruct.vue

@@ -56,6 +56,7 @@
 
 <script>
 import { randomCode } from "@/plugins/utils";
+import { debounce } from "lodash";
 
 const initModalForm = {
   id: null,
@@ -119,15 +120,19 @@ export default {
     open() {
       this.modalIsShow = true;
     },
-    async confirm() {
-      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
-      if (!valid) return;
+    confirm: debounce(
+      async function () {
+        const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+        if (!valid) return;
 
-      let data = { ...this.modalForm };
-      if (!data.id) data.id = randomCode();
-      this.$emit("modified", data);
-      this.cancel();
-    },
+        let data = { ...this.modalForm };
+        if (!data.id) data.id = randomCode();
+        this.$emit("modified", data);
+        this.cancel();
+      },
+      1000,
+      { leading: true, trailing: false }
+    ),
   },
 };
 </script>

+ 17 - 12
src/modules/paper/components/SelectQuestionDialog.vue

@@ -245,6 +245,7 @@ import QuestionPreviewDialog from "../../question/components/QuestionPreviewDial
 import PropertyTreeSelect from "../../question/components/PropertyTreeSelect.vue";
 import { questionPageListApi } from "../../question/api";
 import { deepCopy } from "@/plugins/utils";
+import { debounce } from "lodash";
 
 export default {
   name: "SelectQuestionDialog",
@@ -393,18 +394,22 @@ export default {
         (item) => item.id
       );
     },
-    confirm() {
-      // if (this.IS_PAPER_MODE) {
-      //   const unvalid = this.curSelectedQuestions.some((item) => !item.score);
-      //   if (unvalid) {
-      //     this.$message.error("请完成已选试题分值设置");
-      //     this.tabType = "2";
-      //     return;
-      //   }
-      // }
-      this.$emit("confirm", deepCopy(this.curSelectedQuestions));
-      this.cancel();
-    },
+    confirm: debounce(
+      function () {
+        // if (this.IS_PAPER_MODE) {
+        //   const unvalid = this.curSelectedQuestions.some((item) => !item.score);
+        //   if (unvalid) {
+        //     this.$message.error("请完成已选试题分值设置");
+        //     this.tabType = "2";
+        //     return;
+        //   }
+        // }
+        this.$emit("confirm", deepCopy(this.curSelectedQuestions));
+        this.cancel();
+      },
+      1000,
+      { leading: true, trailing: false }
+    ),
   },
 };
 </script>

+ 8 - 7
src/modules/question/components/GptQuestionDialog.vue

@@ -127,6 +127,7 @@
 
         <el-table
           v-loading="loading"
+          ref="table"
           element-loading-text="加载中"
           :data="questionList"
           @selection-change="tableSelectChange"
@@ -180,7 +181,7 @@
             :page-sizes="[10, 20, 50, 100, 200, 300]"
             layout="total, sizes, prev, pager, next, jumper"
             :total="total"
-            @current-change="toPage"
+            @current-change="handleCurrentChange"
             @size-change="handleSizeChange"
           >
           </el-pagination>
@@ -304,13 +305,13 @@ export default {
       if (res.data.status === "FAILED") {
         this.hasTaskRunning = false;
         if (!isReview) this.$message.error("出题失败,请重新尝试!");
-        this.toPage(1);
+        this.handleCurrentChange(1);
         return;
       }
       if (res.data.status === "FINISH") {
         this.hasTaskRunning = false;
         if (!isReview) this.$message.success("出题成功!");
-        this.toPage(1);
+        this.handleCurrentChange(1);
         return;
       }
       this.hasTaskRunning = ["RUNNING", "INIT"].includes(res.data.status);
@@ -335,7 +336,7 @@ export default {
         this.checkTaskStatus();
       }, 3 * 1000);
     },
-    toPage(page) {
+    handleCurrentChange(page) {
       this.currentPage = page;
       this.getList();
     },
@@ -354,7 +355,7 @@ export default {
     },
     handleSizeChange(val) {
       this.pageSize = val;
-      this.toPage(1);
+      this.handleCurrentChange(1);
     },
     tableSelectChange(selections) {
       this.selectedQuestionIds = selections.map((item) => item.id);
@@ -415,7 +416,7 @@ export default {
         message: "删除成功",
         type: "success",
       });
-      this.getList();
+      this.deletePageLastItem(ids.length);
     },
     async toSaveQuestion() {
       if (this.loading) return;
@@ -440,7 +441,7 @@ export default {
       this.loading = false;
       if (!res) return;
       this.$message.success("保存成功!");
-      this.getList();
+      this.deletePageLastItem(this.selectedQuestionIds.length);
       this.$emit("modified");
     },
   },