elementUI跨页多选行实现

134 阅读1分钟

image.png 使用这个属性可以在分页切换后保留选中内容

<!-- 出库统计报表 -->
<template>
  <div class="app-container">
    <div class="formClass" style="border-bottom: 2px solid #e7eaec">
    <div>
    <!-- <el-table ref="multipleTable" @selection-change="handleSelectionChange" row-key="id" :data="tableData" 这里不能使用slection-change
        style="width: 100%" -->
        <el-table ref="multipleTable" @select="handleSelectionChange" row-key="id" :data="tableData"
        style="width: 100%">
        <el-table-column type="selection" width="55" :reserve-selection="true">
        </el-table-column>
      </el-table>
    </div>

  </div>
</template>

<script>
import {
  outWarehouseReport,
} from '@/api/purchase'
export default {
  name: "",
  data() {
    return {
      tableData: [],
      total: 3,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleSelectionChange(selection, row) {
      console.log(selection, row);
      
    },
    getList() {
      outWarehouseReport().then((res) => {
        if (res.code == 200) {
          this.tableData = res.rows
          this.total = res.total
        }
      })
    },
  },
};
</script>