소스 검색

回评限制的分页bug修复

刘洋 1 년 전
부모
커밋
37b98f6a00
1개의 변경된 파일18개의 추가작업 그리고 18개의 파일을 삭제
  1. 18 18
      src/features/mark/MarkHistory.vue

+ 18 - 18
src/features/mark/MarkHistory.vue

@@ -158,13 +158,10 @@ const remarkCount = computed(() => {
   return store.setting?.remarkCount;
 });
 const limitPageSize = computed(() => {
-  return typeof remarkCount.value == "number"
-    ? remarkCount.value <= 20
-      ? remarkCount.value
-      : currentPage * 20 > remarkCount.value
-      ? remarkCount.value % 20
-      : 20
-    : 20;
+  // return typeof remarkCount.value == "number"
+  //     ? remarkCount.value
+  //     : 20
+  return 20;
 });
 const hasLimit = computed(() => {
   console.log("remarkCount.value:", remarkCount.value);
@@ -280,6 +277,13 @@ EventBus.on("should-reload-history", () => {
       if (res?.data) {
         // let data = cloneDeep(res.data);
         let data = remarkCount.value === 0 ? [] : cloneDeep(res.data);
+        if (
+          typeof remarkCount.value == "number" &&
+          remarkCount.value > 0 &&
+          (currentPage - 1) * 20 + data.length > remarkCount.value
+        ) {
+          data = data.slice(0, remarkCount.value % 20);
+        }
         data = data.map(addFileServerPrefixToTask);
         if (store.currentTask) {
           // 这种方式(对象被重新构造了)能查找到index,我也很惊讶
@@ -325,22 +329,18 @@ async function updateHistoryTask({
   };
   let key = searchType == "1" ? "secretNumber" : "markerScore";
   params[key] = secretNumber;
-  // const res = await getHistory({
-  //   pageNumber,
-  //   pageSize,
-  //   order,
-  //   sort,
-  //   secretNumber,
-  //   subjectCode,
-  //   groupNumber,
-  //   markerId,
-  //   markerScore,
-  // });
   const res = await getHistory(params);
   loading = false;
   if (res?.data) {
     // let data = cloneDeep(res.data);
     let data = remarkCount.value === 0 ? [] : cloneDeep(res.data);
+    if (
+      typeof remarkCount.value == "number" &&
+      remarkCount.value > 0 &&
+      (currentPage - 1) * 20 + data.length > remarkCount.value
+    ) {
+      data = data.slice(0, remarkCount.value % 20);
+    }
     data = data.map(addFileServerPrefixToTask);
     store.historyTasks = data;
     replaceCurrentTask(store.historyTasks[0]).catch((err) => {