Skip to content

Commit c56a887

Browse files
committed
Vue3 重构:地区接入 TableV2 高性能表格
1 parent e669dff commit c56a887

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/api/system/area/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import request from '@/config/axios'
2+
3+
// 获得地区树
4+
export const getAreaTree = async () => {
5+
return await request.get({ url: '/system/area/tree' })
6+
}
7+
8+
// 获得 IP 对应的地区名
9+
export const getDeptApi = async (ip: string) => {
10+
return await request.get({ url: '/system/area/get-by-ip?ip=' + ip })
11+
}

src/views/system/area/index.vue

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
<ContentWrap>
3+
<div style="width: 100%; height: 500px">
4+
<el-auto-resizer>
5+
<template #default="{ height, width }">
6+
<el-table-v2
7+
:columns="columns"
8+
:data="tableData"
9+
:width="width"
10+
:height="height"
11+
fixed
12+
expand-column-key="id"
13+
/>
14+
</template>
15+
</el-auto-resizer>
16+
</div>
17+
</ContentWrap>
18+
</template>
19+
<script setup lang="tsx">
20+
import { Column, ElTableV2 } from 'element-plus'
21+
import * as AreaApi from '@/api/system/area'
22+
23+
const columns: Column[] = [
24+
{
25+
key: 'id',
26+
dataKey: 'id', // 需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
27+
title: '编号', // 显示在单元格表头的文本
28+
width: 200, // 当前列的宽度,必须设置
29+
fixed: true // 是否固定列
30+
},
31+
{
32+
key: 'name',
33+
dataKey: 'name',
34+
title: '地名',
35+
width: 200
36+
}
37+
]
38+
39+
const tableData = ref([])
40+
41+
const getList = async () => {
42+
tableData.value = await AreaApi.getAreaTree()
43+
}
44+
45+
getList()
46+
</script>

0 commit comments

Comments
 (0)