From f504cee74b18269461928e3fe8315461af2cc838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Mon, 11 Nov 2024 13:43:09 +0800 Subject: [PATCH] 1 --- .../container/newTask/taskTypeView.vue | 55 ++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue index e68b0a4..20025f8 100644 --- a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue +++ b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue @@ -442,7 +442,7 @@ const handleQueryParamFromEntpCourseWork = (queryType) => { * 1 - 按条件查询 * 2 - 按关键词查询 */ -const handleQueryFromEntpCourseWork= async (queryType) => { +const handleQueryFromEntpCourseWork= async (queryType, value) => { pageParams.value.loading = true; const queryForm = { @@ -476,6 +476,20 @@ const handleQueryFromEntpCourseWork= async (queryType) => { // } const entpcourseworkres = await listEntpcourseworkNew(queryForm); + + // 当前有更改, 则重新开始流程查询 + if (nextLevelSecondId != -1) { + console.log('再次执行') + nextLevelSecondId = -1; + const debouncedFunction = debounceQueryData(10); + debouncedFunction(); + return; + } + + // 当前为第一页时, 再次重置避免 + if (paginationParams.pageNum == 1) { + initPageParams(); + } const data = entpcourseworkres.data; if(data && data.length>0){ // workResource.entpCourseWorkList = entpcourseworkres.data; @@ -486,9 +500,12 @@ const handleQueryFromEntpCourseWork= async (queryType) => { item.worktype = '单选题' } }) + // 格式化试题信息 processList(data); + + workResource.entpCourseWorkList.push(...data); // 初次加载时更新当前试题数量 @@ -956,17 +973,21 @@ onMounted(async() => { }) -const debounceQueryData = debounce(() => { - console.log("防抖 加载数据中...") - // 初始化滚动加载参数 - initPageParams(); - // 习题资源 - handleQueryFromEntpCourseWork(0); - // 框架梳理 - getQueryFromEvaluationclue(); - // 知识点 - getEntpCourseWorkPointList(); -}, 1000); +let nextLevelSecondId = -1; +const debounceQueryData = (wait) => { + const debouncedFunction = debounce(() => { + console.log("防抖 加载数据中...") + // 初始化滚动加载参数 + initPageParams(); + // 习题资源 + handleQueryFromEntpCourseWork(0); + // 框架梳理 + getQueryFromEvaluationclue(); + // 知识点 + getEntpCourseWorkPointList(); + }, wait); + return debouncedFunction; +} watch(() => props.propsformobj.uniquekey, (newVal) => { @@ -977,7 +998,15 @@ watch(() => props.propsformobj.uniquekey, (newVal) => { }) watch(() => props.bookobj.levelSecondId, (newVal, oldVal) => { console.log(props.bookobj,'课程选择') - debounceQueryData(); + console.log('更改章节id->', newVal); + //nextLevelSecondId = newVal; + if (pageParams.value.loading) { + console.log('更改章节id->', newVal); + nextLevelSecondId = newVal; + return; + } + const debouncedFunction = debounceQueryData(1000); + debouncedFunction(); })