Browse Source

日志增加分页

chenjun 2 years ago
parent
commit
fe5f6e389c
1 changed files with 26 additions and 1 deletions
  1. 26 1
      src/views/systemSettings/views/log/index.vue

+ 26 - 1
src/views/systemSettings/views/log/index.vue

@@ -33,6 +33,7 @@
     </div>
     <div class="interfaceLog_content flex-wrap">
       <el-table
+        v-el-table-infinite-scroll="load"
         :data="tableData"
         class="table"
         border
@@ -104,12 +105,26 @@ export default {
       date: "",
       keyWords: null,
       preDatas: [],
+      page:0,
+      noMore:false
     };
   },
   created() {
     this.getNowTime();
   },
   methods: {
+    load() {
+      // console.log("分页");
+      if (this.noMore) {
+        return;
+      }
+      this.getQuery();
+    },
+    resetTable() {
+      this.page = 0;
+      this.noMore = false;
+      this.tableData = [];
+    },
     rowClick(row, column, event) {
       this.preDatas = [];
       if (row.logObject) {
@@ -124,6 +139,7 @@ export default {
     },
     dateChange() {
       if (this.date != null) {
+        this.resetTable();
         this.getQuery();
       }
     },
@@ -149,16 +165,25 @@ export default {
         this.loading = true;
         const { code, returnData } = await Query({
           id: 15,
+          needPage: ++this.page,
           dataContent: [this.date[0] + " 00:00:00", this.date[1] + " 23:59:59"],
         });
         if (code == 0) {
-          this.tableData = returnData.listValues;
+          if (returnData.listValues.length === 0) {
+            this.page--;
+            this.noMore = true;
+            return;
+          }
+          // this.tableData = returnData.listValues;
+          this.tableData.push(...returnData.listValues);
           console.log(returnData);
         } else {
+          this.page--
           this.loading = false;
           this.$message.error("获取数据失败");
         }
       } catch (error) {
+        this.page--
         this.loading = false;
         console.log(error);
       }