|
@@ -37,6 +37,10 @@ export function useTableExpand(
|
|
|
expandedRowKeys.value = keys;
|
|
|
}
|
|
|
|
|
|
+ function collapseAll() {
|
|
|
+ expandedRowKeys.value = [];
|
|
|
+ }
|
|
|
+
|
|
|
function expandRows(keys: (string | number)[]) {
|
|
|
// use row ID expands the specified table row
|
|
|
const { isTreeTable } = unref(propsRef);
|
|
@@ -44,6 +48,13 @@ export function useTableExpand(
|
|
|
expandedRowKeys.value = [...expandedRowKeys.value, ...keys];
|
|
|
}
|
|
|
|
|
|
+ function collapseRows(keys: (string | number)[]) {
|
|
|
+ // use row ID collapses the specified table row
|
|
|
+ const { isTreeTable } = unref(propsRef);
|
|
|
+ if (!isTreeTable) return;
|
|
|
+ expandedRowKeys.value = unref(expandedRowKeys).filter((key) => !keys.includes(key));
|
|
|
+ }
|
|
|
+
|
|
|
function getAllKeys(data?: Recordable[]) {
|
|
|
const keys: string[] = [];
|
|
|
const { childrenColumnName } = unref(propsRef);
|
|
@@ -57,9 +68,5 @@ export function useTableExpand(
|
|
|
return keys;
|
|
|
}
|
|
|
|
|
|
- function collapseAll() {
|
|
|
- expandedRowKeys.value = [];
|
|
|
- }
|
|
|
-
|
|
|
- return { getExpandOption, expandAll, expandRows, collapseAll };
|
|
|
+ return { getExpandOption, expandAll, collapseAll, expandRows, collapseRows };
|
|
|
}
|