ny
22 小时以前 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script lang="ts">
import { computed, defineComponent } from 'vue';
 
import { $t } from '@vben/locales';
 
import { DoubleLeftOutlined } from '@ant-design/icons-vue';
import { Tooltip } from 'ant-design-vue';
 
import { useTableContext } from '../../hooks/useTableContext';
 
export default defineComponent({
  components: {
    DoubleLeftOutlined,
    Tooltip,
  },
  name: 'ExpandSetting',
  setup() {
    const table = useTableContext();
 
    const isExpanded = computed(() => {
      return table.getIsExpanded();
    });
 
    function expandAll() {
      table.expandAll();
    }
    function collapseAll() {
      table.collapseAll();
    }
 
    return { collapseAll, expandAll, isExpanded, t: $t };
  },
});
</script>
<template>
  <Tooltip placement="top">
    <template #title>
      <span>{{ isExpanded ? t('common.collapseAll') : t('common.expandAll') }}</span>
    </template>
    <DoubleLeftOutlined v-if="isExpanded" class="icon-collapse" @click="collapseAll" />
    <DoubleLeftOutlined v-else class="icon-expand" @click="expandAll" />
  </Tooltip>
</template>
<style lang="scss" scoped>
.icon-collapse {
  transform: rotate(90deg);
}
 
.icon-expand {
  transform: rotate(270deg);
}
</style>