| | |
| | | ref="multipleTable" |
| | | @select="selectTr" |
| | | @select-all="selectAll" |
| | | @selection-change="handleSelectionChange" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | > |
| | | <el-table-column type="selection" label="序号"> </el-table-column> |
| | |
| | | this.isAllSelect = !this.isAllSelect; |
| | | let data = this.tableData; |
| | | this.toggleSelect(data, this.isAllSelect, "all"); |
| | | // 自定义 |
| | | if (this.isAllSelect) { |
| | | val.forEach((i) => { |
| | | if (i.id !== undefined) { |
| | | this.deleteList.push(i.id); |
| | | } else { |
| | | i.children.forEach((c) => { |
| | | this.deleteList.push(c.id); |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | this.deleteList.splice(0, this.deleteList.length); |
| | | } |
| | | }, |
| | | //选择某行 |
| | | selectTr(selection, row) { |
| | |
| | | this.isAllSelect = row.isChecked; |
| | | this.toggleSelect(row, row.isChecked, "tr"); |
| | | }); |
| | | |
| | | if (row.isChecked === true) { |
| | | if (row.children !== undefined) { |
| | | row.children.forEach((i) => { |
| | | this.deleteList.push(i.id); |
| | | }); |
| | | } else { |
| | | this.deleteList.push(row.id); |
| | | } |
| | | } else if (row.isChecked === false) { |
| | | if (row.children !== undefined) { |
| | | row.children.forEach((i) => { |
| | | this.deleteList.findIndex((c, index) => { |
| | | if (c === i.id) { |
| | | this.deleteList.splice(index, 1); |
| | | return; |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | this.deleteList.findIndex((c, index) => { |
| | | if (c === row.id) { |
| | | this.deleteList.splice(index, 1); |
| | | return; |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | //递归子级 |
| | | toggleSelect(data, flag, type) { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | handleSelectionChange(val) { |
| | | this.deleteList = [] |
| | | val.forEach((v) => { |
| | | if(v.id !== undefined) { |
| | | this.deleteList.push(v.id) |
| | | } |
| | | }) |
| | | console.log(`output->this.deleteList`,this.deleteList) |
| | | }, |
| | | // 表格树全部选中配置 结束 |
| | | deleteListClick() { |
| | | deleteListApi(this.deleteList).then((res) => { |