luohairen
2024-11-14 458a16314b4ffee596490ba5c44878570287b21b
src/views/exam/exam/ExamManage.vue
@@ -103,7 +103,7 @@
            v-show="scope.row.status !== 'cancel'"
            style="margin: 0 5px"
            title="确定要删除该考试吗?"
            @confirm="deleteExam(scope.row.id)"
            @confirm="deleteExam(scope.row)"
          >
            <el-button
              slot="reference"
@@ -115,7 +115,7 @@
          </el-popconfirm>
          <el-button
            v-if="scope.row.status === 'finished'"
            v-if="scope.row.status !== 'not_start'"
            type="success"
            size="small"
            @click="markPaper(scope.row)"
@@ -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>