ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { VxeGridInstance } from 'vxe-table';
 
import type { ComputedRef, Ref } from 'vue';
 
import type { BasicTableProps } from '../types/table';
 
import { ref, unref } from 'vue';
 
export function useTableExpand(propsRef: ComputedRef<BasicTableProps>, tableElRef: Ref<undefined | VxeGridInstance>) {
  const isExpanded = ref<boolean>(false);
 
  function getIsExpanded() {
    return isExpanded.value;
  }
  function expandAll() {
    isExpanded.value = true;
    unref(tableElRef)?.setAllTreeExpand(true);
  }
 
  function collapseAll() {
    isExpanded.value = false;
    unref(tableElRef)?.clearTreeExpand();
  }
 
  return { collapseAll, expandAll, getIsExpanded };
}