Browse Source

Merge branch 'master' of http://120.26.64.82:3000/BFFE/CABaggageData2.0

chenrui  2 years ago
parent
commit
763a5bed04
1 changed files with 25 additions and 3 deletions
  1. 25 3
      src/components/Table/index.vue

+ 25 - 3
src/components/Table/index.vue

@@ -352,6 +352,8 @@ export default {
       serviceId: null,
       rmFlag: false,
       rowTitle: "",
+      page: 0,
+      noMore: false,
       tableCols: [], //表头数据
       tableData: [], //表格数据
       tableColsCopy: [], //表头数据缓存
@@ -417,6 +419,7 @@ export default {
     dataContent: {
       handler(val) {
         if (val) {
+          this.resetTable();
           this.getQuery();
         }
       },
@@ -431,7 +434,16 @@ export default {
   },
   methods: {
     load() {
-      console.log("分页");
+      // console.log("分页");
+      if (this.noMore || this.loading) {
+        return;
+      }
+      this.getQuery();
+    },
+    resetTable() {
+      this.page = 0;
+      this.noMore = false;
+      this.tableData = [];
     },
     changeSelect(data) {
       if (this.tableForm[data] === "") {
@@ -452,16 +464,23 @@ export default {
         this.loading = true;
         const { code, returnData } = await Query({
           id: this.dataId,
+          needPage: ++this.page,
           dataContent: Object.values(this.dataContent),
         });
         if (code == 0) {
+          if (returnData.listValues.length === 0) {
+            this.page--;
+            this.noMore = true;
+            this.loading = false;
+            return;
+          }
           const titleColumn = returnData.columnSet.find(
             (item) => item.needShow === 1
           );
           if (titleColumn) {
             this.rowTitle = titleColumn.columnName;
           }
-          this.tableData = returnData.listValues;
+          this.tableData.push(...returnData.listValues);
           this.tableCols = returnData.columnSet;
           this.serviceId = returnData.submitID;
           setTimeout(() => {
@@ -469,10 +488,12 @@ export default {
             this.loading = false;
           }, 100);
         } else {
+          this.page--
           this.loading = false;
           this.$message.error("获取表格数据失败");
         }
       } catch (error) {
+        this.page--
         this.loading = false;
         console.log(error);
       }
@@ -490,6 +511,7 @@ export default {
         });
         if (code == 0) {
           this.$message.success("操作成功");
+          this.resetTable()
           this.getQuery();
           this.flag = false;
           this.rmFlag = false;
@@ -526,7 +548,7 @@ export default {
       // console.log(this.tableColsCopy)
       this.tableDataCopy = _.cloneDeep(this.tableData);
       const datas = _.cloneDeep(this.tableColsCopy);
-      const reqUts = [];
+      // const reqUts = [];
       datas.forEach(async (item) => {
         this.tableDataFilters[item.columnName] = [];
         if (item.needGroup) {