el-table滚动加载

复制代码
 <div class="bottom">
              <div class="title">优惠历史</div>
              <div style="overflow: auto; height: 220px">
                <el-table
                  v-el-table-infinite-scroll="load"
                  border
                  :data="historyData"
                  class="customer-no-border-table"
                  v-loading="historyLoading"
                  element-loading-text="数据正在加载中..."
                  :row-class-name="tableRowClassName"
                  :header-cell-style="{
                    background: '#E7F2FD',
                    color: '#252525',
                  }"
                  style="
                    width: 100%;
                    border-top: 1px solid #409eff;
                    margin-top: 0px;
                  "
                  height="220"
                >
                  <el-table-column
                    type="index"
                    label="序号"
                    width="50"
                    align="center"
                    header-align="center"
                  ></el-table-column>
                  <el-table-column
                    v-for="(item, index) in historyColumns"
                    :show-overflow-tooltip="item.prop == 'activityName'"
                    :width="item.width"
                    :key="index"
                    :prop="item.prop"
                    :label="item.label"
                    :formatter="item.formatter"
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    width="150"
                    align="center"
                    header-align="center"
                  >
                    <template #default="{ row }">
                      <span
                        v-for="(item, index) in listBtns2"
                        :key="index"
                        class="underline"
                        @click="getDetail(item.resourceRemark, row)"
                      >
                        {{ item.resourceName }}
                      </span>
                    </template>
                  </el-table-column>
                  <div slot="empty">
                    <img
                      src="@/assets/nodata.png"
                      style="width: 150px; height: 105px"
                    />
                    <div
                      style="
                        font-size: 16px;
                        color: #666666;
                        height: 20px;
                        line-height: 20px;
                      "
                    >
                      暂无数据
                    </div>
                  </div>
                </el-table>
              </div>
            </div>
          </div>
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 请求优惠历史数据
  getHistory() {
    this.historyLoading = true;
    postToken(selectCompanyActivityHistory, {
      companyCode: this.trData.companyCode,
      buildId: this.buildRow.id,
      page: this.historyPage.page,
    }).then((res) => {
      if (res.data.status == 1) {
        let result = res.data;
        this.historyData = this.historyData.concat(result.rows);
        this.historyPage.total = result.total;
        console.log(this.historyData, result.rows, "优惠历史");
      } else {
        this.$message.error(res.data.msg);
      }
      this.historyLoading = false;
    });
  },

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
load() {
    console.log("表格scroll", this.historyPage.page, this.historyPage.total);
    if (this.historyPage.total > 0) {
      this.historyPage.page++;
      let totalPage = Math.ceil(
        this.historyPage.total / this.historyPage.size
      );
      console.log(this.historyPage.page, totalPage, "表格滚动");
      if (this.historyPage.page > totalPage) {
        return;
      } else {
        this.getHistory();
      }
    }
  },

  

posted @   崛起崛起  阅读(273)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示