From 4a7c02f5f20097e6566471c7c664aa91380e6cd8 Mon Sep 17 00:00:00 2001 From: luohairen <3399054449@qq.com> Date: 星期一, 04 十一月 2024 10:47:04 +0800 Subject: [PATCH] 安排考试防抖 --- src/views/exam/exam/ExamManage.vue | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/views/exam/exam/ExamManage.vue b/src/views/exam/exam/ExamManage.vue index 47e073c..d2f1ae2 100644 --- a/src/views/exam/exam/ExamManage.vue +++ b/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> -- Gitblit v1.8.0