feat:scTable添加expend展开收起功能

This commit is contained in:
shijing 2025-11-13 13:47:58 +08:00
parent dce60da8f2
commit 6d5bca7978
1 changed files with 19 additions and 1 deletions

View File

@ -12,7 +12,7 @@
<div class="scTable-table" :style="{ height: _table_height }">
<el-table v-bind="$attrs" :data="tableData" :row-key="rowKey" :key="toggleIndex" ref="scTable"
:height="height == 'auto' ? null : '100%'" :size="config.size" :border="config.border" :stripe="config.stripe"
:summary-method="remoteSummary ? remoteSummaryMethod : summaryMethod" @sort-change="sortChange"
:summary-method="remoteSummary ? remoteSummaryMethod : summaryMethod" :expand-row-keys="expandRowKeys" @sort-change="sortChange"
@filter-change="filterChange" @selection-change="selectionChange">
<slot></slot>
<template v-for="(item, index) in userColumn" :key="index">
@ -97,6 +97,7 @@ export default {
columnSetting,
},
props: {
expendShow:{ type: Boolean, default: false },
tableName: { type: String, default: "" },
apiObj: { type: Object, default: () => { } },
params: { type: Object, default: () => ({}) },
@ -134,6 +135,9 @@ export default {
this.tableData = this.data;
this.total = this.tableData.length;
},
expendShow(){
this.toggleExpandAll();
},
apiObj() {
this.tableParams = this.params;
this.refresh();
@ -161,6 +165,7 @@ export default {
emptyText: "暂无数据",
toggleIndex: 0,
tableData: [],
expandRowKeys:[],
total: 0,
currentPage: 1,
prop: null,
@ -518,6 +523,19 @@ export default {
sort(prop, order) {
this.$refs.scTable.sort(prop, order);
},
// /
toggleExpandAll() {
const isExpandAll = this.expandRowKeys.length === this.$refs.scTable.data.length;
if (isExpandAll) {
this.expandRowKeys = []; //
} else {
this.expandRowKeys = this.$refs.scTable.data.map(item => item.id); //
}
},
// expandRowKeys
handleExpandChange(row, expandedRows) {
this.expandRowKeys = expandedRows.map(row => row.is); //
}
},
};
</script>