list.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { VxeTableBar } from "@/components/ReVxeTableBar";
  4. const vxeTableRef = ref();
  5. const loading = ref(true);
  6. const tableData = ref([]);
  7. const columns = [
  8. { type: "seq", field: "seq", title: "序号", width: 100 },
  9. { field: "name", title: "名称", sortable: true },
  10. { field: "role", title: "角色" },
  11. { field: "sex", title: "性别" }
  12. ];
  13. async function onSearch() {
  14. loading.value = true;
  15. // 模拟数据
  16. const mockList = [];
  17. for (let index = 0; index < 500; index++) {
  18. mockList.push({
  19. id: index,
  20. name: "Test" + index,
  21. role: "Developer",
  22. sex: "男"
  23. });
  24. }
  25. tableData.value = mockList;
  26. setTimeout(() => {
  27. loading.value = false;
  28. }, 500);
  29. }
  30. onSearch();
  31. </script>
  32. <template>
  33. <VxeTableBar
  34. :vxeTableRef="vxeTableRef"
  35. :columns="columns"
  36. title="虚拟表格"
  37. @refresh="onSearch"
  38. >
  39. <template v-slot="{ size, dynamicColumns }">
  40. <vxe-grid
  41. ref="vxeTableRef"
  42. v-loading="loading"
  43. show-overflow
  44. height="500"
  45. :size="size"
  46. :row-config="{ isHover: true }"
  47. :scroll-y="{ enabled: true }"
  48. :columns="dynamicColumns"
  49. :data="tableData"
  50. />
  51. </template>
  52. </VxeTableBar>
  53. </template>