Fix handover expand toggle

This commit is contained in:
caoqianming 2026-07-28 15:39:54 +08:00
parent ac3dc576c2
commit e990c4e150
1 changed files with 7 additions and 4 deletions

View File

@ -13,7 +13,7 @@
<el-table v-bind="$attrs" :data="tableData" :row-key="rowKey || undefined" :key="toggleIndex" ref="scTable"
:height="height == 'auto' ? null : '100%'" :size="config.size" :border="config.border" :stripe="config.stripe"
:summary-method="remoteSummary ? remoteSummaryMethod : summaryMethod" :expand-row-keys="rowKey ? expandRowKeys : undefined" @sort-change="sortChange"
@filter-change="filterChange" @selection-change="selectionChange">
@filter-change="filterChange" @selection-change="selectionChange" @expand-change="handleExpandChange">
<slot></slot>
<template v-for="(item, index) in userColumn" :key="index">
<el-table-column v-if="!item.hide" :column-key="item.prop" :label="item.label" :prop="item.prop"
@ -562,16 +562,19 @@ export default {
},
// /
toggleExpandAll() {
const isExpandAll = this.expandRowKeys.length === this.$refs.scTable.data.length;
const rows = this.tableData || [];
const key = this.rowKey || "id";
const isExpandAll = rows.length > 0 && rows.every(item => this.expandRowKeys.includes(item[key]));
if (isExpandAll) {
this.expandRowKeys = []; //
} else {
this.expandRowKeys = this.$refs.scTable.data.map(item => item.id); //
this.expandRowKeys = rows.map(item => item[key]); //
}
},
// expandRowKeys
handleExpandChange(row, expandedRows) {
this.expandRowKeys = expandedRows.map(row => row.is); //
const key = this.rowKey || "id";
this.expandRowKeys = expandedRows.map(item => item[key]); //
}
},
};