luohairen
2024-11-04 4a7c02f5f20097e6566471c7c664aa91380e6cd8
安排考试防抖
1个文件已修改
20 ■■■■■ 已修改文件
src/views/exam/exam/ExamManage.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/exam/ExamManage.vue
@@ -264,7 +264,7 @@
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeHandler">取 消</el-button>
        <el-button type="primary" @click="addOrEditExam">确 定</el-button>
        <el-button type="primary" @click="handleDebouncedClick">确 定</el-button>
      </div>
    </el-dialog>
  </div>
@@ -302,6 +302,8 @@
        endTime: null,
        time: []
      },
      // 声明一个定时器
      debounceTimeout: null,
      selectExamPaper: {},
      examRules: {
        examName: [
@@ -339,6 +341,7 @@
    this.page()
    this.getMyClasses()
    this.MyExamPaperList()
    this.handleDebouncedClick = this.debounce(this.addOrEditExam, 500); // 500ms的防抖时间
  },
  methods: {
    // 作废考试
@@ -477,7 +480,20 @@
    },
    handleExamPaperSelect (e) {
      this.selectExamPaper = this.examPaperList.find((o) => o.id === e)
    }
    },
    // 防抖函数
    debounce(func, wait) {
      return (...args) => {
        if (this.debounceTimeout) {
          clearTimeout(this.debounceTimeout);
        }
        this.debounceTimeout = setTimeout(() => {
          func.apply(this, args);
        }, wait);
      };
    },
    // 防抖处理的点击事件
    handleDebouncedClick: null,
  }
}
</script>