el-table多选时翻页数据存储以及多选数据条数限制
多选时翻页数据存储
<el-table :data="tableData" @selection-change="handleSelectionChange" height="480" style="width: 100%;height: 100%;border: 2px solid rgba(0, 125, 252, 0.27);padding-bottom: 10px" :row-key="rowKey" ref="fileTable">
<el-table-column type="selection" width="55" :reserve-selection="true" :selectable="selectAble"></el-table-column>
</el-table>
rowKey(row) {
return row.id
},
多选数据条数限制
<el-table :data="tableData" @selection-change="handleSelectionChange" height="480" style="width: 100%;height: 100%;border: 2px solid rgba(0, 125, 252, 0.27);padding-bottom: 10px" :row-key="rowKey" ref="fileTable">
<el-table-column type="selection" width="55" :reserve-selection="true" :selectable="selectAble"></el-table-column>
</el-table>
selectAble(row) {
if (row.status === 1) {
return true;
}
return false;
},
handleSelectionChange(val) {
this.multipleSelection = val;
if (this.multipleSelection.length >= this.checkNum) {
this.$message.warning(`最多只能选${this.checkNum}条数据`);
for (let j of this.tableData) {
j.status = 0;
for (let i of this.multipleSelection) {
if (i.id == j.id) {
j.status = 1;
}
}
}
return
} else {
for (let i in this.tableData) {
this.tableData[i].status = 1;
}
}
},