// 点击表格全选CheckBox
@select-all="handleSelectAll"
handleSelectAll(selection) {
if(selection.length == 0) {
// 取消全选
for(let item in this.tableData) {
item.rowFlag = false;
}
} else {
// 全选
for(let item in this.tableData) {
item.rowFlag = true;
}
}
}
// --------------------------------------------------------------------
// 点击表格CheckBox
@select="handleSelect"
handleSelect(selection, row) {
this.tableData.forEach((item, index) => {
// 比当前行index大的行选中
if(item.index > row.index) {
item.rowFlag = true;
this.$refs.tableRef.toggleRowSelection(item, true);
}
if(item.index == row.index) {
item.rowFlag = !item.rowFlag;
}
// 比当前行index小的行取消选中
if(item.index < row.index) {
item.rowFlag = false;
this.$refs.tableRef.toggleRowSelection(item, false);
}
})
}
// ------------------------------------------------------------------------
// 点击表格行
@row-click="handleRowClick"
handleRowClick(row) {
row.rowFlag = !row.rowFlag;
this.$refs.tableRef.toggleRowSelection(row, row.rowFlag);
this.handleSelect([], row);
}
对于多选表格,选中某一工序后,该工序及后续所有工序自动选择。
最新推荐文章于 2024-07-19 12:58:53 发布