index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <!-- 操作栏 -->
  3. <content-wrap>
  4. <el-button type="primary" @click="openModal()">
  5. <Icon icon="ep:plus" class="mr-5px" /> IP 查询
  6. </el-button>
  7. </content-wrap>
  8. <!-- 列表 -->
  9. <content-wrap>
  10. <div style="width: 100%; height: 700px">
  11. <!-- AutoResizer 自动调节大小 -->
  12. <el-auto-resizer>
  13. <template #default="{ height, width }">
  14. <!-- Virtualized Table 虚拟化表格:高性能,解决表格在大数据量下的卡顿问题 -->
  15. <el-table-v2
  16. :columns="columns"
  17. :data="list"
  18. :width="width"
  19. :height="height"
  20. expand-column-key="id"
  21. />
  22. </template>
  23. </el-auto-resizer>
  24. </div>
  25. </content-wrap>
  26. <!-- 表单弹窗:添加/修改 -->
  27. <area-form ref="modalRef" />
  28. </template>
  29. <script setup lang="tsx" name="Area">
  30. import type { Column } from 'element-plus'
  31. import AreaForm from './form.vue'
  32. import * as AreaApi from '@/api/system/area'
  33. // 表格的 column 字段
  34. const columns: Column[] = [
  35. {
  36. dataKey: 'id', // 需要渲染当前列的数据字段。例如说:{id:9527, name:'Mike'},则填 id
  37. title: '编号', // 显示在单元格表头的文本
  38. width: 400, // 当前列的宽度,必须设置
  39. fixed: true, // 是否固定列
  40. key: 'id' // 树形展开对应的 key
  41. },
  42. {
  43. dataKey: 'name',
  44. title: '地名',
  45. width: 200
  46. }
  47. ]
  48. // 表格的数据
  49. const list = ref([])
  50. /**
  51. * 获得数据列表
  52. */
  53. const getList = async () => {
  54. list.value = await AreaApi.getAreaTree()
  55. }
  56. /** 添加/修改操作 */
  57. const modalRef = ref()
  58. const openModal = () => {
  59. modalRef.value.openModal()
  60. }
  61. /** 初始化 **/
  62. onMounted(() => {
  63. getList()
  64. })
  65. </script>