treeList.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import treeList from "./tree.json";
  4. import { VxeTableBar } from "@/components/ReVxeTableBar";
  5. const vxeTableRef = ref();
  6. const loading = ref(true);
  7. const tableData = ref([]);
  8. const columns = [
  9. { type: "seq", field: "seq", title: "序号", width: 200, treeNode: true },
  10. { field: "id", title: "Id" },
  11. { field: "name", title: "地点" }
  12. ];
  13. async function onSearch() {
  14. loading.value = true;
  15. tableData.value = treeList;
  16. setTimeout(() => {
  17. loading.value = false;
  18. }, 500);
  19. }
  20. onSearch();
  21. </script>
  22. <template>
  23. <VxeTableBar
  24. tree
  25. title="虚拟树形表格"
  26. :isExpandAll="false"
  27. :vxeTableRef="vxeTableRef"
  28. :columns="columns"
  29. @refresh="onSearch"
  30. >
  31. <template v-slot="{ size, dynamicColumns }">
  32. <vxe-grid
  33. ref="vxeTableRef"
  34. v-loading="loading"
  35. show-overflow
  36. height="500"
  37. :size="size"
  38. :tree-config="{ transform: true }"
  39. :scroll-y="{ enabled: true, gt: 20 }"
  40. :columns="dynamicColumns"
  41. :data="tableData"
  42. />
  43. </template>
  44. </VxeTableBar>
  45. </template>